X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/ddd5b4cf19a92582fd114914be5bd5a04d3522a7..3f607d565bc0e2c7b1b738301c11c16d069913d5:/vendor/gems/rspec-1.1.2/spec/spec/matchers/be_close_spec.rb diff --git a/vendor/gems/rspec-1.1.2/spec/spec/matchers/be_close_spec.rb b/vendor/gems/rspec-1.1.2/spec/spec/matchers/be_close_spec.rb new file mode 100644 index 000000000..d8452d408 --- /dev/null +++ b/vendor/gems/rspec-1.1.2/spec/spec/matchers/be_close_spec.rb @@ -0,0 +1,39 @@ +require File.dirname(__FILE__) + '/../../spec_helper.rb' +module Spec + module Matchers + describe BeClose do + it "should match when value == target" do + BeClose.new(5.0, 0.5).matches?(5.0).should be_true + end + it "should match when value < (target + delta)" do + BeClose.new(5.0, 0.5).matches?(5.49).should be_true + end + it "should match when value > (target - delta)" do + BeClose.new(5.0, 0.5).matches?(4.51).should be_true + end + it "should not match when value == (target - delta)" do + BeClose.new(5.0, 0.5).matches?(4.5).should be_false + end + it "should not match when value < (target - delta)" do + BeClose.new(5.0, 0.5).matches?(4.49).should be_false + end + it "should not match when value == (target + delta)" do + BeClose.new(5.0, 0.5).matches?(5.5).should be_false + end + it "should not match when value > (target + delta)" do + BeClose.new(5.0, 0.5).matches?(5.51).should be_false + end + it "should provide a useful failure message" do + #given + matcher = BeClose.new(5.0, 0.5) + #when + matcher.matches?(5.51) + #then + matcher.failure_message.should == "expected 5.0 +/- (< 0.5), got 5.51" + end + it "should describe itself" do + BeClose.new(5.0, 0.5).description.should == "be close to 5.0 (within +- 0.5)" + end + end + end +end