Sha256: f1e030199d0e6b5177bba1b850993ec2f196fcf764d4486cbe3381a10c8c3c1e

Contents?: true

Size: 810 Bytes

Versions: 12

Compression:

Stored size: 810 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
      "Expected there to be an inclusion of module #{module_name}"
    end 
    
    def negative_failure_message
      super
      "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

12 entries across 12 versions & 1 rubygems

Version Path
code-spec-0.2.8 lib/code_spec/matchers/include_module.rb
code-spec-0.2.7 lib/code_spec/matchers/include_module.rb
code-spec-0.2.6 lib/code_spec/matchers/include_module.rb
code-spec-0.2.5 lib/code_spec/matchers/include_module.rb
code-spec-0.2.4 lib/code_spec/matchers/include_module.rb
code-spec-0.2.3 lib/code_spec/matchers/include_module.rb
code-spec-0.2.2 lib/code_spec/matchers/include_module.rb
code-spec-0.2.1 lib/code_spec/matchers/include_module.rb
code-spec-0.2.0 lib/code_spec/matchers/include_module.rb
code-spec-0.1.3 lib/code_spec/matchers/include_module.rb
code-spec-0.1.2 lib/code_spec/matchers/include_module.rb
code-spec-0.1.0 lib/code_spec/matchers/include_module.rb