rr 0.10.11 → 1.0.0
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.
- data/CHANGES +5 -0
- data/Gemfile +6 -0
- data/README.rdoc +28 -2
- data/VERSION.yml +3 -3
- data/lib/rr.rb +23 -17
- data/lib/rr/adapters/rr_methods.rb +43 -17
- data/lib/rr/blank_slate.rb +2 -2
- data/lib/rr/class_instance_method_defined.rb +9 -0
- data/lib/rr/double.rb +2 -2
- data/lib/rr/double_definitions/double_definition.rb +29 -16
- data/lib/rr/double_definitions/double_definition_create.rb +52 -86
- data/lib/rr/double_definitions/double_injections/any_instance_of.rb +28 -0
- data/lib/rr/double_definitions/double_injections/instance.rb +16 -0
- data/lib/rr/double_definitions/double_injections/new_instance_of.rb +53 -0
- data/lib/rr/double_definitions/strategies/double_injection/any_instance_of.rb +31 -0
- data/lib/rr/double_definitions/strategies/double_injection/double_injection_strategy.rb +10 -0
- data/lib/rr/double_definitions/strategies/double_injection/instance.rb +17 -0
- data/lib/rr/double_definitions/strategies/double_injection/new_instance_of.rb +37 -0
- data/lib/rr/double_definitions/strategies/implementation/implementation_strategy.rb +0 -5
- data/lib/rr/double_definitions/strategies/implementation/proxy.rb +0 -2
- data/lib/rr/double_definitions/strategies/implementation/strongly_typed_reimplementation.rb +0 -2
- data/lib/rr/double_definitions/strategies/strategy.rb +0 -27
- data/lib/rr/double_definitions/strategies/strategy_methods.rb +53 -0
- data/lib/rr/double_definitions/strategies/verification/dont_allow.rb +0 -2
- data/lib/rr/double_definitions/strategies/verification/mock.rb +0 -2
- data/lib/rr/double_definitions/strategies/verification/stub.rb +0 -2
- data/lib/rr/double_definitions/strategies/verification/verification_strategy.rb +0 -5
- data/lib/rr/hash_with_object_id_key.rb +4 -0
- data/lib/rr/injections/double_injection.rb +94 -71
- data/lib/rr/injections/injection.rb +8 -10
- data/lib/rr/injections/method_missing_injection.rb +13 -20
- data/lib/rr/injections/singleton_method_added_injection.rb +19 -17
- data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
- data/lib/rr/method_dispatches/method_dispatch.rb +4 -4
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +17 -14
- data/lib/rr/recorded_calls.rb +1 -1
- data/lib/rr/space.rb +6 -6
- data/lib/rr/times_called_matchers/times_called_matcher.rb +2 -2
- data/scratch.rb +118 -0
- data/spec/api/any_instance_of/all_instances_of_spec.rb +14 -0
- data/spec/api/any_instance_of/any_instance_of_spec.rb +47 -0
- data/spec/api/mock/mock_spec.rb +2 -2
- data/spec/api/new_instance_of/instance_of_spec.rb +15 -0
- data/spec/api/new_instance_of/new_instance_of_spec.rb +61 -0
- data/spec/environment_fixture_setup.rb +3 -2
- data/spec/rr/adapters/rr_methods_space_spec.rb +8 -10
- data/spec/rr/double_definitions/child_double_definition_creator_spec.rb +1 -1
- data/spec/rr/double_definitions/double_definition_create_blank_slate_spec.rb +6 -2
- data/spec/rr/double_definitions/double_definition_create_spec.rb +1 -52
- data/spec/rr/double_injection/double_injection_verify_spec.rb +1 -1
- data/spec/rr/rspec/rspec_adapter_spec.rb +5 -5
- data/spec/rr/space/space_spec.rb +58 -67
- data/spec/spec_helper.rb +2 -2
- metadata +33 -9
- data/lib/rr/double_definitions/strategies/scope/instance.rb +0 -15
- data/lib/rr/double_definitions/strategies/scope/instance_of_class.rb +0 -50
- data/lib/rr/double_definitions/strategies/scope/scope_strategy.rb +0 -15
data/spec/spec_helper.rb
CHANGED
@@ -23,13 +23,13 @@ describe "Swapped Space", :shared => true do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class Spec::ExampleGroup
|
26
|
-
|
26
|
+
extend(Module.new do
|
27
27
|
def macro(name, &implementation)
|
28
28
|
(class << self; self; end).class_eval do
|
29
29
|
define_method(name, &implementation)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end)
|
33
33
|
|
34
34
|
def eigen(object)
|
35
35
|
class << object; self; end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Brian Takita
|
@@ -9,7 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-08-23 00:00:00 -07:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -24,6 +30,7 @@ extra_rdoc_files:
|
|
24
30
|
- README.rdoc
|
25
31
|
files:
|
26
32
|
- CHANGES
|
33
|
+
- Gemfile
|
27
34
|
- LICENSE
|
28
35
|
- README.rdoc
|
29
36
|
- Rakefile
|
@@ -33,19 +40,25 @@ files:
|
|
33
40
|
- lib/rr/adapters/rspec.rb
|
34
41
|
- lib/rr/adapters/test_unit.rb
|
35
42
|
- lib/rr/blank_slate.rb
|
43
|
+
- lib/rr/class_instance_method_defined.rb
|
36
44
|
- lib/rr/double.rb
|
37
45
|
- lib/rr/double_definitions/child_double_definition_create.rb
|
38
46
|
- lib/rr/double_definitions/double_definition.rb
|
39
47
|
- lib/rr/double_definitions/double_definition_create.rb
|
40
48
|
- lib/rr/double_definitions/double_definition_create_blank_slate.rb
|
49
|
+
- lib/rr/double_definitions/double_injections/any_instance_of.rb
|
50
|
+
- lib/rr/double_definitions/double_injections/instance.rb
|
51
|
+
- lib/rr/double_definitions/double_injections/new_instance_of.rb
|
52
|
+
- lib/rr/double_definitions/strategies/double_injection/any_instance_of.rb
|
53
|
+
- lib/rr/double_definitions/strategies/double_injection/double_injection_strategy.rb
|
54
|
+
- lib/rr/double_definitions/strategies/double_injection/instance.rb
|
55
|
+
- lib/rr/double_definitions/strategies/double_injection/new_instance_of.rb
|
41
56
|
- lib/rr/double_definitions/strategies/implementation/implementation_strategy.rb
|
42
57
|
- lib/rr/double_definitions/strategies/implementation/proxy.rb
|
43
58
|
- lib/rr/double_definitions/strategies/implementation/reimplementation.rb
|
44
59
|
- lib/rr/double_definitions/strategies/implementation/strongly_typed_reimplementation.rb
|
45
|
-
- lib/rr/double_definitions/strategies/scope/instance.rb
|
46
|
-
- lib/rr/double_definitions/strategies/scope/instance_of_class.rb
|
47
|
-
- lib/rr/double_definitions/strategies/scope/scope_strategy.rb
|
48
60
|
- lib/rr/double_definitions/strategies/strategy.rb
|
61
|
+
- lib/rr/double_definitions/strategies/strategy_methods.rb
|
49
62
|
- lib/rr/double_definitions/strategies/verification/dont_allow.rb
|
50
63
|
- lib/rr/double_definitions/strategies/verification/mock.rb
|
51
64
|
- lib/rr/double_definitions/strategies/verification/stub.rb
|
@@ -98,8 +111,13 @@ files:
|
|
98
111
|
- lib/rr/wildcard_matchers/range.rb
|
99
112
|
- lib/rr/wildcard_matchers/regexp.rb
|
100
113
|
- lib/rr/wildcard_matchers/satisfy.rb
|
114
|
+
- scratch.rb
|
115
|
+
- spec/api/any_instance_of/all_instances_of_spec.rb
|
116
|
+
- spec/api/any_instance_of/any_instance_of_spec.rb
|
101
117
|
- spec/api/dont_allow/dont_allow_after_stub_spec.rb
|
102
118
|
- spec/api/mock/mock_spec.rb
|
119
|
+
- spec/api/new_instance_of/instance_of_spec.rb
|
120
|
+
- spec/api/new_instance_of/new_instance_of_spec.rb
|
103
121
|
- spec/api/proxy/proxy_spec.rb
|
104
122
|
- spec/api/spy/spy_spec.rb
|
105
123
|
- spec/api/strong/strong_spec.rb
|
@@ -176,25 +194,31 @@ rdoc_options:
|
|
176
194
|
require_paths:
|
177
195
|
- lib
|
178
196
|
required_ruby_version: !ruby/object:Gem::Requirement
|
197
|
+
none: false
|
179
198
|
requirements:
|
180
199
|
- - ">="
|
181
200
|
- !ruby/object:Gem::Version
|
201
|
+
hash: 3
|
202
|
+
segments:
|
203
|
+
- 0
|
182
204
|
version: "0"
|
183
|
-
version:
|
184
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
none: false
|
185
207
|
requirements:
|
186
208
|
- - ">="
|
187
209
|
- !ruby/object:Gem::Version
|
210
|
+
hash: 3
|
211
|
+
segments:
|
212
|
+
- 0
|
188
213
|
version: "0"
|
189
|
-
version:
|
190
214
|
requirements: []
|
191
215
|
|
192
216
|
rubyforge_project: pivotalrb
|
193
|
-
rubygems_version: 1.3.
|
217
|
+
rubygems_version: 1.3.7
|
194
218
|
signing_key:
|
195
219
|
specification_version: 3
|
196
220
|
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
|
197
221
|
test_files:
|
198
222
|
- spec/spy_verification_spec.rb
|
199
|
-
- spec/rr_spec.rb
|
200
223
|
- spec/proc_from_block_spec.rb
|
224
|
+
- spec/rr_spec.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module RR
|
2
|
-
module DoubleDefinitions
|
3
|
-
module Strategies
|
4
|
-
module Scope
|
5
|
-
class Instance < ScopeStrategy
|
6
|
-
protected
|
7
|
-
def do_call
|
8
|
-
double_injection = Injections::DoubleInjection.create(subject, method_name)
|
9
|
-
Double.new(double_injection, definition)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module RR
|
2
|
-
module DoubleDefinitions
|
3
|
-
module Strategies
|
4
|
-
module Scope
|
5
|
-
# Calling instance_of will cause all instances of the passed in Class
|
6
|
-
# to have the Double defined.
|
7
|
-
#
|
8
|
-
# The following example mocks all User's valid? method and return false.
|
9
|
-
# mock.instance_of(User).valid? {false}
|
10
|
-
#
|
11
|
-
# The following example mocks and proxies User#projects and returns the
|
12
|
-
# first 3 projects.
|
13
|
-
# mock.instance_of(User).projects do |projects|
|
14
|
-
# projects[0..2]
|
15
|
-
# end
|
16
|
-
class InstanceOfClass < ScopeStrategy
|
17
|
-
register "instance_of"
|
18
|
-
|
19
|
-
def initialize(*args)
|
20
|
-
super
|
21
|
-
|
22
|
-
if !double_definition_create.no_subject? && !double_definition_create.subject.is_a?(Class)
|
23
|
-
raise ArgumentError, "instance_of only accepts class objects"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
protected
|
28
|
-
def do_call
|
29
|
-
instance_of_subject_double_definition_create = DoubleDefinitionCreate.new
|
30
|
-
instance_of_subject_double_definition_create.strong if definition.verify_method_signature?
|
31
|
-
instance_of_subject_double_definition_create.stub(subject)
|
32
|
-
instance_of_subject_double_definition_create.call(:new) do |*args|
|
33
|
-
#####
|
34
|
-
instance = subject.allocate
|
35
|
-
double_injection = Injections::DoubleInjection.create(instance, method_name)
|
36
|
-
Double.new(double_injection, definition)
|
37
|
-
#####
|
38
|
-
if args.last.is_a?(ProcFromBlock)
|
39
|
-
instance.__send__(:initialize, *args[0..(args.length-2)], &args.last)
|
40
|
-
else
|
41
|
-
instance.__send__(:initialize, *args)
|
42
|
-
end
|
43
|
-
instance
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module RR
|
2
|
-
module DoubleDefinitions
|
3
|
-
module Strategies
|
4
|
-
module Scope
|
5
|
-
class ScopeStrategy < Strategy
|
6
|
-
class << self
|
7
|
-
def register_self_at_double_definition_create(strategy_method_name)
|
8
|
-
DoubleDefinitionCreate.register_scope_strategy_class(self, strategy_method_name)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|