1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
3 describe "should respond_to(:sym)" do
5 it "should pass if target responds to :sym" do
6 Object.new.should respond_to(:methods)
9 it "should fail target does not respond to :sym" do
11 Object.new.should respond_to(:some_method)
12 }.should fail_with("expected target to respond to :some_method")
17 describe "should respond_to(message1, message2)" do
19 it "should pass if target responds to both messages" do
20 Object.new.should respond_to('methods', 'inspect')
23 it "should fail target does not respond to first message" do
25 Object.new.should respond_to('method_one', 'inspect')
26 }.should fail_with('expected target to respond to "method_one"')
29 it "should fail target does not respond to second message" do
31 Object.new.should respond_to('inspect', 'method_one')
32 }.should fail_with('expected target to respond to "method_one"')
35 it "should fail target does not respond to either message" do
37 Object.new.should respond_to('method_one', 'method_two')
38 }.should fail_with('expected target to respond to "method_one", "method_two"')
42 describe "should_not respond_to(:sym)" do
44 it "should pass if target does not respond to :sym" do
45 Object.new.should_not respond_to(:some_method)
48 it "should fail target responds to :sym" do
50 Object.new.should_not respond_to(:methods)
51 }.should fail_with("expected target not to respond to :methods")