Skip to content

Instantly share code, notes, and snippets.

@suweller
Created June 26, 2012 13:50
Show Gist options
  • Save suweller/2995882 to your computer and use it in GitHub Desktop.
Save suweller/2995882 to your computer and use it in GitHub Desktop.
Rspec - Inheritance matcher
RSpec::Matchers.define :inherit_from do |superclass|
match do |klass|
klass.class.ancestors.include? superclass
end
failure_message_for_should do |klass|
"expected #{klass.class.name} to inherit from #{superclass}"
end
failure_message_for_should_not do |klass|
"expected #{klass.class.name} not to inherit from #{superclass}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment