Sha256: 64952236e1196e618a2e71acbff033bcfd5593dfe9619e0496cd61eb99ef8587

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

module RSpec::RubyContentMatchers
  class HaveCalls < HaveCall
    attr_reader :calls, :method, :args

    def initialize(*calls)
      case calls.first
      when Array, Hash
        @calls = calls.first
      else    
        @calls = calls
      end
    end

    def matches?(content)
      super
      case calls
      when Array
        do_list
      when Hash
        do_hash
      end
    end                              
    
    protected

    def do_list
      calls.each do |method|
        @method = method.to_s   
        expr = /#{not_def}#{method}/m
        return false if (content =~ expr) == nil
      end
      true
    end    

    def do_hash
      calls.each_pair do |method, args|
        @method = method.to_s
        @args = args
        return false if (content =~ /#{not_def}#{method}\s+#{args_expr}/m) == nil
      end
      true
    end    
  end
  
  def have_calls(*calls)
    HaveCalls.new(*calls)
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generator-spec-0.4.7 lib/generator_spec/matchers/content/have_calls.rb