Sha256: d13c3d19c9e11d0ac1393fed53341f20136a80312e118db5d7aca5e1f8128ba6

Contents?: true

Size: 1.39 KB

Versions: 77

Compression:

Stored size: 1.39 KB

Contents

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

Version data entries

77 entries across 77 versions & 12 rubygems

Version Path
dchelimsky-rspec-1.1.10 spec/spec/matchers/be_close_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/matchers/be_close_spec.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb
deckshuffler-0.0.2 vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
mack-0.8.2 lib/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/spec/spec/matchers/be_close_spec.rb
picolena-0.1.0 rails_plugins/rspec/spec/spec/matchers/be_close_spec.rb
picolena-0.1.1 rails_plugins/rspec/spec/spec/matchers/be_close_spec.rb