rr 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/CHANGES.md +392 -0
- data/Gemfile +7 -10
- data/README.md +822 -0
- data/Rakefile +24 -78
- data/VERSION +1 -0
- data/lib/rr/adapters/minitest.rb +6 -0
- data/lib/rr/adapters/rr_methods.rb +6 -10
- data/lib/rr/adapters/rspec.rb +3 -0
- data/lib/rr/adapters/rspec2.rb +30 -0
- data/lib/rr/adapters/test_unit.rb +2 -0
- data/lib/rr/double.rb +3 -2
- data/lib/rr/double_definitions/child_double_definition_create.rb +3 -2
- data/lib/rr/double_definitions/double_definition.rb +15 -13
- data/lib/rr/double_definitions/double_definition_create.rb +9 -5
- data/lib/rr/double_definitions/double_injections/any_instance_of.rb +3 -2
- data/lib/rr/double_definitions/strategies/strategy.rb +5 -4
- data/lib/rr/double_definitions/strategies/strategy_methods.rb +6 -8
- data/lib/rr/double_definitions/strategies/verification/mock.rb +3 -3
- data/lib/rr/double_matches.rb +2 -1
- data/lib/rr/expectations/argument_equality_expectation.rb +2 -2
- data/lib/rr/expectations/times_called_expectation.rb +2 -2
- data/lib/rr/injections/double_injection.rb +12 -11
- data/lib/rr/injections/injection.rb +2 -2
- data/lib/rr/injections/method_missing_injection.rb +21 -7
- data/lib/rr/injections/singleton_method_added_injection.rb +3 -1
- data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
- data/lib/rr/method_dispatches/method_dispatch.rb +2 -1
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +2 -1
- data/lib/rr/proc_from_block.rb +8 -4
- data/lib/rr/space.rb +3 -2
- data/lib/rr/times_called_matchers/times_called_matcher.rb +2 -2
- data/lib/rr/version.rb +5 -0
- data/lib/rr/wildcard_matchers/boolean.rb +2 -2
- data/lib/rr.rb +3 -0
- data/spec/runner.rb +41 -0
- metadata +45 -133
- data/.gitignore +0 -10
- data/.runrc +0 -3
- data/.rvmrc +0 -2
- data/CHANGES +0 -266
- data/Gemfile.lock +0 -31
- data/README.rdoc +0 -392
- data/benchmarks/rr_benchmark.rb +0 -32
- data/benchmarks/rspec_benchmark.rb +0 -14
- data/doc/0.6.0.release.markdown +0 -81
- data/doc/todo.txt +0 -0
- data/introducting_rr.txt +0 -206
- data/rr.gemspec +0 -37
- data/spec/api/any_instance_of/all_instances_of_spec.rb +0 -12
- data/spec/api/any_instance_of/any_instance_of_spec.rb +0 -47
- data/spec/api/any_instance_of/instance_of_spec.rb +0 -12
- data/spec/api/dont_allow/dont_allow_after_stub_spec.rb +0 -14
- data/spec/api/mock/mock_spec.rb +0 -193
- data/spec/api/proxy/proxy_spec.rb +0 -86
- data/spec/api/spy/spy_spec.rb +0 -49
- data/spec/api/strong/strong_spec.rb +0 -87
- data/spec/api/stub/stub_spec.rb +0 -152
- data/spec/core_spec_suite.rb +0 -19
- data/spec/environment_fixture_setup.rb +0 -8
- data/spec/minitest_spec_suite.rb +0 -21
- data/spec/proc_from_block_spec.rb +0 -14
- data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +0 -67
- data/spec/rr/adapters/rr_methods_creator_spec.rb +0 -137
- data/spec/rr/adapters/rr_methods_space_spec.rb +0 -98
- data/spec/rr/adapters/rr_methods_spec_helper.rb +0 -11
- data/spec/rr/adapters/rr_methods_times_matcher_spec.rb +0 -13
- data/spec/rr/double_definitions/child_double_definition_creator_spec.rb +0 -112
- data/spec/rr/double_definitions/double_definition_create_blank_slate_spec.rb +0 -91
- data/spec/rr/double_definitions/double_definition_create_spec.rb +0 -443
- data/spec/rr/double_injection/double_injection_spec.rb +0 -546
- data/spec/rr/double_injection/double_injection_verify_spec.rb +0 -29
- data/spec/rr/errors/rr_error_spec.rb +0 -67
- data/spec/rr/expectations/any_argument_expectation_spec.rb +0 -47
- data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +0 -14
- data/spec/rr/expectations/argument_equality_expectation_spec.rb +0 -135
- data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +0 -34
- data/spec/rr/expectations/hash_including_argument_equality_expectation_spec.rb +0 -82
- data/spec/rr/expectations/hash_including_spec.rb +0 -17
- data/spec/rr/expectations/satisfy_argument_equality_expectation_spec.rb +0 -59
- data/spec/rr/expectations/satisfy_spec.rb +0 -14
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +0 -22
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +0 -37
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +0 -43
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +0 -15
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +0 -58
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +0 -35
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +0 -39
- data/spec/rr/minitest/minitest_integration_test.rb +0 -59
- data/spec/rr/minitest/test_helper.rb +0 -7
- data/spec/rr/rspec/invocation_matcher_spec.rb +0 -279
- data/spec/rr/rspec/rspec_adapter_spec.rb +0 -63
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +0 -31
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec_fixture.rb +0 -11
- data/spec/rr/rspec/rspec_usage_spec.rb +0 -86
- data/spec/rr/space/hash_with_object_id_key_spec.rb +0 -88
- data/spec/rr/space/space_spec.rb +0 -596
- data/spec/rr/test_unit/test_helper.rb +0 -7
- data/spec/rr/test_unit/test_unit_backtrace_test.rb +0 -36
- data/spec/rr/test_unit/test_unit_integration_test.rb +0 -59
- data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +0 -47
- data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/integer_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/proc_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/range_matcher_spec.rb +0 -76
- data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +0 -118
- data/spec/rr/wildcard_matchers/anything_spec.rb +0 -24
- data/spec/rr/wildcard_matchers/boolean_spec.rb +0 -36
- data/spec/rr/wildcard_matchers/duck_type_spec.rb +0 -52
- data/spec/rr/wildcard_matchers/is_a_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/numeric_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/range_spec.rb +0 -35
- data/spec/rr/wildcard_matchers/regexp_spec.rb +0 -43
- data/spec/rr_spec.rb +0 -28
- data/spec/rspec_spec_suite.rb +0 -17
- data/spec/spec.opts +0 -10
- data/spec/spec_helper.rb +0 -41
- data/spec/spec_suite.rb +0 -54
- data/spec/spy_verification_spec.rb +0 -129
- data/spec/test_unit_spec_suite.rb +0 -21
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module TimesCalledMatchers
|
|
5
|
-
describe AnyTimesMatcher do
|
|
6
|
-
attr_reader :matcher
|
|
7
|
-
before do
|
|
8
|
-
@matcher = AnyTimesMatcher.new
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe AnyTimesMatcher, "#possible_match?" do
|
|
12
|
-
it "always returns true" do
|
|
13
|
-
matcher.should be_possible_match(0)
|
|
14
|
-
matcher.should be_possible_match(99999)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe AnyTimesMatcher, "#matches?" do
|
|
19
|
-
it "always returns true" do
|
|
20
|
-
matcher.should be_matches(0)
|
|
21
|
-
matcher.should be_matches(99999)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe AnyTimesMatcher, "#attempt?" do
|
|
26
|
-
it "always returns true" do
|
|
27
|
-
matcher.should be_attempt(0)
|
|
28
|
-
matcher.should be_attempt(99999)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe AnyTimesMatcher, "#terminal?" do
|
|
33
|
-
it "returns false" do
|
|
34
|
-
matcher.should_not be_terminal
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe AnyTimesMatcher, "#error_message" do
|
|
39
|
-
it "has an error message" do
|
|
40
|
-
matcher.error_message(2).should == (
|
|
41
|
-
"Called 2 times.\nExpected any number of times."
|
|
42
|
-
)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module TimesCalledMatchers
|
|
5
|
-
describe AtLeastMatcher do
|
|
6
|
-
attr_reader :matcher, :times
|
|
7
|
-
before do
|
|
8
|
-
@times = 3
|
|
9
|
-
@matcher = AtLeastMatcher.new(times)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#possible_match?" do
|
|
13
|
-
it "always returns true" do
|
|
14
|
-
matcher.should be_possible_match(99999)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe "#matches?" do
|
|
19
|
-
it "returns false when times_called less than times" do
|
|
20
|
-
matcher.should_not be_matches(2)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "returns true when times_called == times" do
|
|
24
|
-
matcher.should be_matches(3)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "returns true when times_called > times" do
|
|
28
|
-
matcher.should be_matches(4)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe "#attempt?" do
|
|
33
|
-
it "always returns true" do
|
|
34
|
-
matcher.should be_attempt(1)
|
|
35
|
-
matcher.should be_attempt(100000)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
describe AnyTimesMatcher, "#terminal?" do
|
|
40
|
-
it "returns false" do
|
|
41
|
-
matcher.should_not be_terminal
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe "#error_message" do
|
|
46
|
-
it "has an error message" do
|
|
47
|
-
matcher.error_message(2).should == (
|
|
48
|
-
"Called 2 times.\nExpected at least 3 times."
|
|
49
|
-
)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module TimesCalledMatchers
|
|
5
|
-
describe AtMostMatcher do
|
|
6
|
-
attr_reader :matcher, :times
|
|
7
|
-
before do
|
|
8
|
-
@times = 3
|
|
9
|
-
@matcher = AtMostMatcher.new(times)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe AtMostMatcher, "#possible_match?" do
|
|
13
|
-
it "returns true when times called < times" do
|
|
14
|
-
matcher.should be_possible_match(2)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "returns true when times called == times" do
|
|
18
|
-
matcher.should be_possible_match(3)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "returns false when times called > times" do
|
|
22
|
-
matcher.should_not be_possible_match(4)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe AtMostMatcher, "#matches?" do
|
|
27
|
-
it "returns true when times_called less than times" do
|
|
28
|
-
matcher.should be_matches(2)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "returns true when times_called == times" do
|
|
32
|
-
matcher.should be_matches(3)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "returns false when times_called > times" do
|
|
36
|
-
matcher.should_not be_matches(4)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe AtMostMatcher, "#attempt?" do
|
|
41
|
-
it "returns true when less than expected times" do
|
|
42
|
-
matcher.should be_attempt(2)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "returns false when == expected times" do
|
|
46
|
-
matcher.should_not be_attempt(3)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "returns false when > expected times" do
|
|
50
|
-
matcher.should_not be_attempt(4)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe AnyTimesMatcher, "#terminal?" do
|
|
55
|
-
it "returns true" do
|
|
56
|
-
matcher.should be_terminal
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe AtMostMatcher, "#error_message" do
|
|
61
|
-
it "has an error message" do
|
|
62
|
-
matcher.error_message(5).should == (
|
|
63
|
-
"Called 5 times.\nExpected at most 3 times."
|
|
64
|
-
)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module TimesCalledMatchers
|
|
5
|
-
describe IntegerMatcher do
|
|
6
|
-
attr_reader :matcher, :times
|
|
7
|
-
before do
|
|
8
|
-
@times = 3
|
|
9
|
-
@matcher = IntegerMatcher.new(times)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#possible_match?" do
|
|
13
|
-
it "returns true when times called < times" do
|
|
14
|
-
matcher.should be_possible_match(2)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "returns true when times called == times" do
|
|
18
|
-
matcher.should be_possible_match(3)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "returns false when times called > times" do
|
|
22
|
-
matcher.should_not be_possible_match(4)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe "#matches?" do
|
|
27
|
-
it "returns false when times_called less than times" do
|
|
28
|
-
matcher.should_not be_matches(2)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "returns true when times_called == times" do
|
|
32
|
-
matcher.should be_matches(3)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "returns false when times_called > times" do
|
|
36
|
-
matcher.should_not be_matches(4)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe "#attempt?" do
|
|
41
|
-
it "returns true when less than expected times" do
|
|
42
|
-
matcher.should be_attempt(2)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "returns false when == expected times" do
|
|
46
|
-
matcher.should_not be_attempt(3)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "returns false when > expected times" do
|
|
50
|
-
matcher.should_not be_attempt(4)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe AnyTimesMatcher, "#terminal?" do
|
|
55
|
-
it "returns true" do
|
|
56
|
-
matcher.should be_terminal
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe "#error_message" do
|
|
61
|
-
it "has an error message" do
|
|
62
|
-
matcher.error_message(2).should == (
|
|
63
|
-
"Called 2 times.\nExpected 3 times."
|
|
64
|
-
)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module TimesCalledMatchers
|
|
5
|
-
describe ProcMatcher do
|
|
6
|
-
attr_reader :matcher, :times
|
|
7
|
-
before do
|
|
8
|
-
@times = lambda {|other| other == 3}
|
|
9
|
-
@matcher = ProcMatcher.new(times)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#possible_match?" do
|
|
13
|
-
it "always returns true" do
|
|
14
|
-
matcher.should be_possible_match(2)
|
|
15
|
-
matcher.should be_possible_match(3)
|
|
16
|
-
matcher.should be_possible_match(10)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe "#matches?" do
|
|
21
|
-
it "returns false when lambda returns false" do
|
|
22
|
-
times.call(2).should be_false
|
|
23
|
-
matcher.should_not be_matches(2)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "returns true when lambda returns true" do
|
|
27
|
-
times.call(3).should be_true
|
|
28
|
-
matcher.should be_matches(3)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe "#attempt?" do
|
|
33
|
-
it "always returns true" do
|
|
34
|
-
matcher.should be_attempt(2)
|
|
35
|
-
matcher.should be_attempt(3)
|
|
36
|
-
matcher.should be_attempt(10)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe "#terminal?" do
|
|
41
|
-
it "returns false" do
|
|
42
|
-
matcher.should_not be_terminal
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe "#error_message" do
|
|
47
|
-
it "has an error message" do
|
|
48
|
-
matcher.error_message(1).should =~
|
|
49
|
-
/Called 1 time.\nExpected #<Proc.*> times./
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module TimesCalledMatchers
|
|
5
|
-
describe RangeMatcher do
|
|
6
|
-
attr_reader :matcher, :times
|
|
7
|
-
before do
|
|
8
|
-
@times = 2..4
|
|
9
|
-
@matcher = RangeMatcher.new(times)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#possible_match?" do
|
|
13
|
-
it "returns true when times called < start of range" do
|
|
14
|
-
matcher.should be_possible_match(1)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "returns true when times called in range" do
|
|
18
|
-
matcher.should be_possible_match(2)
|
|
19
|
-
matcher.should be_possible_match(3)
|
|
20
|
-
matcher.should be_possible_match(4)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "returns false when times called > end of range" do
|
|
24
|
-
matcher.should_not be_possible_match(5)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "#matches?" do
|
|
29
|
-
it "returns false when times_called less than start of range" do
|
|
30
|
-
matcher.should_not be_matches(1)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "returns true when times_called in range" do
|
|
34
|
-
matcher.should be_matches(2)
|
|
35
|
-
matcher.should be_matches(3)
|
|
36
|
-
matcher.should be_matches(4)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "returns false when times_called > end of range" do
|
|
40
|
-
matcher.should_not be_matches(5)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
describe "#attempt?" do
|
|
45
|
-
it "returns true when less than start of range" do
|
|
46
|
-
matcher.should be_attempt(1)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "returns true when in range" do
|
|
50
|
-
matcher.should be_attempt(2)
|
|
51
|
-
matcher.should be_attempt(3)
|
|
52
|
-
matcher.should be_attempt(4)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "returns false when > end of range" do
|
|
56
|
-
matcher.should_not be_attempt(5)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe "#terminal?" do
|
|
61
|
-
it "returns true" do
|
|
62
|
-
matcher.should be_terminal
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe "#error_message" do
|
|
67
|
-
it "has an error message" do
|
|
68
|
-
matcher.error_message(1).should == (
|
|
69
|
-
"Called 1 time.\nExpected 2..4 times."
|
|
70
|
-
)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module TimesCalledMatchers
|
|
5
|
-
describe TimesCalledMatcher do
|
|
6
|
-
describe ".create" do
|
|
7
|
-
describe "when passed a AnyTimesMatcher" do
|
|
8
|
-
it "returns the passed in argument" do
|
|
9
|
-
matcher = AnyTimesMatcher.new
|
|
10
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "when passed a AtLeastMatcher" do
|
|
15
|
-
it "returns the passed in argument" do
|
|
16
|
-
matcher = AtLeastMatcher.new(5)
|
|
17
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe "when passed a AtMostMatcher" do
|
|
22
|
-
it "returns the passed in argument" do
|
|
23
|
-
matcher = AtMostMatcher.new(5)
|
|
24
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "when passed a IntegerMatcher" do
|
|
29
|
-
it "returns the passed in argument" do
|
|
30
|
-
matcher = IntegerMatcher.new(5)
|
|
31
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe "when passed a Integer" do
|
|
36
|
-
it "returns IntegerMatcher" do
|
|
37
|
-
TimesCalledMatcher.create(5).should == IntegerMatcher.new(5)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe "when passed a ProcMatcher" do
|
|
42
|
-
it "returns the passed in argument" do
|
|
43
|
-
matcher = ProcMatcher.new(lambda {|other| other == 5})
|
|
44
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe "when passed a Lambda" do
|
|
49
|
-
it "returns ProcMatcher" do
|
|
50
|
-
value = lambda {|other| other == 5}
|
|
51
|
-
TimesCalledMatcher.create(value).should == ProcMatcher.new(value)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe "when passed a IntegerMatcher" do
|
|
56
|
-
it "returns the passed in argument" do
|
|
57
|
-
matcher = RangeMatcher.new(2..4)
|
|
58
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe "when passed a Integer" do
|
|
63
|
-
it "returns RangeMatcher" do
|
|
64
|
-
TimesCalledMatcher.create(2..4).should == RangeMatcher.new(2..4)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
describe "when passed a TimesCalledMatcher" do
|
|
69
|
-
it "returns the passed in argument" do
|
|
70
|
-
matcher = TimesCalledMatcher.new(5)
|
|
71
|
-
TimesCalledMatcher.create(matcher).should === matcher
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe "when passed an unsupported type" do
|
|
76
|
-
it "raises an ArgumentError" do
|
|
77
|
-
matcher = Object.new
|
|
78
|
-
lambda do
|
|
79
|
-
TimesCalledMatcher.create(matcher)
|
|
80
|
-
end.should raise_error(ArgumentError, "There is no TimesCalledMatcher for #{matcher.inspect}.")
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
describe "#error_message" do
|
|
86
|
-
before do
|
|
87
|
-
@times = 3
|
|
88
|
-
@matcher = TimesCalledMatcher.new(@times)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "has an error message" do
|
|
92
|
-
@matcher.error_message(5).should == (
|
|
93
|
-
"Called 5 times.\nExpected 3 times."
|
|
94
|
-
)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe "#==" do
|
|
99
|
-
before do
|
|
100
|
-
@times = 3
|
|
101
|
-
@matcher = TimesCalledMatcher.new(@times)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "returns true when other is the same class and times are ==" do
|
|
105
|
-
@matcher.should == TimesCalledMatcher.new(@times)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it "returns false when other is a different class and times are ==" do
|
|
109
|
-
@matcher.should_not == IntegerMatcher.new(@times)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it "returns false when is the same class and times are not ==" do
|
|
113
|
-
@matcher.should_not == TimesCalledMatcher.new(1)
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module WildcardMatchers
|
|
5
|
-
describe Anything do
|
|
6
|
-
attr_reader :matcher
|
|
7
|
-
before do
|
|
8
|
-
@matcher = Anything.new
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#wildcard_match?" do
|
|
12
|
-
it "returns true" do
|
|
13
|
-
matcher.should be_wildcard_match(Object.new)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe "#inspect" do
|
|
18
|
-
it "returns anything" do
|
|
19
|
-
matcher.inspect.should == "anything"
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module WildcardMatchers
|
|
5
|
-
describe Boolean do
|
|
6
|
-
attr_reader :matcher
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
@matcher = Boolean.new
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#wildcard_match?" do
|
|
13
|
-
context "when passed a Boolean" do
|
|
14
|
-
it "returns true" do
|
|
15
|
-
matcher.should be_wildcard_match(true)
|
|
16
|
-
matcher.should be_wildcard_match(false)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context "when not passed a Boolean" do
|
|
21
|
-
it "returns false" do
|
|
22
|
-
matcher.should_not be_wildcard_match(:not_a_boolean)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe Boolean do
|
|
28
|
-
describe "#inspect" do
|
|
29
|
-
it "returns boolean" do
|
|
30
|
-
matcher.inspect.should == "boolean"
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module WildcardMatchers
|
|
5
|
-
describe DuckType do
|
|
6
|
-
attr_reader :matcher
|
|
7
|
-
before do
|
|
8
|
-
@matcher = DuckType.new(:quack, :waddle)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#wildcard_match?" do
|
|
12
|
-
before do
|
|
13
|
-
@matching_object = Object.new
|
|
14
|
-
def @matching_object.quack
|
|
15
|
-
end
|
|
16
|
-
def @matching_object.waddle
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
@partial_matching_object = Object.new
|
|
20
|
-
def @partial_matching_object.quack
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
@not_match_object = Object.new
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context "when passed-in object matches all required methods" do
|
|
27
|
-
it "returns true" do
|
|
28
|
-
matcher.should be_wildcard_match(@matching_object)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context "when passed-in object matches some required methods" do
|
|
33
|
-
it "returns false" do
|
|
34
|
-
matcher.should_not be_wildcard_match(@partial_matching_object)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context "when passed-in object matches no required methods" do
|
|
39
|
-
it "returns false" do
|
|
40
|
-
matcher.should_not be_wildcard_match(@not_match_object)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe "#inspect" do
|
|
46
|
-
it "returns duck_type with methods" do
|
|
47
|
-
matcher.inspect.should == "duck_type(:quack, :waddle)"
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module WildcardMatchers
|
|
5
|
-
describe IsA do
|
|
6
|
-
attr_reader :matcher
|
|
7
|
-
before do
|
|
8
|
-
@matcher = IsA.new(Symbol)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#wildcard_match?" do
|
|
12
|
-
context "when passed an instance of the expected Module" do
|
|
13
|
-
it "returns true" do
|
|
14
|
-
matcher.should be_wildcard_match(:a_symbol)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when not passed an instance of the expected Module" do
|
|
19
|
-
it "returns false" do
|
|
20
|
-
matcher.should_not be_wildcard_match("not a symbol")
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe "#inspect" do
|
|
26
|
-
it "returns the is_a(ClassName)" do
|
|
27
|
-
matcher.inspect.should == "is_a(Symbol)"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
2
|
-
|
|
3
|
-
module RR
|
|
4
|
-
module WildcardMatchers
|
|
5
|
-
describe Numeric do
|
|
6
|
-
attr_reader :matcher
|
|
7
|
-
before do
|
|
8
|
-
@matcher = Numeric.new
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#wildcard_match?" do
|
|
12
|
-
context "when passed a Numeric" do
|
|
13
|
-
it "returns true" do
|
|
14
|
-
matcher.should be_wildcard_match(99)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when not passed a Numeric" do
|
|
19
|
-
it "returns false" do
|
|
20
|
-
matcher.should_not be_wildcard_match(:not_a_numeric)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe "#inspect" do
|
|
26
|
-
it "returns numeric" do
|
|
27
|
-
matcher.inspect.should == "numeric"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|