Re: [rspec-users] [rspec-rails] Exception catching in controller

2011-02-17 Thread Avdi Grimm
On Thu, Feb 17, 2011 at 11:46 AM, Justin Ko wrote: > "A straight-up exception will bypass all default "rescue" clauses" - I > learn something everyday! If you will forgive a brief moment of self-promotion, I recently posted an entire talk I did on Ruby exception handling: http://avdi.org/devblog/

Re: [rspec-users] Order of execution of specs

2011-02-17 Thread Justin Ko
On Feb 16, 4:31 pm, LesNightingill wrote: > ...trying to debug some interaction between my model specs, a > particular spec passes by itself but fails when I run all my model > specs. Whenever this happens to me, 90% of the time the cause of the problem is database state. The state of the data

Re: [rspec-users] it_behaves_like and running single examples

2011-02-17 Thread Justin Ko
On Feb 16, 7:34 am, Andrew Vargo wrote: > Hello, > > I am running rspec 2 and rails 3 in a project. > > When I have a shared example being used in a spec file, I loose the > ability to run a single test in that file. > rspec spec/controllers/proposals_controller_spec.rb:13  for instance > will a

Re: [rspec-users] [rspec-rails] Exception catching in controller

2011-02-17 Thread Justin Ko
On Feb 17, 7:36 am, Avdi Grimm wrote: > On Wed, Feb 16, 2011 at 7:24 AM, Yuriy Naidyon wrote: > > def some_action > >   raise Exception if some_falsy_value > > rescue > >   @message = 'Error' > > end > > Don't raise Exception. Raise some descendant of StandardError, like > RuntimeError (the def

Re: [rspec-users] [rspec-rails] Exception catching in controller

2011-02-17 Thread Avdi Grimm
On Wed, Feb 16, 2011 at 7:24 AM, Yuriy Naidyon wrote: > def some_action >   raise Exception if some_falsy_value > rescue >   @message = 'Error' > end Don't raise Exception. Raise some descendant of StandardError, like RuntimeError (the default if you don't specify a class) or (even better) your o

Re: [rspec-users] it_behaves_like and running single examples

2011-02-17 Thread Andrew Wagner
To diagnose this, I would start to try to isolate the problem as much as possible. Get it all the way down to one file, outside of rails, with one test that exemplifies the behavior, if need be. And if you get to that point and still see the strangeness...send us a pastebin of it :) On Wed, Feb 16

[rspec-users] TypeError: can't convert RSpec::Mocks::Mock to Hash

2011-02-17 Thread Karl
In MoneyOrdersController controller: def create @money_order = current_user.money_orders.build(params[:money_order]) if @money_order.save flash.now[:msg_ok] = "Added money order for: #{number_to_currency(@money_order.amount)}" end respond_with(@money_order) end In MoneyOrdersControlle

[rspec-users] it_behaves_like and running single examples

2011-02-17 Thread Andrew Vargo
Hello, I am running rspec 2 and rails 3 in a project. When I have a shared example being used in a spec file, I loose the ability to run a single test in that file. rspec spec/controllers/proposals_controller_spec.rb:13 for instance will always give me a green '..', even if I put uparsable junk

[rspec-users] [rspec-rails] Exception catching in controller

2011-02-17 Thread Yuriy Naidyon
Hi folks. I'm currently using rspec-2.4.0 and rspec-rails-2.4.1. In the controller I have the code like this (at least at two different places): def some_action raise Exception if some_falsy_value rescue @message = 'Error' end but when I do testing with rspec this exception doesn't proceeded