]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/matchers/throw_symbol_spec.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / matchers / throw_symbol_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3 module Spec
4   module Matchers
5     describe ThrowSymbol, "(constructed with no Symbol)" do
6       before(:each) { @matcher = ThrowSymbol.new }
7
8       it "should match if any Symbol is thrown" do
9         @matcher.matches?(lambda{ throw :sym }).should be_true
10       end
11       it "should not match if no Symbol is thrown" do
12         @matcher.matches?(lambda{ }).should be_false
13       end
14       it "should provide a failure message" do
15         @matcher.matches?(lambda{})
16         @matcher.failure_message.should == "expected a Symbol but nothing was thrown"
17       end
18       it "should provide a negative failure message" do
19         @matcher.matches?(lambda{ throw :sym})
20         @matcher.negative_failure_message.should == "expected no Symbol, got :sym"
21       end
22     end
23     
24     describe ThrowSymbol, "(constructed with a Symbol)" do
25       before(:each) { @matcher = ThrowSymbol.new(:sym) }
26       
27       it "should match if correct Symbol is thrown" do
28         @matcher.matches?(lambda{ throw :sym }).should be_true
29       end
30       it "should not match if no Symbol is thrown" do
31         @matcher.matches?(lambda{ }).should be_false
32       end
33       it "should not match if correct Symbol is thrown" do
34         @matcher.matches?(lambda{ throw :other_sym }).should be_false
35         @matcher.failure_message.should == "expected :sym, got :other_sym"
36       end
37       it "should provide a failure message when no Symbol is thrown" do
38         @matcher.matches?(lambda{})
39         @matcher.failure_message.should == "expected :sym but nothing was thrown"
40       end
41       it "should provide a failure message when wrong Symbol is thrown" do
42         @matcher.matches?(lambda{ throw :other_sym })
43         @matcher.failure_message.should == "expected :sym, got :other_sym"
44       end
45       it "should provide a negative failure message" do
46         @matcher.matches?(lambda{ throw :sym })
47         @matcher.negative_failure_message.should == "expected :sym not to be thrown"
48       end
49       it "should only match NameErrors raised by uncaught throws" do
50         @matcher.matches?(lambda{ sym }).should be_false
51       end
52     end
53   end
54 end