diff options
author | Josh Susser <josh@hasmanythrough.com> | 2008-03-15 18:13:46 -0700 |
---|---|---|
committer | Josh Susser <josh@hasmanythrough.com> | 2008-03-15 18:13:46 -0700 |
commit | 9c00e8b0f0dc422e4bf5efa3fb79cda2cb0ac6a1 (patch) | |
tree | a5ce787629563b0265be9d35c1adf3a9504a4012 /spec/matchers | |
parent | 5d7c8176f1df8df819dadb1973a202a1c2d9836d (diff) | |
parent | cd9efb9eec6198f08b4fd5d754a33aa1b1669b37 (diff) | |
download | rails-9c00e8b0f0dc422e4bf5efa3fb79cda2cb0ac6a1.tar.gz rails-9c00e8b0f0dc422e4bf5efa3fb79cda2cb0ac6a1.tar.bz2 rails-9c00e8b0f0dc422e4bf5efa3fb79cda2cb0ac6a1.zip |
merge changes from nick
Diffstat (limited to 'spec/matchers')
-rw-r--r-- | spec/matchers/hash_the_same_as.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/matchers/hash_the_same_as.rb b/spec/matchers/hash_the_same_as.rb new file mode 100644 index 0000000000..86e98f31a3 --- /dev/null +++ b/spec/matchers/hash_the_same_as.rb @@ -0,0 +1,26 @@ +module HashTheSameAsMatcher + class HashTheSameAs + def initialize(expected) + @expected = expected + end + + def matches?(target) + @target = target + hash = {} + hash[@expected] = :some_arbitrary_value + hash[@target] == :some_arbitrary_value + end + + def failure_message + "expected #{@target} to hash the same as #{@expected}; they must be `eql?` and have the same `#hash` value" + end + + def negative_failure_message + "expected #{@target} to hash differently than #{@expected}; they must not be `eql?` or have a differing `#hash` values" + end + end + + def hash_the_same_as(expected) + HashTheSameAs.new(expected) + end +end
\ No newline at end of file |