Skip to content

Instantly share code, notes, and snippets.

@technicalpickles
Created September 24, 2009 21:34
Show Gist options
  • Save technicalpickles/193071 to your computer and use it in GitHub Desktop.
Save technicalpickles/193071 to your computer and use it in GitHub Desktop.
Spec::Matchers.define :include_module do |mod|
match do |instance|
mod.instance_methods.inject(true) { |accum, method| accum && instance.respond_to?(method) }
end
failure_message_for_should do |instance|
"expected the class #{instance.class.name} to include the module #{mod}"
end
failure_message_for_should_not do |instance|
"expected the class #{instance.class.name} not to include the module #{mod}"
end
description do
"expected a class to include a mod by responding to all of its methods"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment