Class: RSpec::RubyContentMatchers::IncludeModule
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::IncludeModule
- Defined in:
- lib/rspec_for_generators/matchers/content/include_module.rb
Instance Attribute Summary collapse
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(module_name) ⇒ IncludeModule
constructor
A new instance of IncludeModule.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(module_name) ⇒ IncludeModule
Returns a new instance of IncludeModule.
5 6 7 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 5 def initialize module_name @module_name = module_name.to_s.camelize end |
Instance Attribute Details
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
3 4 5 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 3 def module_name @module_name end |
Instance Method Details
#failure_message ⇒ Object
19 20 21 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 19 def "Expected there to be an inclusion of module #{module_name}" end |
#matches?(content) ⇒ Boolean
9 10 11 12 13 14 15 16 17 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 9 def matches?(content) match_res = (content =~ /include\s+#{module_name}/) if block_given? && match_res ruby_content = content.extend(RSpec::RubyContent::Helpers) yield ruby_content else match_res end end |
#negative_failure_message ⇒ Object
23 24 25 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 23 def "Did not expect there to be an inclusion of module #{module_name}" end |