Sha256: e3bf924a46554357687075de979386d80c7d8ce37a8466d452665bcf1669c2c6

Contents?: true

Size: 1.59 KB

Versions: 20

Compression:

Stored size: 1.59 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 {
      "this string".should respond_to(:some_method)
    }.should fail_with("expected \"this string\" 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 #<Object:.*> 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 #<Object:.*> 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 #<Object:.*> 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 #<Object:.*> not to respond to :methods/)
  end
  
end

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
dchelimsky-rspec-1.1.10 spec/spec/matchers/respond_to_spec.rb
dchelimsky-rspec-1.1.11.1 spec/spec/matchers/respond_to_spec.rb
dchelimsky-rspec-1.1.11.2 spec/spec/matchers/respond_to_spec.rb
dchelimsky-rspec-1.1.11.3 spec/spec/matchers/respond_to_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/matchers/respond_to_spec.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb
mack-0.8.2 lib/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb
rspec-1.1.10 spec/spec/matchers/respond_to_spec.rb
rspec-1.1.7 spec/spec/matchers/respond_to_spec.rb
rspec-1.1.11 spec/spec/matchers/respond_to_spec.rb
rspec-1.1.6 spec/spec/matchers/respond_to_spec.rb
rspec-1.1.9 spec/spec/matchers/respond_to_spec.rb
rspec-1.1.8 spec/spec/matchers/respond_to_spec.rb
typo-5.1.98 vendor/plugins/rspec/spec/spec/matchers/respond_to_spec.rb
typo-5.2 vendor/plugins/rspec/spec/spec/matchers/respond_to_spec.rb