Class: RSpec::RubyContentMatchers::IncludeModule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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



22
23
24
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 22

def failure_message
  "Expected there to be an inclusion of module #{module_name}"
end

#matches?(content) ⇒ Boolean

Returns:

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



26
27
28
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 26

def negative_failure_message
  "Did not expect there to be an inclusion of module #{module_name}"
end