Created
July 20, 2012 12:41
-
-
Save mattsnyder/3150522 to your computer and use it in GitHub Desktop.
Example custom matcher to use for testing roman numeral conversions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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