rr 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ * 0.4.2
2
+ - Renamed DoubleInsertion to DoubleInjection to be consistent with Mocha terminology
3
+
1
4
  * 0.4.1
2
5
  - Fixed backward compatability issues with rspec
3
6
  - Renamed Space#verify_double_insertions to #verify_doubles
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ def run_suite
26
26
  end
27
27
 
28
28
  PKG_NAME = "rr"
29
- PKG_VERSION = "0.4.1"
29
+ PKG_VERSION = "0.4.2"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
data/lib/rr.rb CHANGED
@@ -7,7 +7,7 @@ require "#{dir}/rr/errors/argument_equality_error"
7
7
  require "#{dir}/rr/errors/times_called_error"
8
8
 
9
9
  require "#{dir}/rr/space"
10
- require "#{dir}/rr/double_insertion"
10
+ require "#{dir}/rr/double_injection"
11
11
  require "#{dir}/rr/hash_with_object_id_key"
12
12
 
13
13
  require "#{dir}/rr/double_method_proxy"
@@ -1,7 +1,7 @@
1
1
  module RR
2
2
  module Adapters
3
3
  module RRMethods
4
- # Verifies all the DoubleInsertion objects have met their
4
+ # Verifies all the DoubleInjection objects have met their
5
5
  # TimesCalledExpectations.
6
6
  def verify
7
7
  RR::Space.instance.verify_doubles
@@ -1,8 +1,8 @@
1
1
  module RR
2
- # RR::DoubleInsertion is the binding of an object and a method.
2
+ # RR::DoubleInjection is the binding of an object and a method.
3
3
  # A double_insertion has 0 to many Double objects. Each Double
4
4
  # has Argument Expectations and Times called Expectations.
5
- class DoubleInsertion
5
+ class DoubleInjection
6
6
  MethodArguments = Struct.new(:arguments, :block)
7
7
  attr_reader :space, :object, :method_name, :scenarios
8
8
 
@@ -16,13 +16,13 @@ module RR
16
16
  @scenarios = []
17
17
  end
18
18
 
19
- # RR::DoubleInsertion#register_scenario adds the passed in Double
20
- # into this DoubleInsertion's list of Double objects.
19
+ # RR::DoubleInjection#register_scenario adds the passed in Double
20
+ # into this DoubleInjection's list of Double objects.
21
21
  def register_scenario(scenario)
22
22
  @scenarios << scenario
23
23
  end
24
24
 
25
- # RR::DoubleInsertion#bind injects a method that acts as a dispatcher
25
+ # RR::DoubleInjection#bind injects a method that acts as a dispatcher
26
26
  # that dispatches to the matching Double when the method
27
27
  # is called.
28
28
  def bind
@@ -36,7 +36,7 @@ module RR
36
36
  meta.class_eval(returns_method, __FILE__, __LINE__ - 5)
37
37
  end
38
38
 
39
- # RR::DoubleInsertion#verify verifies each Double
39
+ # RR::DoubleInjection#verify verifies each Double
40
40
  # TimesCalledExpectation are met.
41
41
  def verify
42
42
  @scenarios.each do |scenario|
@@ -44,7 +44,7 @@ module RR
44
44
  end
45
45
  end
46
46
 
47
- # RR::DoubleInsertion#reset removes the injected dispatcher method.
47
+ # RR::DoubleInjection#reset removes the injected dispatcher method.
48
48
  # It binds the original method implementation on the object
49
49
  # if one exists.
50
50
  def reset
@@ -49,15 +49,15 @@ module RR
49
49
  DoubleDefinition.new(self)
50
50
  end
51
51
 
52
- # Reuses or creates, if none exists, a DoubleInsertion for the passed
52
+ # Reuses or creates, if none exists, a DoubleInjection for the passed
53
53
  # in object and method_name.
54
- # When a DoubleInsertion is created, it binds the dispatcher to the
54
+ # When a DoubleInjection is created, it binds the dispatcher to the
55
55
  # object.
56
56
  def double_insertion(object, method_name)
57
57
  double_insertion = @double_insertions[object][method_name.to_sym]
58
58
  return double_insertion if double_insertion
59
59
 
60
- double_insertion = DoubleInsertion.new(self, object, method_name.to_sym)
60
+ double_insertion = DoubleInjection.new(self, object, method_name.to_sym)
61
61
  @double_insertions[object][method_name.to_sym] = double_insertion
62
62
  double_insertion.bind
63
63
  double_insertion
@@ -85,7 +85,7 @@ module RR
85
85
  scenario
86
86
  end
87
87
 
88
- # Verifies all the DoubleInsertion objects have met their
88
+ # Verifies all the DoubleInjection objects have met their
89
89
  # TimesCalledExpectations.
90
90
  def verify_doubles
91
91
  @double_insertions.each do |object, method_double_map|
@@ -101,14 +101,14 @@ module RR
101
101
  reset_double_insertions
102
102
  end
103
103
 
104
- # Verifies the DoubleInsertion for the passed in object and method_name.
104
+ # Verifies the DoubleInjection for the passed in object and method_name.
105
105
  def verify_double(object, method_name)
106
106
  @double_insertions[object][method_name].verify
107
107
  ensure
108
108
  reset_double object, method_name
109
109
  end
110
110
 
111
- # Resets the DoubleInsertion for the passed in object and method_name.
111
+ # Resets the DoubleInjection for the passed in object and method_name.
112
112
  def reset_double(object, method_name)
113
113
  double_insertion = @double_insertions[object].delete(method_name)
114
114
  @double_insertions.delete(object) if @double_insertions[object].empty?
@@ -1,7 +1,7 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInsertion, "#bind with an existing method" do
4
+ describe DoubleInjection, "#bind with an existing method" do
5
5
  before do
6
6
  @space = Space.new
7
7
  @object = Object.new
@@ -11,7 +11,7 @@ module RR
11
11
  end
12
12
  @original_method = @object.method(:foobar)
13
13
  @object.methods.should include(@method_name.to_s)
14
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
14
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
15
15
  end
16
16
 
17
17
  it "overrides the original method with the double_insertion's dispatching methods" do
@@ -41,13 +41,13 @@ module RR
41
41
  end
42
42
  end
43
43
 
44
- describe DoubleInsertion, "#bind without an existing method" do
44
+ describe DoubleInjection, "#bind without an existing method" do
45
45
  before do
46
46
  @space = Space.new
47
47
  @object = Object.new
48
48
  @method_name = :foobar
49
49
  @object.methods.should_not include(@method_name.to_s)
50
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
50
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
51
51
  end
52
52
 
53
53
  it "overrides the original method with the double_insertion's dispatching methods" do
@@ -1,7 +1,7 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInsertion do
4
+ describe DoubleInjection do
5
5
  before do
6
6
  @space = Space.new
7
7
  @object = Object.new
@@ -1,12 +1,12 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInsertion, "#object_has_original_method?" do
4
+ describe DoubleInjection, "#object_has_original_method?" do
5
5
  before do
6
6
  @space = Space.new
7
7
  @object = Object.new
8
8
  @method_name = :to_s
9
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
9
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
10
10
  class << @double_insertion
11
11
  public :original_method_name
12
12
  end
@@ -1,13 +1,13 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInsertion, "#register_scenario" do
4
+ describe DoubleInjection, "#register_scenario" do
5
5
  before do
6
6
  @space = Space.new
7
7
  @object = Object.new
8
8
  @method_name = :foobar
9
9
  @object.methods.should_not include(@method_name.to_s)
10
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
10
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
11
11
  def @double_insertion.scenarios
12
12
  @scenarios
13
13
  end
@@ -1,7 +1,7 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInsertion, "#reset", :shared => true do
4
+ describe DoubleInjection, "#reset", :shared => true do
5
5
  it "cleans up by removing the __rr__method" do
6
6
  @double_insertion.bind
7
7
  @object.methods.should include("__rr__foobar")
@@ -11,15 +11,15 @@ module RR
11
11
  end
12
12
  end
13
13
 
14
- describe DoubleInsertion, "#reset when method does not exist" do
15
- it_should_behave_like "RR::DoubleInsertion#reset"
14
+ describe DoubleInjection, "#reset when method does not exist" do
15
+ it_should_behave_like "RR::DoubleInjection#reset"
16
16
 
17
17
  before do
18
18
  @space = Space.new
19
19
  @object = Object.new
20
20
  @method_name = :foobar
21
21
  @object.methods.should_not include(@method_name.to_s)
22
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
22
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
23
23
  end
24
24
 
25
25
  it "removes the method" do
@@ -32,8 +32,8 @@ module RR
32
32
  end
33
33
  end
34
34
 
35
- describe DoubleInsertion, "#reset when method exists" do
36
- it_should_behave_like "RR::DoubleInsertion#reset"
35
+ describe DoubleInjection, "#reset when method exists" do
36
+ it_should_behave_like "RR::DoubleInjection#reset"
37
37
 
38
38
  before do
39
39
  @space = Space.new
@@ -44,7 +44,7 @@ module RR
44
44
  end
45
45
  @object.methods.should include(@method_name.to_s)
46
46
  @original_method = @object.method(@method_name)
47
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
47
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
48
48
 
49
49
  @double_insertion.bind
50
50
  @object.methods.should include(@method_name.to_s)
@@ -57,8 +57,8 @@ module RR
57
57
  end
58
58
  end
59
59
 
60
- describe DoubleInsertion, "#reset when method with block exists" do
61
- it_should_behave_like "RR::DoubleInsertion#reset"
60
+ describe DoubleInjection, "#reset when method with block exists" do
61
+ it_should_behave_like "RR::DoubleInjection#reset"
62
62
 
63
63
  before do
64
64
  @space = Space.new
@@ -69,7 +69,7 @@ module RR
69
69
  end
70
70
  @object.methods.should include(@method_name.to_s)
71
71
  @original_method = @object.method(@method_name)
72
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
72
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
73
73
 
74
74
  @double_insertion.bind
75
75
  @object.methods.should include(@method_name.to_s)
@@ -1,46 +1,46 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInsertion, :shared => true do
4
+ describe DoubleInjection, :shared => true do
5
5
  it "sets up object and method_name" do
6
6
  @double_insertion.object.should === @object
7
7
  @double_insertion.method_name.should == @method_name.to_sym
8
8
  end
9
9
  end
10
10
 
11
- describe DoubleInsertion, "#initialize where method_name is a symbol" do
12
- it_should_behave_like "RR::DoubleInsertion"
11
+ describe DoubleInjection, "#initialize where method_name is a symbol" do
12
+ it_should_behave_like "RR::DoubleInjection"
13
13
 
14
14
  before do
15
15
  @space = Space.new
16
16
  @object = Object.new
17
17
  @method_name = :foobar
18
18
  @object.methods.should_not include(@method_name.to_s)
19
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
19
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
20
20
  end
21
21
  end
22
22
 
23
- describe DoubleInsertion, "#initialize where method_name is a string" do
24
- it_should_behave_like "RR::DoubleInsertion"
23
+ describe DoubleInjection, "#initialize where method_name is a string" do
24
+ it_should_behave_like "RR::DoubleInjection"
25
25
 
26
26
  before do
27
27
  @space = Space.new
28
28
  @object = Object.new
29
29
  @method_name = 'foobar'
30
30
  @object.methods.should_not include(@method_name)
31
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
31
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
32
32
  end
33
33
  end
34
34
 
35
- describe DoubleInsertion, "#initialize where method does not exist on object" do
36
- it_should_behave_like "RR::DoubleInsertion"
35
+ describe DoubleInjection, "#initialize where method does not exist on object" do
36
+ it_should_behave_like "RR::DoubleInjection"
37
37
 
38
38
  before do
39
39
  @space = Space.new
40
40
  @object = Object.new
41
41
  @method_name = :foobar
42
42
  @object.methods.should_not include(@method_name.to_s)
43
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
43
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
44
44
  end
45
45
 
46
46
  it "object does not have original method" do
@@ -48,15 +48,15 @@ module RR
48
48
  end
49
49
  end
50
50
 
51
- describe DoubleInsertion, "#initialize where method exists on object" do
52
- it_should_behave_like "RR::DoubleInsertion"
51
+ describe DoubleInjection, "#initialize where method exists on object" do
52
+ it_should_behave_like "RR::DoubleInjection"
53
53
 
54
54
  before do
55
55
  @space = Space.new
56
56
  @object = Object.new
57
57
  @method_name = :to_s
58
58
  @object.methods.should include(@method_name.to_s)
59
- @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
59
+ @double_insertion = DoubleInjection.new(@space, @object, @method_name)
60
60
  end
61
61
 
62
62
  it "has a original_method" do
@@ -1,7 +1,7 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleInsertion, "#verify" do
4
+ describe DoubleInjection, "#verify" do
5
5
  before do
6
6
  @space = Space.new
7
7
  @object = Object.new
@@ -622,7 +622,7 @@ module RR
622
622
  end
623
623
 
624
624
  describe "#method_name" do
625
- it "returns the DoubleInsertion's method_name" do
625
+ it "returns the DoubleInjection's method_name" do
626
626
  double_insertion.method_name.should == :foobar
627
627
  scenario.method_name.should == :foobar
628
628
  end
@@ -6,7 +6,7 @@ describe RR do
6
6
  @subject = Object.new
7
7
  end
8
8
 
9
- it "creates a mock DoubleInsertion Double" do
9
+ it "creates a mock DoubleInjection Double" do
10
10
  mock(@subject).foobar(1, 2) {:baz}
11
11
  @subject.foobar(1, 2).should == :baz
12
12
  end
@@ -17,7 +17,7 @@ describe RR do
17
17
  @subject = Object.new
18
18
  end
19
19
 
20
- it "creates a stub DoubleInsertion Double" do
20
+ it "creates a stub DoubleInjection Double" do
21
21
  stub(@subject).foobar {:baz}
22
22
  @subject.foobar("any", "thing").should == :baz
23
23
  end
@@ -31,7 +31,7 @@ describe RR do
31
31
  end
32
32
  end
33
33
 
34
- it "creates a proxy DoubleInsertion Double" do
34
+ it "creates a proxy DoubleInjection Double" do
35
35
  mock.proxy(@subject).foobar
36
36
  @subject.foobar.should == :baz
37
37
  end
@@ -45,7 +45,7 @@ describe RR do
45
45
  end
46
46
  end
47
47
 
48
- it "creates a proxy DoubleInsertion Double" do
48
+ it "creates a proxy DoubleInjection Double" do
49
49
  stub.proxy(@subject).foobar
50
50
  @subject.foobar.should == :baz
51
51
  end
@@ -59,7 +59,7 @@ describe RR do
59
59
  end
60
60
  end
61
61
 
62
- it "creates a proxy DoubleInsertion Double" do
62
+ it "creates a proxy DoubleInjection Double" do
63
63
  stub.proxy(@subject).foobar
64
64
  @subject.foobar.should == :baz
65
65
  end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rr
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.1
6
+ version: 0.4.2
7
7
  date: 2007-12-31 00:00:00 -08: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:
@@ -43,7 +43,6 @@ files:
43
43
  - lib/rr/times_called_matchers/terminal.rb
44
44
  - lib/rr/times_called_matchers/range_matcher.rb
45
45
  - lib/rr/hash_with_object_id_key.rb
46
- - lib/rr/double_insertion.rb
47
46
  - lib/rr/double_creator.rb
48
47
  - lib/rr/expectations/argument_equality_expectation.rb
49
48
  - lib/rr/expectations/times_called_expectation.rb
@@ -60,6 +59,7 @@ files:
60
59
  - lib/rr/adapters/test_unit.rb
61
60
  - lib/rr/adapters/rspec.rb
62
61
  - lib/rr/double_definition.rb
62
+ - lib/rr/double_injection.rb
63
63
  - lib/rr/double_method_proxy.rb
64
64
  - lib/rr/space.rb
65
65
  - lib/rr/wildcard_matchers/boolean.rb
@@ -118,13 +118,13 @@ files:
118
118
  - spec/rr/adapters/rr_methods_creator_spec.rb
119
119
  - spec/rr/adapters/rr_methods_argument_matcher_spec.rb
120
120
  - spec/rr/double_definition_spec.rb
121
- - spec/rr/double/double_insertion_bind_spec.rb
122
- - spec/rr/double/double_insertion_dispatching_spec.rb
123
- - spec/rr/double/double_insertion_has_original_method_spec.rb
124
- - spec/rr/double/double_insertion_verify_spec.rb
125
- - spec/rr/double/double_insertion_spec.rb
126
- - spec/rr/double/double_insertion_register_scenario_spec.rb
127
- - spec/rr/double/double_insertion_reset_spec.rb
121
+ - spec/rr/double/double_injection_register_scenario_spec.rb
122
+ - spec/rr/double/double_injection_has_original_method_spec.rb
123
+ - spec/rr/double/double_injection_spec.rb
124
+ - spec/rr/double/double_injection_bind_spec.rb
125
+ - spec/rr/double/double_injection_dispatching_spec.rb
126
+ - spec/rr/double/double_injection_verify_spec.rb
127
+ - spec/rr/double/double_injection_reset_spec.rb
128
128
  - spec/rr/double_method_proxy_spec.rb
129
129
  - spec/rr/test_unit/test_unit_backtrace_test.rb
130
130
  - spec/rr/test_unit/test_helper.rb