On Mon, Dec 22, 2008 at 5:59 PM, Sarah A. [email protected]
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
distinction.
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.
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 !
ActiveRecord::Base 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:
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001902
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.
Cheers,
Aslak