]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/matchers/be_close_spec.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / matchers / be_close_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2 module Spec
3   module Matchers
4     describe BeClose do
5       it "should match when value == target" do
6         BeClose.new(5.0, 0.5).matches?(5.0).should be_true
7       end
8       it "should match when value < (target + delta)" do
9         BeClose.new(5.0, 0.5).matches?(5.49).should be_true
10       end
11       it "should match when value > (target - delta)" do
12         BeClose.new(5.0, 0.5).matches?(4.51).should be_true
13       end
14       it "should not match when value == (target - delta)" do
15         BeClose.new(5.0, 0.5).matches?(4.5).should be_false
16       end
17       it "should not match when value < (target - delta)" do
18         BeClose.new(5.0, 0.5).matches?(4.49).should be_false
19       end
20       it "should not match when value == (target + delta)" do
21         BeClose.new(5.0, 0.5).matches?(5.5).should be_false
22       end
23       it "should not match when value > (target + delta)" do
24         BeClose.new(5.0, 0.5).matches?(5.51).should be_false
25       end
26       it "should provide a useful failure message" do
27         #given
28           matcher = BeClose.new(5.0, 0.5)
29         #when
30           matcher.matches?(5.51)
31         #then
32           matcher.failure_message.should == "expected 5.0 +/- (< 0.5), got 5.51"
33       end
34       it "should describe itself" do
35         BeClose.new(5.0, 0.5).description.should == "be close to 5.0 (within +- 0.5)"
36       end
37     end
38   end
39 end