Skip to content

Instantly share code, notes, and snippets.

@seeflanigan
Created July 7, 2010 19:47
Show Gist options
  • Save seeflanigan/467172 to your computer and use it in GitHub Desktop.
Save seeflanigan/467172 to your computer and use it in GitHub Desktop.
RSpec matcher/macro to detect if a module is included in another module or class.
module CustomMacros
def it_should_include_module(expected)
it "should include #{expected}" do
should include_module(expected)
end
end
def it_should_not_include_module(expected)
it "should not include #{expected}" do
should_not include_module(expected)
end
end
end
module CustomMatchers
def include_module(expected)
simple_matcher("should include module #{expected}") do |actual|
module_name = expected.to_s.camelize
actual.class.included_modules.include?(module_name.constantize)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment