1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
require File.join(File.dirname(__FILE__), "..", "..", "test_helper")
require 'mocha/parameter_matchers/includes'
require 'mocha/inspect'
class IncludesTest < Test::Unit::TestCase
include Mocha::ParameterMatchers
def test_should_match_object_including_value
matcher = includes(:x)
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_describe_matcher
matcher = includes(:x)
assert_equal "includes(:x)", 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
|