~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to vendor/gems/rspec/spec/spec/matchers/be_close_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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