Sha256: c774221ae688b69dafc0f3b0ecf8054813631a0b4eb23cdf80f75d940a55f29c

Contents?: true

Size: 826 Bytes

Versions: 4

Compression:

Stored size: 826 Bytes

Contents

module RSpec::RubyContentMatchers
  class IncludeModule < RSpec::RubyContentMatcher
    attr_reader :module_name, :type

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

    def matches?(content)      
      @content = content
      (content =~ /#{type}\s+#{module_name}/)
    end          
  
    def failure_message
      super
      display "Expected there to be an inclusion of module #{module_name}"
    end 
    
    def negative_failure_message
      super
      display "Did not expect there to be an inclusion of module #{module_name}"
    end
               
  end
  
  def include_module(module_name)
    IncludeModule.new(module_name)
  end    

  def extend_module(module_name)
    IncludeModule.new(module_name, :extend)
  end
end  

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
code-spec-0.4.0 lib/code_spec/matchers/include_module.rb
code-spec-0.3.0 lib/code_spec/matchers/include_module.rb
code-spec-0.2.11 lib/code_spec/matchers/include_module.rb
code-spec-0.2.9 lib/code_spec/matchers/include_module.rb