[rspec-users] newbie cucumber tutorial

Pat Maddox pergesu at gmail.com
Mon Dec 22 15:30:12 EST 2008


On Mon, Dec 22, 2008 at 11:29 AM, Caius Durling <caius at caius.name> wrote:
>
> On 22 Dec 2008, at 17:18, aslak hellesoy wrote:
>
> 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.
>
> Use the bang methods everywhere, but make sure to catch
> ActiveRecord::RecordInvalid and ActiveRecord::RecordNotFound either in
> rescue_from handlers or within the controller actions themselves.
> If you use rescue_from you need to turn on rails_error_handling in rspec's
> config though.
> C
> ---
> Caius Durling
> caius at caius.name
> +44 (0) 7960 268 100
> http://caius.name/
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

I'm a "use the non-bang methods in the app, bang methods in tests"
guy.  In the app, I don't want an exception to be raised, because
validation failures aren't exceptional.  if @post.save is good enough
to know what happened.  In tests though, I want it to fail fast and
noisily, so I use bang methods.

Pat


More information about the rspec-users mailing list