Skip to content

Instantly share code, notes, and snippets.

@smtlaissezfaire
Created March 17, 2009 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smtlaissezfaire/80262 to your computer and use it in GitHub Desktop.
Save smtlaissezfaire/80262 to your computer and use it in GitHub Desktop.
describe "should respond_to(message1, message2)" do
it "passes if target responds to both messages" do
Object.new.should respond_to('methods', 'inspect')
end
it "fails if target does not respond to first message" do
lambda {
Object.new.should respond_to('method_one', 'inspect')
}.should fail_with(/expected #<Object:.*> to respond to "method_one"/)
end
it "fails if target does not respond to second message" do
lambda {
Object.new.should respond_to('inspect', 'method_one')
}.should fail_with(/expected #<Object:.*> to respond to "method_one"/)
end
it "fails if target does not respond to either message" do
lambda {
Object.new.should respond_to('method_one', 'method_two')
}.should fail_with(/expected #<Object:.*> to respond to "method_one", "method_two"/)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment