[rspec-users] newbie cucumber tutorial
Sarah Allen
lists at ruby-forum.com
Mon Dec 22 11:59:51 EST 2008
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?)
> * "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. When I started using cucumber, I thought it was
part of RSpec. The cucumber .feature files still feel like a spec to me
and since I've never used RSpec, I don't really appreciate the
distinction.
> * 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.
Fun stuff. Thanks for making this!
Sarah
--
Posted via http://www.ruby-forum.com/.
More information about the rspec-users
mailing list