aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/matchers/be_like.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/matchers/be_like.rb')
-rw-r--r--spec/support/matchers/be_like.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/support/matchers/be_like.rb b/spec/support/matchers/be_like.rb
new file mode 100644
index 0000000000..c9d4d4b979
--- /dev/null
+++ b/spec/support/matchers/be_like.rb
@@ -0,0 +1,24 @@
+module BeLikeMatcher
+ class BeLike
+ def initialize(expected)
+ @expected = expected
+ end
+
+ def matches?(actual)
+ @actual = actual
+ @expected.gsub(/\s+/, ' ').strip == @actual.gsub(/\s+/, ' ').strip
+ end
+
+ def failure_message
+ "expected\n#{@actual}\nto be like\n#{@expected}"
+ end
+
+ def negative_failure_message
+ "expected\n#{@actual}\nto be unlike\n#{@expected}"
+ end
+ end
+
+ def be_like(expected)
+ BeLike.new(expected)
+ end
+end