Skip to content

Instantly share code, notes, and snippets.

@lmarburger
Created May 29, 2009 15:35
Show Gist options
  • Save lmarburger/120010 to your computer and use it in GitHub Desktop.
Save lmarburger/120010 to your computer and use it in GitHub Desktop.
class ActiveSupport::TestCase
# Create a be_a / be_an matchy matcher.
# @video.should be_a(Video)
# @video.should_not be_an(Octopus)
custom_matcher :be_a do |receiver, matcher, args|
expected = args[0]
matcher.positive_failure_message = "Expected #{ receiver.inspect } to be a #{ expected.inspect }."
matcher.negative_failure_message = "Expected #{ receiver.inspect } to not be a #{ expected.inspect }."
receiver.is_a? expected
end
alias :be_an :be_a
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment