Sha256: d468cd9508afee88dba2a8a15182d4c039d3a9d6003fcf3b080e46037e1c06d5

Contents?: true

Size: 755 Bytes

Versions: 5

Compression:

Stored size: 755 Bytes

Contents

module RSpec::RubyContentMatchers
  class HaveModule
    attr_reader :module_name

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

    def matches?(content)            
      match_res =~ /module\s+#{module_name}\s+(.*)end/m
      if block_given? && match_res
        ruby_content = $2.strip.extend(RSpec::RubyContent::Helpers)
        yield ruby_content
      else
        match_res
      end
    end          
  
    def failure_message
      "Expected there to be the module #{module_name}"
    end 
    
    def negative_failure_message
      "Did no expected there to be the module #{module_name}"
    end
               
  end
  
  def have_module(module_name)
    HaveModule.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/have_module.rb
generator-spec-0.4.0 lib/rspec_for_generators/matchers/content/have_module.rb
generator-spec-0.3.5 lib/rspec_for_generators/matchers/content/have_module.rb
generator-spec-0.3.4 lib/rspec_for_generators/matchers/content/have_module.rb
generator-spec-0.3.3 lib/rspec_for_generators/matchers/content/have_module.rb