Sha256: eb1da360b10328a8b959192d8922a92ad1ba9e69f4f36320d9c335c9b7b833ea

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

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

require 'mocha/parameter_matchers/responds_with'
require 'mocha/parameter_matchers/instance_methods'
require 'mocha/inspect'

class RespondsWithTest < Mocha::TestCase
  include Mocha::ParameterMatchers

  def test_should_match_parameter_responding_with_expected_value
    matcher = responds_with(:upcase, 'FOO')
    assert matcher.matches?(['foo'])
  end

  def test_should_not_match_parameter_responding_with_unexpected_value
    matcher = responds_with(:upcase, 'FOO')
    assert !matcher.matches?(['bar'])
  end

  def test_should_match_parameter_responding_with_nested_responds_with_matcher
    matcher = responds_with(:foo, responds_with(:bar, 'baz'))
    object = Class.new do
      def foo
        Class.new do
          def bar
            'baz'
          end
        end.new
      end
    end.new
    assert matcher.matches?([object])
  end

  def test_should_describe_matcher
    matcher = responds_with(:foo, :bar)
    assert_equal 'responds_with(:foo, :bar)', matcher.mocha_inspect
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mocha-1.11.2 test/unit/parameter_matchers/responds_with_test.rb
mocha-1.11.1 test/unit/parameter_matchers/responds_with_test.rb
mocha-1.11.0 test/unit/parameter_matchers/responds_with_test.rb
mocha-1.10.2 test/unit/parameter_matchers/responds_with_test.rb
mocha-1.10.1 test/unit/parameter_matchers/responds_with_test.rb
mocha-1.10.0 test/unit/parameter_matchers/responds_with_test.rb
mocha-1.10.0.beta.1 test/unit/parameter_matchers/responds_with_test.rb
mocha-1.10.0.alpha test/unit/parameter_matchers/responds_with_test.rb