[rspec-users] newbie cucumber tutorial
aslak.hellesoy at gmail.com
Mon Dec 22 12:18:27 EST 2008
On Mon, Dec 22, 2008 at 5:59 PM, Sarah Allen <lists at ruby-forum.com> wrote:
> Aslak Hellesøy wrote:
> > * I released 0.1.13 yesterday. In the Rails installation wiki page I
> > recommend using my webrat gem. It lets you use response.should
> > have_selector(...) (You're not using it in your tutorial, but just in
> > case...)
> Luckily I started with cucumber on Sunday just after your release, so
> I'm using that version. What does have_selector do? (Is there an API
> reference somewhere that I missed?)
That's part of the WebRat API:
> > * "Write a Spec" should be "Write a feature" (specs is confusing here
> > because that is what people use RSpec for. describe and it style). There
> > are
> > some other refs to "spec" which should be "feature".
> I changed it to "describe a feature," since to me "write a feature"
> means writing the code.
"Cucumber Feature Description" is probably a better term.
> When I started using cucumber, I thought it was
> part of RSpec.
It's not part of RSpec, but grew out of it.
> The cucumber .feature files still feel like a spec to me
> and since I've never used RSpec, I don't really appreciate the
They are two different projects. RSpec is for lower levels (objects). A
"test" in RSpec is called a spec. A "test" in Cucumber is called a Feature.
> > * Use bang! methods when creating records. Otherwise a failure to create
> > will silently pass without you knowing. Example:
> > task = Task.new(:description => desc) # Lose the semicolon
> > task.save!
> > Or simpler:
> > Task.create!(:description => desc)
> Thanks for the tip. 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 if
> 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
Therefore - use #create! (or #save!). In your app, use the non-bang methods.
> Fun stuff. Thanks for making this!
> 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