Why use lambda in RSpec?
November 15th, 2007
RSpec allows you to write nice readable tests… and some little tricks make it even nicer! And I don’t know about you, but the word lambda is (1) ugly, (2) means basically bugger all and (3) is hard to pronounce late at night… so lets replace it!
Read the rest of this entryLatest comments
- Mikel
@Clemens
I actually use Geoffrey’s approach in all my spec’s in addition to this little builder.
The idea of the...
- Clemens Kofler
Geoffrey Grosenbach uses another method in his screencasts sometimes.
In your user_spec.rb, you’d have the following code:module UserSpecHelper...
- Xavier Shay
Even quicker way to assign User.find to a variable: user = _
the value of the last line executed is...
- Mikel
Duncan, good point, I changed the code above. Thanks for that.
- Duncan Beevers
It might be better to use a method name like build_valid instead of just build.
This way, you could use...
- Mikel
Exactly, this method handles it if it is false or nil and always returns true or false.
Mikel