Sha256: a6d3d8a18969a18c16711bb2d7a68a7e8ea24fbba7ae18a4f9157f53c811721c

Contents?: true

Size: 1.81 KB

Versions: 20

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe "should cover(expected)", :if => RSpec::Matchers.respond_to?(:cover) do
  context "for a range target" do
    it "passes if target covers expected" do
      (1..10).should cover(5)
    end

    it "fails if target does not cover expected" do
      lambda {
        (1..10).should cover(11)
      }.should fail_with("expected 1..10 to cover 11")
    end
  end
end

describe "should cover(with, multiple, args)", :if => RSpec::Matchers.respond_to?(:cover) do
  context "for a range target" do
    it "passes if target covers all items" do
      (1..10).should cover(4, 6)
    end

    it "fails if target does not cover any one of the items" do
      lambda {
        (1..10).should cover(4, 6, 11)
      }.should fail_with("expected 1..10 to cover 4, 6, and 11")
    end
  end
end

describe "should_not cover(expected)", :if => RSpec::Matchers.respond_to?(:cover) do
  context "for a range target" do
    it "passes if target does not cover expected" do
      (1..10).should_not cover(11)
    end

    it "fails if target covers expected" do
      lambda {
        (1..10).should_not cover(5)
      }.should fail_with("expected 1..10 not to cover 5")
    end
  end
end

describe "should_not cover(with, multiple, args)", :if => RSpec::Matchers.respond_to?(:cover) do
  context "for a range target" do
    it "passes if the target does not cover any of the expected" do
      (1..10).should_not include(11, 12, 13)
    end

    it "fails if the target covers all of the expected" do
      expect {
        (1..10).should_not include(4, 6)
      }.to fail_with("expected 1..10 not to include 4 and 6")
    end

    it "fails if the target covers some (but not all) of the expected" do
      expect {
        (1..10).should_not include(5, 11)
      }.to fail_with("expected 1..10 not to include 5 and 11")
    end
  end
end


Version data entries

20 entries across 18 versions & 4 rubygems

Version Path
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.8.0/spec/rspec/matchers/cover_spec.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.8.0/spec/rspec/matchers/cover_spec.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-expectations-2.8.0/spec/rspec/matchers/cover_spec.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-expectations-2.8.0/spec/rspec/matchers/cover_spec.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
horseman-0.0.2 vendor/ruby/1.9.1/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
rspec-expectations-2.8.0 spec/rspec/matchers/cover_spec.rb
nutshell-crm-0.0.6.alpha vendor/bundle/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
rspec-expectations-2.8.0.rc2 spec/rspec/matchers/cover_spec.rb
nutshell-crm-0.0.5 vendor/bundle/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
nutshell-crm-0.0.4 vendor/bundle/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
nutshell-crm-0.0.3 vendor/bundle/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
nutshell-crm-0.0.2 vendor/bundle/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
nutshell-crm-0.0.1 vendor/bundle/gems/rspec-expectations-2.7.0/spec/rspec/matchers/cover_spec.rb
rspec-expectations-2.8.0.rc1 spec/rspec/matchers/cover_spec.rb
rspec-expectations-2.7.0 spec/rspec/matchers/cover_spec.rb
rspec-expectations-2.7.0.rc1 spec/rspec/matchers/cover_spec.rb
rspec-expectations-2.6.0 spec/rspec/matchers/cover_spec.rb
rspec-expectations-2.6.0.rc6 spec/rspec/matchers/cover_spec.rb