Class: RSpec::RubyContentMatchers::HaveModule

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_for_generators/matchers/content/have_module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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_messageObject



20
21
22
# File 'lib/rspec_for_generators/matchers/content/have_module.rb', line 20

def failure_message
  "Expected there to be the module #{module_name}"
end

#matches?(module_name) ⇒ Boolean

Returns:

  • (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_messageObject



24
25
26
# File 'lib/rspec_for_generators/matchers/content/have_module.rb', line 24

def negative_failure_message
  "Did no expected there to be the module #{module_name}"
end