Skip to content

Instantly share code, notes, and snippets.

@maiha
Created December 4, 2009 18:56
Show Gist options
  • Save maiha/249252 to your computer and use it in GitHub Desktop.
Save maiha/249252 to your computer and use it in GitHub Desktop.
Spec::Matchers.define :be_extension_of do |expected|
match do |obj|
(class << obj; self; end).ancestors.include?(expected)
end
end
obj = Object.new
obj.should be_extension_of(Kernel) # => true
obj.should be_extension_of(Spec) # Spec::Expectations::ExpectationNotMetError
obj.extend(Spec)
obj.should be_extension_of(Spec) # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment