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.
7 8 9 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 7 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.
5 6 7 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 5 def module_name @module_name end |
Instance Method Details
#failure_message ⇒ Object
22 23 24 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 22 def "Expected there to be an inclusion of module #{module_name}" end |
#matches?(content) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 11 def matches?(content) @content = 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
26 27 28 |
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 26 def "Did not expect there to be an inclusion of module #{module_name}" end |