Class: RSpec::RubyContentMatchers::HaveModule
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::HaveModule
- Defined in:
- lib/generator_spec/matchers/content/have_module.rb
Instance Attribute Summary collapse
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
Attributes inherited from RSpec::RubyContentMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(module_name) ⇒ HaveModule
constructor
A new instance of HaveModule.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from RSpec::RubyContentMatcher
Constructor Details
#initialize(module_name) ⇒ HaveModule
Returns a new instance of HaveModule.
5 6 7 |
# File 'lib/generator_spec/matchers/content/have_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/generator_spec/matchers/content/have_module.rb', line 3 def module_name @module_name end |
Instance Method Details
#failure_message ⇒ Object
20 21 22 23 |
# File 'lib/generator_spec/matchers/content/have_module.rb', line 20 def super "Expected there to be the module #{module_name}" end |
#matches?(content) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/generator_spec/matchers/content/have_module.rb', line 9 def matches?(content) super match_res =~ /module\s+#{module_name}\s+(.*)end/m if block_given? && match_res ruby_content = $2.strip.extend(RSpec::RubyContent::Helpers) yield ruby_content else match_res end end |
#negative_failure_message ⇒ Object
25 26 27 28 |
# File 'lib/generator_spec/matchers/content/have_module.rb', line 25 def super "Did no expected there to be the module #{module_name}" end |