Forum: Ruby on Rails Shouldn't this spec fail?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D5145c421cd25af6fa577c15219add90?d=identicon&s=25 unknown (Guest)
on 2007-04-27 01:36
(Received via mailing list)
Shouldn't the second spec fail? I'm trying to provide a default value in
model (I'm well aware this is normally the job of the controller, but it
seems right to be the model in this case). Also, after_initialize
seem to be the right way of doing this, but before_create or any of the
other things don't make the first test pass.

specify "should provide a default name when none is given" do
  @emailer.attributes = valid_emailer_attributes.except(:name)

specify "should not replace name if one is given" do
  @emailer.attributes = valid_emailer_attributes  # valid name attribute

class Emailer < ActiveRecord::Base
    def after_initialize = "joe"

I know how to code what I'm trying to do, but I want to make sure I only
the minimum to make the specs pass, in proper TDD/BDD style.

This topic is locked and can not be replied to.