Created
July 7, 2010 19:47
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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