Permalink
Browse files

delegate be(val) to equal(val)

  • Loading branch information...
1 parent 7cdb347 commit deb38c9ec0b4d430cc9d5e39284594ebc112ff70 @dchelimsky dchelimsky committed Sep 4, 2010
Showing with 6 additions and 42 deletions.
  1. +1 −28 lib/rspec/matchers/be.rb
  2. +5 −14 spec/rspec/matchers/be_spec.rb
View
29 lib/rspec/matchers/be.rb
@@ -177,32 +177,6 @@ def prefix_to_sentence
end
- class BeSameAs < Be
-
- def initialize(*args, &block)
- @expected = args.shift
- @args = args
- end
-
- def matches?(actual)
- @actual = actual
- @actual.equal?(@expected)
- end
-
- def failure_message_for_should
- "expected #{@expected}, got #{@actual.inspect}"
- end
-
- def failure_message_for_should_not
- "expected not #{@expected}, got #{@actual.inspect}"
- end
-
- def description
- "be #{expected_to_sentence}#{args_to_sentence}"
- end
-
- end
-
# :call-seq:
# should be_true
# should be_false
@@ -235,8 +209,7 @@ def description
# target.should_not be_old_enough(16) #passes unless target.old_enough?(16)
def be(*args)
args.empty? ?
- Matchers::Be.new :
- Matchers::BeSameAs.new(*args)
+ Matchers::Be.new : equal(*args)
end
# passes if target.kind_of?(klass)
View
19 spec/rspec/matchers/be_spec.rb
@@ -386,25 +386,16 @@
end
describe "should be(value)" do
- it "passes if actual.equal?(value)" do
+ it "delegates to equal" do
+ self.should_receive(:equal).with(5)
5.should be(5)
end
-
- it "fails if !actual.equal?(value)" do
- lambda { 5.should be(6) }.should fail_with("expected 6, got 5")
- end
-
- it "describes itself" do
- be(5).description.should == "be 5"
- end
end
describe "should_not be(value)" do
- it "passes if !actual.equal?(value)" do
- 5.should_not be(6)
- end
- it "fails if !actual.equal?(value)" do
- lambda { 5.should_not be(5) }.should fail_with("expected not 5, got 5")
+ it "delegates to equal" do
+ self.should_receive(:equal).with(4)
+ 5.should_not be(4)
end
end

0 comments on commit deb38c9

Please sign in to comment.