Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix test for cover

  • Loading branch information...
commit fb361608047cefa299568bed176ad1f2a456ad23 1 parent 867260b
David Chelimsky dchelimsky authored
Showing with 47 additions and 45 deletions.
  1. +1 −1  lib/rspec/matchers.rb
  2. +46 −44 spec/rspec/matchers/cover_spec.rb
2  lib/rspec/matchers.rb
View
@@ -353,7 +353,7 @@ def change(receiver=nil, message=nil, &block)
# ### Warning:: Ruby >= 1.9 only
def cover(*values)
BuiltIn::Cover.new(*values)
- end
+ end if (1..2).respond_to?(:cover)
# Passes if <tt>actual == expected</tt>.
#
90 spec/rspec/matchers/cover_spec.rb
View
@@ -1,63 +1,65 @@
require 'spec_helper'
-describe "should cover(expected)", :if => defined?("[].cover?") do
- context "for a range target" do
- it "passes if target covers expected" do
- (1..10).should cover(5)
- end
+if (1..2).respond_to?(:cover)
+ describe "should cover(expected)" 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")
+ 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
-end
-describe "should cover(with, multiple, args)", :if => defined?("[].cover?") do
- context "for a range target" do
- it "passes if target covers all items" do
- (1..10).should cover(4, 6)
- end
+ describe "should cover(with, multiple, args)" 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")
+ 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
-end
-describe "should_not cover(expected)", :if => defined?("[].cover?") do
- context "for a range target" do
- it "passes if target does not cover expected" do
- (1..10).should_not cover(11)
- end
+ describe "should_not cover(expected)" 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")
+ 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
-end
-describe "should_not cover(with, multiple, args)", :if => defined?("[].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
+ describe "should_not cover(with, multiple, args)" 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 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")
+ 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
end
Please sign in to comment.
Something went wrong with that request. Please try again.