Skip to content

Instantly share code, notes, and snippets.

@JonRowe
Created January 20, 2014 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonRowe/2c1200452672ffec0322 to your computer and use it in GitHub Desktop.
Save JonRowe/2c1200452672ffec0322 to your computer and use it in GitHub Desktop.
Failures:
1) should custom match false
Failure/Error: expect(true).to custom_match(false)
expected true to custom match false
# ./matcher_spec.rb:12:in `block (2 levels) in <top (required)>'
2) should custom match "another"
Failure/Error: expect("string").to custom_match("another")
expected "string" to custom match "another"
# ./matcher_spec.rb:15:in `block (2 levels) in <top (required)>'
Finished in 0.0006 seconds
2 examples, 2 failures
Failures:
1) should custom match false
Failure/Error: expect(true).to custom_match(false)
expected true to custom match false
Diff:
@@ -1,2 +1,2 @@
-[false]
+true
# ./matcher_spec.rb:12:in `block (2 levels) in <top (required)>'
2) should custom match "another"
Failure/Error: expect("string").to custom_match("another")
expected "string" to custom match "another"
# ./matcher_spec.rb:15:in `block (2 levels) in <top (required)>'
Finished in 0.0006 seconds
2 examples, 2 failures
RSpec::Matchers.define :custom_match do |expected|
match do |actual|
actual == expected
end
diffable
end
describe do
example do
expect(true).to custom_match(false)
end
example do
expect("string").to custom_match("another")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment