Sha256: 2ca20be8e527ba6356e5b661eb55dda27c87de9df5de81eadbf364b69f336d4a

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

describe "should respond_to(:sym)" do

  it "should pass if target responds to :sym" do
    Object.new.should respond_to(:methods)
  end

  it "should fail target does not respond to :sym" do
    lambda {
      Object.new.should respond_to(:some_method)
    }.should fail_with("expected target to respond to :some_method")
  end

end

describe "should respond_to(message1, message2)" do

  it "should pass if target responds to both messages" do
    Object.new.should respond_to('methods', 'inspect')
  end

  it "should fail target does not respond to first message" do
    lambda {
      Object.new.should respond_to('method_one', 'inspect')
    }.should fail_with('expected target to respond to "method_one"')
  end

  it "should fail target does not respond to second message" do
    lambda {
      Object.new.should respond_to('inspect', 'method_one')
    }.should fail_with('expected target to respond to "method_one"')
  end

  it "should fail target does not respond to either message" do
    lambda {
      Object.new.should respond_to('method_one', 'method_two')
    }.should fail_with('expected target to respond to "method_one", "method_two"')
  end
end

describe "should_not respond_to(:sym)" do

  it "should pass if target does not respond to :sym" do
    Object.new.should_not respond_to(:some_method)
  end

  it "should fail target responds to :sym" do
    lambda {
      Object.new.should_not respond_to(:methods)
    }.should fail_with("expected target not to respond to :methods")
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picolena-0.1.6 rails_plugins/rspec/spec/spec/matchers/respond_to_spec.rb
picolena-0.1.7 rails_plugins/rspec/spec/spec/matchers/respond_to_spec.rb
picolena-0.1.8 rails_plugins/rspec/spec/spec/matchers/respond_to_spec.rb