On Tue, Aug 18, 2009 at 12:19 PM, Paul Mylchreest<[email protected]> wrote: > Given > rspec 1.2.8 > ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0] > > And the following spec: > > def over_limit?(a) > catch(:over_limit) do > a.each do |x| > throw(:over_limit) if x > 10 > end > end > end > > describe "when over limit" do > it "should throw symbol :over_limit" do > lambda{ > over_limit?([0, 5, 11]) > }.should throw_symbol(:over_limit) > end > end > > One would expect this to pass, however this is the result: > > when over limit > - should throw symbol :over_limit (FAILED - 1) > > 1) > 'when over limit should throw symbol :over_limit' FAILED > expected :over_limit but nothing was thrown > ./spec/rspec_tests/rutabaga_spec.rb:125: > > When the catch is removed, it works.
That's correct. The catch in over_limit() catches the throw, so it does not bubble out of the method. > > Can anyone reproduce this behavior? > > thanks > > Paul Mylchreest > [email protected] > > > > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
