rr 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -0
- data/Rakefile +1 -1
- data/examples/environment_fixture_setup.rb +1 -1
- data/examples/example_helper.rb +1 -0
- data/examples/high_level_example.rb +1 -2
- data/examples/rr/do_not_allow_creator_example.rb +1 -2
- data/examples/rr/double_bind_example.rb +1 -2
- data/examples/rr/double_dispatching_example.rb +2 -3
- data/examples/rr/double_example.rb +1 -2
- data/examples/rr/double_register_scenario_example.rb +1 -2
- data/examples/rr/double_reset_example.rb +1 -2
- data/examples/rr/double_verify_example.rb +1 -2
- data/examples/rr/errors/rr_error_example.rb +1 -2
- data/examples/rr/expectations/any_argument_expectation_example.rb +1 -2
- data/examples/rr/expectations/anything_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/boolean_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/duck_type_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/is_a_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/numeric_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/range_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/regexp_argument_equality_expectation_example.rb +1 -2
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_least_example.rb +74 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_at_most_example.rb +69 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +18 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb +102 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb +80 -0
- data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb +81 -0
- data/examples/rr/expectations/times_called_expectation_example.rb +1 -185
- data/examples/rr/extensions/double_methods_example.rb +3 -4
- data/examples/rr/mock_creator_example.rb +1 -2
- data/examples/rr/probe_creator_example.rb +1 -2
- data/examples/rr/rspec/rspec_adapter_example.rb +1 -2
- data/examples/rr/rspec/rspec_backtrace_tweaking_example.rb +1 -2
- data/examples/rr/rspec/rspec_usage_example.rb +1 -2
- data/examples/rr/scenario_example.rb +60 -15
- data/examples/rr/space_create_example.rb +1 -2
- data/examples/rr/space_example.rb +1 -2
- data/examples/rr/space_register_example.rb +1 -2
- data/examples/rr/space_reset_example.rb +51 -4
- data/examples/rr/space_verify_example.rb +4 -5
- data/examples/rr/stub_creator_example.rb +1 -2
- data/examples/rr/test_unit/test_helper.rb +1 -1
- data/examples/rr/times_called_matchers/at_least_matcher_example.rb +74 -0
- data/examples/rr/times_called_matchers/at_most_matcher_example.rb +82 -0
- data/examples/rr/times_called_matchers/integer_matcher_example.rb +88 -0
- data/examples/rr/times_called_matchers/proc_matcher_example.rb +74 -0
- data/examples/rr/times_called_matchers/range_matcher_example.rb +94 -0
- data/examples/rr/times_called_matchers/times_called_matcher_example.rb +53 -0
- data/lib/rr.rb +15 -7
- data/lib/rr/adapters/rspec.rb +2 -2
- data/lib/rr/adapters/test_unit.rb +1 -1
- data/lib/rr/double.rb +2 -2
- data/lib/rr/expectations/times_called_expectation.rb +14 -13
- data/lib/rr/extensions/double_methods.rb +5 -5
- data/lib/rr/scenario.rb +35 -7
- data/lib/rr/space.rb +20 -8
- data/lib/rr/times_called_matchers/at_least_matcher.rb +22 -0
- data/lib/rr/times_called_matchers/at_most_matcher.rb +22 -0
- data/lib/rr/times_called_matchers/integer_matcher.rb +17 -0
- data/lib/rr/times_called_matchers/proc_matcher.rb +17 -0
- data/lib/rr/times_called_matchers/range_matcher.rb +19 -0
- data/lib/rr/times_called_matchers/times_called_matcher.rb +44 -0
- data/lib/rr/wildcard_matchers/anything.rb +13 -0
- data/lib/rr/wildcard_matchers/boolean.rb +18 -0
- data/lib/rr/wildcard_matchers/duck_type.rb +24 -0
- data/lib/rr/wildcard_matchers/is_a.rb +20 -0
- data/lib/rr/wildcard_matchers/numeric.rb +9 -0
- data/lib/rr/{expectations/wildcard_matchers → wildcard_matchers}/range.rb +0 -0
- data/lib/rr/{expectations/wildcard_matchers → wildcard_matchers}/regexp.rb +0 -0
- metadata +27 -9
- data/lib/rr/expectations/wildcard_matchers/anything.rb +0 -15
- data/lib/rr/expectations/wildcard_matchers/boolean.rb +0 -20
- data/lib/rr/expectations/wildcard_matchers/duck_type.rb +0 -26
- data/lib/rr/expectations/wildcard_matchers/is_a.rb +0 -22
- data/lib/rr/expectations/wildcard_matchers/numeric.rb +0 -11
@@ -0,0 +1,22 @@
|
|
1
|
+
module RR
|
2
|
+
module TimesCalledMatchers
|
3
|
+
class AtMostMatcher < TimesCalledMatcher
|
4
|
+
def possible_match?(times_called)
|
5
|
+
times_called <= @times
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(times_called)
|
9
|
+
times_called <= @times
|
10
|
+
end
|
11
|
+
|
12
|
+
def attempt?(times_called)
|
13
|
+
times_called < @times
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
def expected_message_part
|
18
|
+
"Expected at most #{@times.inspect} times."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RR
|
2
|
+
module TimesCalledMatchers
|
3
|
+
class IntegerMatcher < TimesCalledMatcher
|
4
|
+
def possible_match?(times_called)
|
5
|
+
times_called <= @times
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(times_called)
|
9
|
+
times_called == @times
|
10
|
+
end
|
11
|
+
|
12
|
+
def attempt?(times_called)
|
13
|
+
times_called < @times
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RR
|
2
|
+
module TimesCalledMatchers
|
3
|
+
class ProcMatcher < TimesCalledMatcher
|
4
|
+
def possible_match?(times_called)
|
5
|
+
return true
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(times_called)
|
9
|
+
@times.call(times_called)
|
10
|
+
end
|
11
|
+
|
12
|
+
def attempt?(times_called)
|
13
|
+
possible_match?(times_called)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RR
|
2
|
+
module TimesCalledMatchers
|
3
|
+
class RangeMatcher < TimesCalledMatcher
|
4
|
+
def possible_match?(times_called)
|
5
|
+
return true if times_called < @times.begin
|
6
|
+
return true if @times.include?(times_called)
|
7
|
+
return false
|
8
|
+
end
|
9
|
+
|
10
|
+
def matches?(times_called)
|
11
|
+
@times.include?(times_called)
|
12
|
+
end
|
13
|
+
|
14
|
+
def attempt?(times_called)
|
15
|
+
possible_match?(times_called)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module RR
|
2
|
+
module TimesCalledMatchers
|
3
|
+
class TimesCalledMatcher
|
4
|
+
class << self
|
5
|
+
def create(value)
|
6
|
+
return value if value.is_a?(TimesCalledMatcher)
|
7
|
+
return IntegerMatcher.new(value) if value.is_a?(Integer)
|
8
|
+
return RangeMatcher.new(value) if value.is_a?(Range )
|
9
|
+
return ProcMatcher.new(value) if value.is_a?(Proc)
|
10
|
+
raise ArgumentError, "There is no TimesCalledMatcher for #{value.inspect}."
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :times
|
15
|
+
|
16
|
+
def initialize(times)
|
17
|
+
@times = times
|
18
|
+
end
|
19
|
+
|
20
|
+
def matches?(times_called)
|
21
|
+
end
|
22
|
+
|
23
|
+
def attempt?(times_called)
|
24
|
+
end
|
25
|
+
|
26
|
+
def error_message(times_called)
|
27
|
+
"Called #{times_called.inspect} #{pluralized_time(times_called)}. #{expected_message_part}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def ==(other)
|
31
|
+
self.class == other.class && self.times == other.times
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
def expected_message_part
|
36
|
+
"Expected #{@times.inspect} times."
|
37
|
+
end
|
38
|
+
|
39
|
+
def pluralized_time(times_called)
|
40
|
+
(times_called == 1) ? "time" : "times"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RR
|
2
|
+
module WildcardMatchers
|
3
|
+
class Boolean
|
4
|
+
def wildcard_match?(other)
|
5
|
+
self == other || is_a_boolean?(other)
|
6
|
+
end
|
7
|
+
|
8
|
+
def ==(other)
|
9
|
+
other.is_a?(self.class)
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
def is_a_boolean?(subject)
|
14
|
+
subject.is_a?(TrueClass) || subject.is_a?(FalseClass)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RR
|
2
|
+
module WildcardMatchers
|
3
|
+
class DuckType
|
4
|
+
attr_accessor :required_methods
|
5
|
+
|
6
|
+
def initialize(*required_methods)
|
7
|
+
@required_methods = required_methods
|
8
|
+
end
|
9
|
+
|
10
|
+
def wildcard_match?(other)
|
11
|
+
return true if self == other
|
12
|
+
required_methods.each do |m|
|
13
|
+
return false unless other.respond_to?(m)
|
14
|
+
end
|
15
|
+
return true
|
16
|
+
end
|
17
|
+
|
18
|
+
def ==(other)
|
19
|
+
return false unless other.is_a?(self.class)
|
20
|
+
self.required_methods == other.required_methods
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RR
|
2
|
+
module WildcardMatchers
|
3
|
+
class IsA
|
4
|
+
attr_reader :klass
|
5
|
+
|
6
|
+
def initialize(klass)
|
7
|
+
@klass = klass
|
8
|
+
end
|
9
|
+
|
10
|
+
def wildcard_match?(other)
|
11
|
+
self == other || other.is_a?(klass)
|
12
|
+
end
|
13
|
+
|
14
|
+
def ==(other)
|
15
|
+
return false unless other.is_a?(self.class)
|
16
|
+
self.klass == other.klass
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.3
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rr
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-07-
|
6
|
+
version: 0.1.7
|
7
|
+
date: 2007-07-14 00:00:00 -07:00
|
8
8
|
summary: RR (Double Ruby) is a double framework that features a rich selection of double techniques and a terse syntax. http://xunitpatterns.com/Test%20Double.html
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -40,16 +40,15 @@ files:
|
|
40
40
|
- lib/rr/do_not_allow_creator.rb
|
41
41
|
- lib/rr/mock_creator.rb
|
42
42
|
- lib/rr/probe_creator.rb
|
43
|
+
- lib/rr/times_called_matchers/at_most_matcher.rb
|
44
|
+
- lib/rr/times_called_matchers/times_called_matcher.rb
|
45
|
+
- lib/rr/times_called_matchers/at_least_matcher.rb
|
46
|
+
- lib/rr/times_called_matchers/proc_matcher.rb
|
47
|
+
- lib/rr/times_called_matchers/integer_matcher.rb
|
48
|
+
- lib/rr/times_called_matchers/range_matcher.rb
|
43
49
|
- lib/rr/expectations/argument_equality_expectation.rb
|
44
50
|
- lib/rr/expectations/times_called_expectation.rb
|
45
51
|
- lib/rr/expectations/any_argument_expectation.rb
|
46
|
-
- lib/rr/expectations/wildcard_matchers/boolean.rb
|
47
|
-
- lib/rr/expectations/wildcard_matchers/duck_type.rb
|
48
|
-
- lib/rr/expectations/wildcard_matchers/range.rb
|
49
|
-
- lib/rr/expectations/wildcard_matchers/regexp.rb
|
50
|
-
- lib/rr/expectations/wildcard_matchers/numeric.rb
|
51
|
-
- lib/rr/expectations/wildcard_matchers/is_a.rb
|
52
|
-
- lib/rr/expectations/wildcard_matchers/anything.rb
|
53
52
|
- lib/rr/errors/scenario_not_found_error.rb
|
54
53
|
- lib/rr/errors/argument_equality_error.rb
|
55
54
|
- lib/rr/errors/scenario_order_error.rb
|
@@ -57,6 +56,13 @@ files:
|
|
57
56
|
- lib/rr/errors/times_called_error.rb
|
58
57
|
- lib/rr/adapters/test_unit.rb
|
59
58
|
- lib/rr/adapters/rspec.rb
|
59
|
+
- lib/rr/wildcard_matchers/boolean.rb
|
60
|
+
- lib/rr/wildcard_matchers/duck_type.rb
|
61
|
+
- lib/rr/wildcard_matchers/range.rb
|
62
|
+
- lib/rr/wildcard_matchers/regexp.rb
|
63
|
+
- lib/rr/wildcard_matchers/numeric.rb
|
64
|
+
- lib/rr/wildcard_matchers/is_a.rb
|
65
|
+
- lib/rr/wildcard_matchers/anything.rb
|
60
66
|
- lib/rr/extensions/double_methods.rb
|
61
67
|
- examples/environment_fixture_setup.rb
|
62
68
|
- examples/rspec_example_suite.rb
|
@@ -84,6 +90,12 @@ files:
|
|
84
90
|
- examples/rr/rspec/rspec_backtrace_tweaking_example.rb
|
85
91
|
- examples/rr/rspec/rspec_adapter_example.rb
|
86
92
|
- examples/rr/rspec/rspec_usage_example.rb
|
93
|
+
- examples/rr/times_called_matchers/at_most_matcher_example.rb
|
94
|
+
- examples/rr/times_called_matchers/at_least_matcher_example.rb
|
95
|
+
- examples/rr/times_called_matchers/times_called_matcher_example.rb
|
96
|
+
- examples/rr/times_called_matchers/range_matcher_example.rb
|
97
|
+
- examples/rr/times_called_matchers/proc_matcher_example.rb
|
98
|
+
- examples/rr/times_called_matchers/integer_matcher_example.rb
|
87
99
|
- examples/rr/expectations/is_a_argument_equality_expectation_example.rb
|
88
100
|
- examples/rr/expectations/any_argument_expectation_example.rb
|
89
101
|
- examples/rr/expectations/regexp_argument_equality_expectation_example.rb
|
@@ -94,6 +106,12 @@ files:
|
|
94
106
|
- examples/rr/expectations/range_argument_equality_expectation_example.rb
|
95
107
|
- examples/rr/expectations/argument_equality_expectation_example.rb
|
96
108
|
- examples/rr/expectations/anything_argument_equality_expectation_example.rb
|
109
|
+
- examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb
|
110
|
+
- examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb
|
111
|
+
- examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb
|
112
|
+
- examples/rr/expectations/times_called_expectation/times_called_expectation_at_least_example.rb
|
113
|
+
- examples/rr/expectations/times_called_expectation/times_called_expectation_at_most_example.rb
|
114
|
+
- examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb
|
97
115
|
- examples/rr/errors/rr_error_example.rb
|
98
116
|
- examples/rr/test_unit/test_unit_backtrace_test.rb
|
99
117
|
- examples/rr/test_unit/test_helper.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module RR
|
2
|
-
module Expectations
|
3
|
-
module WildcardMatchers
|
4
|
-
class Boolean
|
5
|
-
def wildcard_match?(other)
|
6
|
-
self == other || is_a_boolean?(other)
|
7
|
-
end
|
8
|
-
|
9
|
-
def ==(other)
|
10
|
-
other.is_a?(self.class)
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
def is_a_boolean?(subject)
|
15
|
-
subject.is_a?(TrueClass) || subject.is_a?(FalseClass)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module RR
|
2
|
-
module Expectations
|
3
|
-
module WildcardMatchers
|
4
|
-
class DuckType
|
5
|
-
attr_accessor :required_methods
|
6
|
-
|
7
|
-
def initialize(*required_methods)
|
8
|
-
@required_methods = required_methods
|
9
|
-
end
|
10
|
-
|
11
|
-
def wildcard_match?(other)
|
12
|
-
return true if self == other
|
13
|
-
required_methods.each do |m|
|
14
|
-
return false unless other.respond_to?(m)
|
15
|
-
end
|
16
|
-
return true
|
17
|
-
end
|
18
|
-
|
19
|
-
def ==(other)
|
20
|
-
return false unless other.is_a?(self.class)
|
21
|
-
self.required_methods == other.required_methods
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module RR
|
2
|
-
module Expectations
|
3
|
-
module WildcardMatchers
|
4
|
-
class IsA
|
5
|
-
attr_reader :klass
|
6
|
-
|
7
|
-
def initialize(klass)
|
8
|
-
@klass = klass
|
9
|
-
end
|
10
|
-
|
11
|
-
def wildcard_match?(other)
|
12
|
-
self == other || other.is_a?(klass)
|
13
|
-
end
|
14
|
-
|
15
|
-
def ==(other)
|
16
|
-
return false unless other.is_a?(self.class)
|
17
|
-
self.klass == other.klass
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|