Sha256: 4e0154fd0a65b732c9f50c3d09f0597e332f1b6aa8ae89ac872a3443cf26c6c2

Contents?: true

Size: 850 Bytes

Versions: 7

Compression:

Stored size: 850 Bytes

Contents

module RSpec
  module Matchers
    class Cover
      include BaseMatcher

      def initialize(*expected)
        super(expected)
      end

      def matches?(range)
        expected.all? {|e| super(range).cover?(e)}
      end

      def does_not_match?(range)
        @actual = range
        expected.none? {|e| range.cover?(e)}
      end
    end

    # Passes if actual covers expected. This works for
    # Ranges. You can also pass in multiple args
    # and it will only pass if all args are found in Range.
    #
    # @example
    #   (1..10).should cover(5)
    #   (1..10).should cover(4, 6)
    #   (1..10).should cover(4, 6, 11) # will fail
    #   (1..10).should_not cover(11)
    #   (1..10).should_not cover(5)    # will fail
    #
    # ### Warning:: Ruby >= 1.9 only
    def cover(*values)
      Cover.new(*values)
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.8.0/lib/rspec/matchers/cover.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.8.0/lib/rspec/matchers/cover.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-expectations-2.8.0/lib/rspec/matchers/cover.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-expectations-2.8.0/lib/rspec/matchers/cover.rb
rspec-expectations-2.8.0 lib/rspec/matchers/cover.rb
rspec-expectations-2.8.0.rc2 lib/rspec/matchers/cover.rb
rspec-expectations-2.8.0.rc1 lib/rspec/matchers/cover.rb