[rspec-users] newbie cucumber tutorial
aslak.hellesoy at gmail.com
Mon Dec 22 14:20:10 EST 2008
On Mon, Dec 22, 2008 at 8:09 PM, Sarah Allen <lists at ruby-forum.com> wrote:
> I realize this is off-topic for the RSpec forum and cucumber tutorial,
> but I'm hoping you'll enlighten me on this point which is, I guess, more
> of a Ruby language question...
> Aslak Hellesøy wrote:
> >> As you can see from my series of blog posts, I'm
> >> new to Ruby and Rails. I thought that ending a method with ! was a
> >> naming convention. Reading the humble ruby book it says "Another
> >> convention to follow is that if the method modifies its receiver in
> >> place (i.e. the method modifies the object that called it), then it
> >> should end in an exclamation point" and the Rails doc show examples of
> >> create without !
> >> http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001969 but
> >> I make the change you suggest the test passes. I've updated the
> >> tutorial and my code, but I'm confused.
> > The #create! method is documented here:
> > Essentially, #create will never raise an error no matter what you pass
> > it,
> > and you actually want exceptions for bad input in your tests (step
> > definitions).
> > Therefore - use #create! (or #save!). In your app, use the non-bang
> > methods.
> My Task model is simply defined (by the generate scaffold script) as:
> class Task < ActiveRecord::Base
> How is it that I can call Task.create! which is a method of
> ActiveRecord::Validations ?
Because ActiveRecord::Base includes the ActiveRecord::Validations module.
It's not clear from the RDoc though...
> Thanks in advance,
> Posted via http://www.ruby-forum.com/.
> rspec-users mailing list
> rspec-users at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users