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