Class: RSpec::RubyContentMatchers::IncludeModule

Inherits:
RSpec::RubyContentMatcher show all
Defined in:
lib/code_spec/matchers/include_module.rb

Constant Summary

Constants inherited from RSpec::RubyContentMatcher

RSpec::RubyContentMatcher::ANY_GROUP, RSpec::RubyContentMatcher::LPAR, RSpec::RubyContentMatcher::OPT_ARGS, RSpec::RubyContentMatcher::OPT_SPACES, RSpec::RubyContentMatcher::Q_ANY_GROUP, RSpec::RubyContentMatcher::RPAR, RSpec::RubyContentMatcher::SPACES

Instance Attribute Summary collapse

Attributes inherited from RSpec::RubyContentMatcher

#alt_end, #content, #content_matches, #end_option

Instance Method Summary collapse

Methods inherited from RSpec::RubyContentMatcher

#any_args_expr, #args_expr, #args_msg, #comment_end, #debug, #debug?, #debug_content, #end_expr, #get_expr, #handle_result, #index, #indexes, #is_match?, #main_expr, #opt

Constructor Details

#initialize(module_name, type = nil) ⇒ IncludeModule

Returns a new instance of IncludeModule.



5
6
7
8
# File 'lib/code_spec/matchers/include_module.rb', line 5

def initialize module_name, type=nil
  @module_name = module_name.to_s.camelize
  @type = type || :include
end

Instance Attribute Details

#module_nameObject (readonly)

Returns the value of attribute module_name.



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

def module_name
  @module_name
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#failure_messageObject



15
16
17
18
# File 'lib/code_spec/matchers/include_module.rb', line 15

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

#matches?(content) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/code_spec/matchers/include_module.rb', line 10

def matches?(content)      
  @content = content
  (content =~ /#{type}\s+#{module_name}/)
end

#negative_failure_messageObject



20
21
22
23
# File 'lib/code_spec/matchers/include_module.rb', line 20

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