]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/matchers/respond_to_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 / respond_to_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3 describe "should respond_to(:sym)" do
4   
5   it "should pass if target responds to :sym" do
6     Object.new.should respond_to(:methods)
7   end
8   
9   it "should fail target does not respond to :sym" do
10     lambda {
11       Object.new.should respond_to(:some_method)
12     }.should fail_with("expected target to respond to :some_method")
13   end
14   
15 end
16
17 describe "should respond_to(message1, message2)" do
18   
19   it "should pass if target responds to both messages" do
20     Object.new.should respond_to('methods', 'inspect')
21   end
22   
23   it "should fail target does not respond to first message" do
24     lambda {
25       Object.new.should respond_to('method_one', 'inspect')
26     }.should fail_with('expected target to respond to "method_one"')
27   end
28   
29   it "should fail target does not respond to second message" do
30     lambda {
31       Object.new.should respond_to('inspect', 'method_one')
32     }.should fail_with('expected target to respond to "method_one"')
33   end
34   
35   it "should fail target does not respond to either message" do
36     lambda {
37       Object.new.should respond_to('method_one', 'method_two')
38     }.should fail_with('expected target to respond to "method_one", "method_two"')
39   end
40 end
41
42 describe "should_not respond_to(:sym)" do
43   
44   it "should pass if target does not respond to :sym" do
45     Object.new.should_not respond_to(:some_method)
46   end
47   
48   it "should fail target responds to :sym" do
49     lambda {
50       Object.new.should_not respond_to(:methods)
51     }.should fail_with("expected target not to respond to :methods")
52   end
53   
54 end