rr 0.3.10 → 0.3.11

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 CHANGED
@@ -1,3 +1,6 @@
1
+ * 0.3.11
2
+ - Fixed [#13724] Mock Proxy on Active Record Association proxies causes error
3
+
1
4
  * 0.3.10
2
5
  - Fixed [#13139] Blocks added to proxy sets the return_value and not the after_call callback
3
6
 
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ def run_suite
26
26
  end
27
27
 
28
28
  PKG_NAME = "rr"
29
- PKG_VERSION = "0.3.10"
29
+ PKG_VERSION = "0.3.11"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
@@ -43,8 +43,8 @@ describe Double, "#initialize where method does not exist on object" do
43
43
  @double = Double.new(@space, @object, @method_name)
44
44
  end
45
45
 
46
- it "has a nil original_method" do
47
- @double.original_method.should be_nil
46
+ it "object does not have original method" do
47
+ @double.object_has_original_method?.should be_false
48
48
  end
49
49
  end
50
50
 
@@ -59,8 +59,8 @@ describe Double, "#initialize where method exists on object" do
59
59
  @double = Double.new(@space, @object, @method_name)
60
60
  end
61
61
 
62
- it "has a nil original_method" do
63
- @double.original_method.should == @object.method(@method_name)
62
+ it "has a original_method" do
63
+ @double.object_has_original_method?.should be_true
64
64
  end
65
65
  end
66
66
  end
@@ -0,0 +1,56 @@
1
+ require "examples/example_helper"
2
+
3
+ module RR
4
+ describe Double, "#object_has_original_method?" do
5
+ before do
6
+ @space = Space.new
7
+ @object = Object.new
8
+ @method_name = :to_s
9
+ @double = Double.new(@space, @object, @method_name)
10
+ class << @double
11
+ public :original_method_name
12
+ end
13
+ end
14
+
15
+ it "returns true when method is still in object" do
16
+ @double.bind
17
+ @double.object_has_original_method?.should be_true
18
+ end
19
+
20
+ it "returns true when respond_to is true and methods include method" do
21
+ @double.bind
22
+ def @object.methods
23
+ [:__rr_original_to_s]
24
+ end
25
+ def @object.respond_to?(value)
26
+ true
27
+ end
28
+
29
+ @double.object_has_original_method?.should be_true
30
+ end
31
+
32
+ it "returns true when respond_to is true and methods do not include method" do
33
+ @double.bind
34
+ def @object.methods
35
+ []
36
+ end
37
+ def @object.respond_to?(value)
38
+ true
39
+ end
40
+
41
+ @double.object_has_original_method?.should be_true
42
+ end
43
+
44
+ it "returns false when respond_to is false and methods do not include method" do
45
+ @double.bind
46
+ def @object.methods
47
+ []
48
+ end
49
+ def @object.respond_to?(value)
50
+ false
51
+ end
52
+
53
+ @double.object_has_original_method?.should be_false
54
+ end
55
+ end
56
+ end
@@ -382,7 +382,32 @@ describe Scenario, "#implemented_by_original_method" do
382
382
  @scenario.call(@double, 1, 2).should == [2, 1]
383
383
  end
384
384
 
385
- it "calls method_missing when original_method does not exist" do
385
+ it "calls methods when respond_to? is true and methods does not contain original method" do
386
+ method_name = nil
387
+ class << @object
388
+ def methods
389
+ []
390
+ end
391
+ def method(name)
392
+ raise "We should not be here"
393
+ end
394
+ def respond_to?(name)
395
+ true
396
+ end
397
+ def method_missing(method_name, *args, &block)
398
+ raise "We should not be here"
399
+ end
400
+ end
401
+
402
+ double = @space.double(@object, :foobar)
403
+ scenario = @space.scenario(double)
404
+ scenario.with_any_args
405
+ scenario.implemented_by_original_method
406
+
407
+ @object.foobar(1, 2).should == [2, 1]
408
+ end
409
+
410
+ it "calls method when original_method does not exist" do
386
411
  class << @object
387
412
  def method_missing(method_name, *args, &block)
388
413
  "method_missing for #{method_name}(#{args.inspect})"
@@ -267,7 +267,7 @@ describe Space, "#double when double exists" do
267
267
  original_foobar_method = @object.method(:foobar)
268
268
  double = @space.double(@object, 'foobar')
269
269
 
270
- double.original_method.should == original_foobar_method
270
+ double.object_has_original_method?.should be_true
271
271
 
272
272
  @space.double(@object, 'foobar').should === double
273
273
 
data/lib/rr/double.rb CHANGED
@@ -49,7 +49,7 @@ module RR
49
49
  # if one exists.
50
50
  def reset
51
51
  meta.send(:remove_method, placeholder_name)
52
- if original_method
52
+ if object_has_original_method?
53
53
  meta.send(:alias_method, @method_name, original_method_name)
54
54
  meta.send(:remove_method, original_method_name)
55
55
  else
@@ -57,11 +57,12 @@ module RR
57
57
  end
58
58
  end
59
59
 
60
- # The original method of the object. It returns nil if the object
61
- # does not have an original method.
62
- def original_method
63
- return nil unless object_has_method?(original_method_name)
64
- return @object.method(original_method_name)
60
+ def call_original_method(*args, &block)
61
+ @object.__send__(original_method_name, *args, &block)
62
+ end
63
+
64
+ def object_has_original_method?
65
+ object_has_method?(original_method_name)
65
66
  end
66
67
 
67
68
  protected
@@ -121,7 +122,7 @@ module RR
121
122
  end
122
123
 
123
124
  def object_has_method?(method_name)
124
- @object.methods.include?(method_name.to_s)
125
+ @object.methods.include?(method_name.to_s) || @object.respond_to?(method_name)
125
126
  end
126
127
 
127
128
  def meta
data/lib/rr/scenario.rb CHANGED
@@ -239,8 +239,8 @@ module RR
239
239
  return nil unless implementation
240
240
 
241
241
  if implementation === ScenarioDefinition::ORIGINAL_METHOD
242
- if double.original_method
243
- return double.original_method.call(*args, &block)
242
+ if double.object_has_original_method?
243
+ return double.call_original_method(*args, &block)
244
244
  else
245
245
  return double.object.__send__(
246
246
  :method_missing,
data/lib/rr.rb CHANGED
@@ -1,46 +1,47 @@
1
- require "rr/errors/rr_error"
2
- require "rr/errors/scenario_definition_error"
3
- require "rr/errors/scenario_not_found_error"
4
- require "rr/errors/scenario_order_error"
5
- require "rr/errors/argument_equality_error"
6
- require "rr/errors/times_called_error"
7
-
8
- require "rr/space"
9
- require "rr/double"
10
- require "rr/hash_with_object_id_key"
11
-
12
- require "rr/scenario_method_proxy"
13
-
14
- require "rr/scenario_creator"
15
-
16
- require "rr/scenario"
17
- require "rr/scenario_definition"
18
- require "rr/scenario_definition_builder"
19
- require "rr/scenario_matches"
20
-
21
- require "rr/expectations/argument_equality_expectation"
22
- require "rr/expectations/any_argument_expectation"
23
- require "rr/expectations/times_called_expectation"
24
-
25
- require "rr/wildcard_matchers/anything"
26
- require "rr/wildcard_matchers/is_a"
27
- require "rr/wildcard_matchers/numeric"
28
- require "rr/wildcard_matchers/boolean"
29
- require "rr/wildcard_matchers/duck_type"
30
- require "rr/wildcard_matchers/regexp"
31
- require "rr/wildcard_matchers/range"
32
-
33
- require "rr/times_called_matchers/terminal"
34
- require "rr/times_called_matchers/non_terminal"
35
- require "rr/times_called_matchers/times_called_matcher"
36
- require "rr/times_called_matchers/any_times_matcher"
37
- require "rr/times_called_matchers/integer_matcher"
38
- require "rr/times_called_matchers/range_matcher"
39
- require "rr/times_called_matchers/proc_matcher"
40
- require "rr/times_called_matchers/at_least_matcher"
41
- require "rr/times_called_matchers/at_most_matcher"
42
-
43
- require "rr/extensions/instance_methods"
44
-
45
- require "rr/adapters/rspec"
46
- require "rr/adapters/test_unit"
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/rr/errors/rr_error"
3
+ require "#{dir}/rr/errors/scenario_definition_error"
4
+ require "#{dir}/rr/errors/scenario_not_found_error"
5
+ require "#{dir}/rr/errors/scenario_order_error"
6
+ require "#{dir}/rr/errors/argument_equality_error"
7
+ require "#{dir}/rr/errors/times_called_error"
8
+
9
+ require "#{dir}/rr/space"
10
+ require "#{dir}/rr/double"
11
+ require "#{dir}/rr/hash_with_object_id_key"
12
+
13
+ require "#{dir}/rr/scenario_method_proxy"
14
+
15
+ require "#{dir}/rr/scenario_creator"
16
+
17
+ require "#{dir}/rr/scenario"
18
+ require "#{dir}/rr/scenario_definition"
19
+ require "#{dir}/rr/scenario_definition_builder"
20
+ require "#{dir}/rr/scenario_matches"
21
+
22
+ require "#{dir}/rr/expectations/argument_equality_expectation"
23
+ require "#{dir}/rr/expectations/any_argument_expectation"
24
+ require "#{dir}/rr/expectations/times_called_expectation"
25
+
26
+ require "#{dir}/rr/wildcard_matchers/anything"
27
+ require "#{dir}/rr/wildcard_matchers/is_a"
28
+ require "#{dir}/rr/wildcard_matchers/numeric"
29
+ require "#{dir}/rr/wildcard_matchers/boolean"
30
+ require "#{dir}/rr/wildcard_matchers/duck_type"
31
+ require "#{dir}/rr/wildcard_matchers/regexp"
32
+ require "#{dir}/rr/wildcard_matchers/range"
33
+
34
+ require "#{dir}/rr/times_called_matchers/terminal"
35
+ require "#{dir}/rr/times_called_matchers/non_terminal"
36
+ require "#{dir}/rr/times_called_matchers/times_called_matcher"
37
+ require "#{dir}/rr/times_called_matchers/any_times_matcher"
38
+ require "#{dir}/rr/times_called_matchers/integer_matcher"
39
+ require "#{dir}/rr/times_called_matchers/range_matcher"
40
+ require "#{dir}/rr/times_called_matchers/proc_matcher"
41
+ require "#{dir}/rr/times_called_matchers/at_least_matcher"
42
+ require "#{dir}/rr/times_called_matchers/at_most_matcher"
43
+
44
+ require "#{dir}/rr/extensions/instance_methods"
45
+
46
+ require "#{dir}/rr/adapters/rspec"
47
+ require "#{dir}/rr/adapters/test_unit"
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.3
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: rr
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.10
7
- date: 2007-08-18 00:00:00 -07:00
6
+ version: 0.3.11
7
+ date: 2007-09-06 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
@@ -29,108 +29,108 @@ post_install_message:
29
29
  authors:
30
30
  - Brian Takita
31
31
  files:
32
+ - README
32
33
  - Rakefile
33
34
  - CHANGES
34
- - README
35
- - lib/rr.rb
36
- - lib/rr/scenario_method_proxy.rb
37
- - lib/rr/scenario.rb
38
- - lib/rr/scenario_definition.rb
39
- - lib/rr/hash_with_object_id_key.rb
40
- - lib/rr/scenario_definition_builder.rb
41
- - lib/rr/scenario_matches.rb
42
- - lib/rr/space.rb
43
- - lib/rr/double.rb
44
- - lib/rr/scenario_creator.rb
45
- - lib/rr/times_called_matchers/any_times_matcher.rb
46
- - lib/rr/times_called_matchers/at_most_matcher.rb
47
- - lib/rr/times_called_matchers/times_called_matcher.rb
48
- - lib/rr/times_called_matchers/at_least_matcher.rb
49
- - lib/rr/times_called_matchers/proc_matcher.rb
50
- - lib/rr/times_called_matchers/integer_matcher.rb
51
- - lib/rr/times_called_matchers/non_terminal.rb
52
- - lib/rr/times_called_matchers/terminal.rb
53
- - lib/rr/times_called_matchers/range_matcher.rb
35
+ - lib/rr/extensions/instance_methods.rb
36
+ - lib/rr/adapters/test_unit.rb
37
+ - lib/rr/adapters/rspec.rb
54
38
  - lib/rr/expectations/argument_equality_expectation.rb
55
39
  - lib/rr/expectations/times_called_expectation.rb
56
40
  - lib/rr/expectations/any_argument_expectation.rb
41
+ - lib/rr/scenario.rb
42
+ - lib/rr/double.rb
43
+ - lib/rr/errors/times_called_error.rb
57
44
  - lib/rr/errors/scenario_not_found_error.rb
58
- - lib/rr/errors/argument_equality_error.rb
59
45
  - lib/rr/errors/scenario_order_error.rb
46
+ - lib/rr/errors/argument_equality_error.rb
60
47
  - lib/rr/errors/rr_error.rb
61
- - lib/rr/errors/times_called_error.rb
62
48
  - lib/rr/errors/scenario_definition_error.rb
63
- - lib/rr/adapters/test_unit.rb
64
- - lib/rr/adapters/rspec.rb
49
+ - lib/rr/scenario_creator.rb
50
+ - lib/rr/space.rb
51
+ - lib/rr/scenario_definition_builder.rb
52
+ - lib/rr/scenario_definition.rb
65
53
  - lib/rr/wildcard_matchers/boolean.rb
54
+ - lib/rr/wildcard_matchers/anything.rb
55
+ - lib/rr/wildcard_matchers/numeric.rb
66
56
  - lib/rr/wildcard_matchers/duck_type.rb
67
- - lib/rr/wildcard_matchers/range.rb
68
57
  - lib/rr/wildcard_matchers/regexp.rb
69
- - lib/rr/wildcard_matchers/numeric.rb
70
58
  - lib/rr/wildcard_matchers/is_a.rb
71
- - lib/rr/wildcard_matchers/anything.rb
72
- - lib/rr/extensions/instance_methods.rb
73
- - examples/environment_fixture_setup.rb
74
- - examples/rspec_example_suite.rb
75
- - examples/core_example_suite.rb
76
- - examples/example_suite.rb
77
- - examples/example_helper.rb
78
- - examples/test_unit_example_suite.rb
79
- - examples/high_level_example.rb
80
- - examples/rr/scenario_definition_example.rb
81
- - examples/rr/scenario_method_proxy_example.rb
82
- - examples/rr/scenario_example.rb
83
- - examples/rr/scenario_creator_example.rb
84
- - examples/rr/rspec/rspec_backtrace_tweaking_example.rb
85
- - examples/rr/rspec/rspec_adapter_example.rb
86
- - examples/rr/rspec/rspec_usage_example.rb
87
- - examples/rr/times_called_matchers/at_most_matcher_example.rb
88
- - examples/rr/times_called_matchers/at_least_matcher_example.rb
89
- - examples/rr/times_called_matchers/times_called_matcher_example.rb
90
- - examples/rr/times_called_matchers/range_matcher_example.rb
91
- - examples/rr/times_called_matchers/proc_matcher_example.rb
92
- - examples/rr/times_called_matchers/any_times_matcher_example.rb
93
- - examples/rr/times_called_matchers/integer_matcher_example.rb
94
- - examples/rr/space/space_verify_example.rb
95
- - examples/rr/space/space_reset_example.rb
96
- - examples/rr/space/space_create_example.rb
97
- - examples/rr/space/space_helper.rb
98
- - examples/rr/space/space_example.rb
99
- - examples/rr/space/hash_with_object_id_key_example.rb
100
- - examples/rr/space/space_register_example.rb
101
- - examples/rr/expectations/is_a_argument_equality_expectation_example.rb
102
- - examples/rr/expectations/any_argument_expectation_example.rb
103
- - examples/rr/expectations/regexp_argument_equality_expectation_example.rb
104
- - examples/rr/expectations/boolean_argument_equality_expectation_example.rb
105
- - examples/rr/expectations/duck_type_argument_equality_expectation_example.rb
106
- - examples/rr/expectations/numeric_argument_equality_expectation_example.rb
107
- - examples/rr/expectations/range_argument_equality_expectation_example.rb
59
+ - lib/rr/wildcard_matchers/range.rb
60
+ - lib/rr/times_called_matchers/at_least_matcher.rb
61
+ - lib/rr/times_called_matchers/range_matcher.rb
62
+ - lib/rr/times_called_matchers/integer_matcher.rb
63
+ - lib/rr/times_called_matchers/non_terminal.rb
64
+ - lib/rr/times_called_matchers/proc_matcher.rb
65
+ - lib/rr/times_called_matchers/times_called_matcher.rb
66
+ - lib/rr/times_called_matchers/at_most_matcher.rb
67
+ - lib/rr/times_called_matchers/any_times_matcher.rb
68
+ - lib/rr/times_called_matchers/terminal.rb
69
+ - lib/rr/scenario_method_proxy.rb
70
+ - lib/rr/scenario_matches.rb
71
+ - lib/rr/hash_with_object_id_key.rb
72
+ - lib/rr.rb
73
+ - examples/rr/extensions/instance_methods_creator_example.rb
74
+ - examples/rr/extensions/instance_methods_example_helper.rb
75
+ - examples/rr/extensions/instance_methods_times_matcher_example.rb
76
+ - examples/rr/extensions/instance_methods_argument_matcher_example.rb
77
+ - examples/rr/extensions/instance_methods_space_example.rb
108
78
  - examples/rr/expectations/argument_equality_expectation_example.rb
109
79
  - examples/rr/expectations/anything_argument_equality_expectation_example.rb
80
+ - examples/rr/expectations/times_called_expectation/times_called_expectation_at_least_example.rb
81
+ - examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb
110
82
  - examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb
111
- - examples/rr/expectations/times_called_expectation/times_called_expectation_any_times_example.rb
112
- - examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb
113
- - examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb
114
83
  - examples/rr/expectations/times_called_expectation/times_called_expectation_example.rb
115
- - examples/rr/expectations/times_called_expectation/times_called_expectation_at_least_example.rb
84
+ - examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb
85
+ - examples/rr/expectations/times_called_expectation/times_called_expectation_helper.rb
116
86
  - examples/rr/expectations/times_called_expectation/times_called_expectation_at_most_example.rb
117
- - examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb
118
- - examples/rr/errors/rr_error_example.rb
119
- - examples/rr/double/double_original_method_example.rb
120
- - examples/rr/double/double_reset_example.rb
87
+ - examples/rr/expectations/times_called_expectation/times_called_expectation_any_times_example.rb
88
+ - examples/rr/expectations/any_argument_expectation_example.rb
89
+ - examples/rr/expectations/is_a_argument_equality_expectation_example.rb
90
+ - examples/rr/expectations/numeric_argument_equality_expectation_example.rb
91
+ - examples/rr/expectations/boolean_argument_equality_expectation_example.rb
92
+ - examples/rr/expectations/duck_type_argument_equality_expectation_example.rb
93
+ - examples/rr/expectations/regexp_argument_equality_expectation_example.rb
94
+ - examples/rr/expectations/range_argument_equality_expectation_example.rb
95
+ - examples/rr/rspec/rspec_adapter_example.rb
96
+ - examples/rr/rspec/rspec_usage_example.rb
97
+ - examples/rr/rspec/rspec_backtrace_tweaking_example.rb
98
+ - examples/rr/test_unit/test_helper.rb
99
+ - examples/rr/test_unit/test_unit_integration_test.rb
100
+ - examples/rr/test_unit/test_unit_backtrace_test.rb
101
+ - examples/rr/scenario_example.rb
121
102
  - examples/rr/double/double_bind_example.rb
122
- - examples/rr/double/double_register_scenario_example.rb
123
- - examples/rr/double/double_example.rb
124
103
  - examples/rr/double/double_dispatching_example.rb
104
+ - examples/rr/double/double_example.rb
105
+ - examples/rr/double/double_reset_example.rb
125
106
  - examples/rr/double/double_verify_example.rb
126
- - examples/rr/test_unit/test_unit_backtrace_test.rb
127
- - examples/rr/test_unit/test_helper.rb
128
- - examples/rr/test_unit/test_unit_integration_test.rb
129
- - examples/rr/extensions/instance_methods_argument_matcher_example.rb
130
- - examples/rr/extensions/instance_methods_times_matcher_example.rb
131
- - examples/rr/extensions/instance_methods_creator_example.rb
132
- - examples/rr/extensions/instance_methods_space_example.rb
133
- - examples/rr/extensions/instance_methods_example_helper.rb
107
+ - examples/rr/double/double_register_scenario_example.rb
108
+ - examples/rr/double/double_has_original_method_example.rb
109
+ - examples/rr/space/space_example.rb
110
+ - examples/rr/space/space_reset_example.rb
111
+ - examples/rr/space/space_create_example.rb
112
+ - examples/rr/space/space_helper.rb
113
+ - examples/rr/space/space_register_example.rb
114
+ - examples/rr/space/space_verify_example.rb
115
+ - examples/rr/space/hash_with_object_id_key_example.rb
116
+ - examples/rr/times_called_matchers/proc_matcher_example.rb
117
+ - examples/rr/times_called_matchers/times_called_matcher_example.rb
118
+ - examples/rr/times_called_matchers/at_most_matcher_example.rb
119
+ - examples/rr/times_called_matchers/any_times_matcher_example.rb
120
+ - examples/rr/times_called_matchers/at_least_matcher_example.rb
121
+ - examples/rr/times_called_matchers/range_matcher_example.rb
122
+ - examples/rr/times_called_matchers/integer_matcher_example.rb
123
+ - examples/rr/scenario_creator_example.rb
124
+ - examples/rr/scenario_method_proxy_example.rb
125
+ - examples/rr/scenario_definition_example.rb
126
+ - examples/rr/errors/rr_error_example.rb
127
+ - examples/rspec_example_suite.rb
128
+ - examples/high_level_example.rb
129
+ - examples/test_unit_example_suite.rb
130
+ - examples/example_suite.rb
131
+ - examples/environment_fixture_setup.rb
132
+ - examples/example_helper.rb
133
+ - examples/core_example_suite.rb
134
134
  test_files: []
135
135
 
136
136
  rdoc_options:
@@ -1,33 +0,0 @@
1
- require "examples/example_helper"
2
-
3
- module RR
4
- describe Double, "#original_method" do
5
- before do
6
- @space = Space.new
7
- @object = Object.new
8
- @method_name = :to_s
9
- @double = Double.new(@space, @object, @method_name)
10
- class << @double
11
- public :original_method_name
12
- end
13
- end
14
-
15
- it "returns true when method is still in object" do
16
- @double.bind
17
- @double.original_method.should == @object.method(@double.original_method_name)
18
- end
19
-
20
- it "returns false when respond_to is true and methods do not include method" do
21
- @double.bind
22
- @object.methods.should include(@double.original_method_name.to_s)
23
- class << @object
24
- undef_method :__rr__original_to_s
25
- end
26
- def @object.respond_to?(value)
27
- true
28
- end
29
-
30
- @double.original_method.should be_nil
31
- end
32
- end
33
- end