Sha256: ef2d125813b159c07e2b358977c34a89e1e1a2c07315d73fe8b47eef211e9911

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 Bytes

Contents

module RSpec
  module RubyContentMatchers
    class HaveModule

      attr_reader :module_name

      def initialize(content)
        @content = content      
      end

      def matches?(module_name)      
        @module_name = module_name.to_s.camelize
        @content =~ /module\s+#{@module_name}\s+(.*)end/m
        if block_given?
          ruby_content = $2.strip.extend(RSpec::RubyContent::Helpers)
          yield ruby_content
        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  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec_for_generators-0.3.1 lib/rspec_for_generators/matchers/content/have_module.rb
rspec_for_generators-0.3.0 lib/rspec_for_generators/matchers/content/have_module.rb