Sha256: 46c633842b6448386f8cf7e0c1605c12d2baf4ac90ce26107d9f9f5a75ef1f6f

Contents?: true

Size: 1.61 KB

Versions: 11

Compression:

Stored size: 1.61 KB

Contents

require File.expand_path('../../../test_helper', __FILE__)

require 'mocha/parameter_matchers/includes'
require 'mocha/inspect'

class IncludesTest < Mocha::TestCase

  include Mocha::ParameterMatchers

  def test_should_match_object_including_value
    matcher = includes(:x)
    assert matcher.matches?([[:x, :y, :z]])
  end

  def test_should_match_object_including_all_values
    matcher = includes(:x, :y, :z)
    assert matcher.matches?([[:x, :y, :z]])
  end

  def test_should_not_match_object_that_does_not_include_value
    matcher = includes(:not_included)
    assert !matcher.matches?([[:x, :y, :z]])
  end

  def test_should_not_match_object_that_does_not_include_any_one_value
    matcher = includes(:x, :y, :z, :not_included)
    assert !matcher.matches?([[:x, :y, :z]])
  end

  def test_should_describe_matcher_with_one_item
    matcher = includes(:x)
    assert_equal "includes(:x)", matcher.mocha_inspect
  end

  def test_should_describe_matcher_with_multiple_items
    matcher = includes(:x, :y, :z)
    assert_equal "includes(:x, :y, :z)", matcher.mocha_inspect
  end

  def test_should_not_raise_error_on_emtpy_arguments
    matcher = includes(:x)
    assert_nothing_raised { matcher.matches?([]) }
  end

  def test_should_not_match_on_empty_arguments
    matcher = includes(:x)
    assert !matcher.matches?([])
  end

  def test_should_not_raise_error_on_argument_that_does_not_respond_to_include
    matcher = includes(:x)
    assert_nothing_raised { matcher.matches?([:x]) }
  end

  def test_should_not_match_on_argument_that_does_not_respond_to_include
    matcher = includes(:x)
    assert !matcher.matches?([:x])
  end
end

Version data entries

11 entries across 8 versions & 4 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/unit/parameter_matchers/includes_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/unit/parameter_matchers/includes_test.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/unit/parameter_matchers/includes_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/unit/parameter_matchers/includes_test.rb
mocha-1.1.0 test/unit/parameter_matchers/includes_test.rb
mocha-1.0.0 test/unit/parameter_matchers/includes_test.rb
mocha-1.0.0.alpha test/unit/parameter_matchers/includes_test.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/unit/parameter_matchers/includes_test.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/test/unit/parameter_matchers/includes_test.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/unit/parameter_matchers/includes_test.rb
mocha-0.14.0 test/unit/parameter_matchers/includes_test.rb