Skip to content

Instantly share code, notes, and snippets.

@mattsnyder
Created July 20, 2012 12:41
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 mattsnyder/3150522 to your computer and use it in GitHub Desktop.
Save mattsnyder/3150522 to your computer and use it in GitHub Desktop.
Example custom matcher to use for testing roman numeral conversions
RSpec::Matchers.define :be_converted_to do |expected|
match do |actual|
@result = Calculator.convert(actual)
@result == expected
end
failure_message_for_should do
"Expected #{actual} to be converted to #{expected}, but got #{@result}"
end
failure_message_for_should_not do
"Expected #{actual} to not be converted of #{expected}"
end
description do
"#{actual} be converted to #{expected}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment