Sha256: 1b8a7b7b2069f2656fa08fa91806c9a00b959caa6217bc62152fe60229299eca

Contents?: true

Size: 1.61 KB

Versions: 54

Compression:

Stored size: 1.61 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")

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

54 entries across 54 versions & 3 rubygems

Version Path
rsanheim-micronaut-0.1.3.2 examples/lib/micronaut/matchers/respond_to_example.rb
rsanheim-micronaut-0.1.4.1 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.0.3 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.0.4 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.0.5 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.0.6 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.0.7 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.0.9 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.0 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.1 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.2 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.3 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.4.1 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.4.2 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.4.3 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.4.4 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.4 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.5.2 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.5 examples/lib/micronaut/matchers/respond_to_example.rb
spicycode-micronaut-0.1.6.1 examples/lib/micronaut/matchers/respond_to_example.rb