Sha256: 301f9ab18ff0579769884b6a18363f01ba4fc9a414d8d118ec23601840d0ad7d

Contents?: true

Size: 781 Bytes

Versions: 5

Compression:

Stored size: 781 Bytes

Contents

module RSpec::RubyContentMatchers
  class IncludeModule
    attr_reader :module_name

    def initialize module_name
      @module_name = module_name.to_s.camelize
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
generator-spec-0.4.1 lib/rspec_for_generators/matchers/content/include_module.rb
generator-spec-0.4.0 lib/rspec_for_generators/matchers/content/include_module.rb
generator-spec-0.3.5 lib/rspec_for_generators/matchers/content/include_module.rb
generator-spec-0.3.4 lib/rspec_for_generators/matchers/content/include_module.rb
generator-spec-0.3.3 lib/rspec_for_generators/matchers/content/include_module.rb