]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/lib/spec/matchers/equal.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / lib / spec / matchers / equal.rb
1 module Spec
2   module Matchers
3   
4     class Equal #:nodoc:
5       def initialize(expected)
6         @expected = expected
7       end
8   
9       def matches?(actual)
10         @actual = actual
11         @actual.equal?(@expected)
12       end
13
14       def failure_message
15         return "expected #{@expected.inspect}, got #{@actual.inspect} (using .equal?)", @expected, @actual
16       end
17
18       def negative_failure_message
19         return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .equal?)", @expected, @actual
20       end
21       
22       def description
23         "equal #{@expected.inspect}"
24       end
25     end
26     
27     # :call-seq:
28     #   should equal(expected)
29     #   should_not equal(expected)
30     #
31     # Passes if actual and expected are the same object (object identity).
32     #
33     # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
34     #
35     # == Examples
36     #
37     #   5.should equal(5) #Fixnums are equal
38     #   "5".should_not equal("5") #Strings that look the same are not the same object
39     def equal(expected)
40       Matchers::Equal.new(expected)
41     end
42   end
43 end