Class: RSpec::RubyContentMatchers::IncludeModule
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::IncludeModule
- Defined in:
- lib/code_spec/matchers/include_module.rb
Constant Summary
Constants inherited from RSpec::RubyContentMatcher
RSpec::RubyContentMatcher::ANY_GROUP, RSpec::RubyContentMatcher::LPAR, RSpec::RubyContentMatcher::OPT_ARGS, RSpec::RubyContentMatcher::OPT_SPACES, RSpec::RubyContentMatcher::Q_ANY_GROUP, RSpec::RubyContentMatcher::RPAR, RSpec::RubyContentMatcher::SPACES
Instance Attribute Summary collapse
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from RSpec::RubyContentMatcher
#alt_end, #content, #content_matches, #end_option
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(module_name, type = nil) ⇒ IncludeModule
constructor
A new instance of IncludeModule.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from RSpec::RubyContentMatcher
#any_args_expr, #args_expr, #args_msg, #comment_end, #debug, #debug?, #debug_content, #display, #display_content, #end_expr, #get_expr, #handle_result, #index, #indexes, #is_match?, #main_expr, #opt
Constructor Details
#initialize(module_name, type = nil) ⇒ IncludeModule
Returns a new instance of IncludeModule.
5 6 7 8 |
# File 'lib/code_spec/matchers/include_module.rb', line 5 def initialize module_name, type=nil @module_name = module_name.to_s.camelize @type = type || :include end |
Instance Attribute Details
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
3 4 5 |
# File 'lib/code_spec/matchers/include_module.rb', line 3 def module_name @module_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/code_spec/matchers/include_module.rb', line 3 def type @type end |
Instance Method Details
#failure_message ⇒ Object
15 16 17 18 |
# File 'lib/code_spec/matchers/include_module.rb', line 15 def super display "Expected there to be an inclusion of module #{module_name}" end |
#matches?(content) ⇒ Boolean
10 11 12 13 |
# File 'lib/code_spec/matchers/include_module.rb', line 10 def matches?(content) @content = content (content =~ /#{type}\s+#{module_name}/) end |
#negative_failure_message ⇒ Object
20 21 22 23 |
# File 'lib/code_spec/matchers/include_module.rb', line 20 def super display "Did not expect there to be an inclusion of module #{module_name}" end |