njmacinnes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-26 23:36 UTC
Shouldn''t this spec fail?
Shouldn''t the second spec fail? I''m trying to provide a
default value in the
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
doesn''t
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)
@emailer.name.should_not_be_nil
@emailer.should_be_valid
end
specify "should not replace name if one is given" do
@emailer.attributes = valid_emailer_attributes # valid name attribute is
"bill"
(@emailer.name=="bill").should_be_true
end
class Emailer < ActiveRecord::Base
def after_initialize
self.name = "joe"
end
end
I know how to code what I''m trying to do, but I want to make sure I
only do
the minimum to make the specs pass, in proper TDD/BDD style.
-Nathan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
