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.



5
6
7
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 5

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.



3
4
5
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 3

def module_name
  @module_name
end

Instance Method Details

#failure_messageObject



19
20
21
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 19

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

#matches?(content) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# File 'lib/rspec_for_generators/matchers/content/include_module.rb', line 9

def matches?(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



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

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