module RSpec::RubyContentMatchers class IncludeModule attr_reader :module_name, :content def initialize module_name @module_name = module_name.to_s.camelize end 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 def failure_message puts "Content: #{content}" if RSpec::Generator.debug? "Expected there to be an inclusion of module #{module_name}" end def negative_failure_message puts "Content: #{content}" if RSpec::Generator.debug? "Did not expect there to be an inclusion of module #{module_name}" end end def include_module(module_name) IncludeModule.new(module_name) end end