Sha256: 4ea31f1d0bea4bc5c54b3d402c060b86607ccd0215ce6b13ca49e902a4d34a99
Contents?: true
Size: 1.9 KB
Versions: 10
Compression:
Stored size: 1.9 KB
Contents
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper") describe Micronaut::Matchers do describe "should have_sym(*args)" do it "should pass if #has_sym?(*args) returns true" do {:a => "A"}.should have_key(:a) end it "should fail if #has_sym?(*args) returns false" do lambda { {:b => "B"}.should have_key(:a) }.should fail_with("expected #has_key?(:a) to return true, got false") end it "should fail if target does not respond to #has_sym?" do lambda { Object.new.should have_key(:a) }.should raise_error(NoMethodError) end it "should reraise an exception thrown in #has_sym?(*args)" do o = Object.new def o.has_sym?(*args) raise "Funky exception" end lambda { o.should have_sym(:foo) }.should raise_error("Funky exception") end end describe "should_not have_sym(*args)" do it "should pass if #has_sym?(*args) returns false" do {:a => "A"}.should_not have_key(:b) end it "should fail if #has_sym?(*args) returns true" do lambda { {:a => "A"}.should_not have_key(:a) }.should fail_with("expected #has_key?(:a) to return false, got true") end it "should fail if target does not respond to #has_sym?" do lambda { Object.new.should have_key(:a) }.should raise_error(NoMethodError) end it "should reraise an exception thrown in #has_sym?(*args)" do o = Object.new def o.has_sym?(*args) raise "Funky exception" end lambda { o.should_not have_sym(:foo) }.should raise_error("Funky exception") end end describe "has" do it "should work when the target implements #send" do o = {:a => "A"} def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end lambda { o.should have_key(:a) }.should_not raise_error end end end
Version data entries
10 entries across 10 versions & 2 rubygems