Permalink
Browse files

more more consistency across failure messages for operator matchers

  • Loading branch information...
1 parent fe8f85e commit d1566d412de2274264fea39ebfccbbb1258a79a0 @dchelimsky dchelimsky committed Dec 20, 2010
Showing with 15 additions and 47 deletions.
  1. +13 −45 features/matchers/operators.feature
  2. +1 −1 lib/rspec/matchers/be.rb
  3. +1 −1 spec/rspec/matchers/be_spec.rb
@@ -90,17 +90,13 @@ Feature: Operator matchers
"""
describe "Strawberry" do
it { should == "Strawberry" }
- it { should < "Tomato" }
- it { should > "Apple" }
- it { should <= "Turnip" }
- it { should >= "Banana" }
+ it { should be < "Tomato" }
+ it { should be > "Apple" }
+ it { should be <= "Turnip" }
+ it { should be >= "Banana" }
it { should =~ /berry/ }
it { should_not == "Peach" }
- it { should_not < "Cranberry" }
- it { should_not > "Zuchini" }
- it { should_not <= "Potato" }
- it { should_not >= "Tomato" }
it { should_not =~ /apple/ }
it "reports that it is a string using ===" do
@@ -109,17 +105,13 @@ Feature: Operator matchers
# deliberate failures
it { should == "Peach" }
- it { should < "Cranberry" }
- it { should > "Zuchini" }
- it { should <= "Potato" }
- it { should >= "Tomato" }
+ it { should be < "Cranberry" }
+ it { should be > "Zuchini" }
+ it { should be <= "Potato" }
+ it { should be >= "Tomato" }
it { should =~ /apple/ }
it { should_not == "Strawberry" }
- it { should_not < "Tomato" }
- it { should_not > "Apple" }
- it { should_not <= "Turnip" }
- it { should_not >= "Banana" }
it { should_not =~ /berry/ }
it "fails a spec asserting that it is a symbol" do
@@ -128,7 +120,7 @@ Feature: Operator matchers
end
"""
When I run "rspec string_operator_matchers_spec.rb"
- Then the output should contain "26 examples, 13 failures"
+ Then the output should contain "18 examples, 9 failures"
And the output should contain:
"""
Failure/Error: it { should == "Peach" }
@@ -137,25 +129,25 @@ Feature: Operator matchers
"""
And the output should contain:
"""
- Failure/Error: it { should < "Cranberry" }
+ Failure/Error: it { should be < "Cranberry" }
expected: < "Cranberry"
got: "Strawberry"
"""
And the output should contain:
"""
- Failure/Error: it { should > "Zuchini" }
+ Failure/Error: it { should be > "Zuchini" }
expected: > "Zuchini"
got: "Strawberry"
"""
And the output should contain:
"""
- Failure/Error: it { should <= "Potato" }
+ Failure/Error: it { should be <= "Potato" }
expected: <= "Potato"
got: "Strawberry"
"""
And the output should contain:
"""
- Failure/Error: it { should >= "Tomato" }
+ Failure/Error: it { should be >= "Tomato" }
expected: >= "Tomato"
got: "Strawberry"
"""
@@ -173,30 +165,6 @@ Feature: Operator matchers
"""
And the output should contain:
"""
- Failure/Error: it { should_not < "Tomato" }
- expected not: < "Tomato"
- got: "Strawberry"
- """
- And the output should contain:
- """
- Failure/Error: it { should_not > "Apple" }
- expected not: > "Apple"
- got: "Strawberry"
- """
- And the output should contain:
- """
- Failure/Error: it { should_not <= "Turnip" }
- expected not: <= "Turnip"
- got: "Strawberry"
- """
- And the output should contain:
- """
- Failure/Error: it { should_not >= "Banana" }
- expected not: >= "Banana"
- got: "Strawberry"
- """
- And the output should contain:
- """
Failure/Error: it { should_not =~ /berry/ }
expected not: =~ /berry/
got: "Strawberry"
View
@@ -96,7 +96,7 @@ def matches?(actual)
end
def failure_message_for_should
- "expected: #{@operator} #{@expected}\n got: #{@operator.to_s.gsub(/./, ' ')} #{@actual.inspect}"
+ "expected: #{@operator} #{@expected.inspect}\n got: #{@operator.to_s.gsub(/./, ' ')} #{@actual.inspect}"
end
def failure_message_for_should_not
@@ -347,7 +347,7 @@
end
it "fails when === operator returns false" do
- lambda { Hash.should be === "not a hash" }.should fail_with(%[expected: === not a hash\n got: Hash])
+ lambda { Hash.should be === "not a hash" }.should fail_with(%[expected: === "not a hash"\n got: Hash])
end
end

0 comments on commit d1566d4

Please sign in to comment.