Class: RSpec::RubyContentMatchers::HaveModule
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::HaveModule
- Defined in:
- lib/rspec_for_generators/matchers/content/have_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(content) ⇒ HaveModule
constructor
A new instance of HaveModule.
- #matches?(module_name) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(content) ⇒ HaveModule
Returns a new instance of HaveModule.
7 8 9 |
# File 'lib/rspec_for_generators/matchers/content/have_module.rb', line 7 def initialize(content) @content = content 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/have_module.rb', line 5 def module_name @module_name end |
Instance Method Details
#failure_message ⇒ Object
20 21 22 |
# File 'lib/rspec_for_generators/matchers/content/have_module.rb', line 20 def "Expected there to be the module #{module_name}" end |
#matches?(module_name) ⇒ Boolean
11 12 13 14 15 16 17 18 |
# File 'lib/rspec_for_generators/matchers/content/have_module.rb', line 11 def matches?(module_name) @module_name = module_name.to_s.camelize @content =~ /module\s+#{@module_name}\s+(.*)end/m if block_given? ruby_content = $2.strip.extend(RSpec::RubyContent::Helpers) yield ruby_content end end |
#negative_failure_message ⇒ Object
24 25 26 |
# File 'lib/rspec_for_generators/matchers/content/have_module.rb', line 24 def "Did no expected there to be the module #{module_name}" end |