rr 1.1.0.rc1 → 1.1.0.rc2

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rr/adapters.rb +64 -0
  4. data/lib/rr/autohook.rb +6 -13
  5. data/lib/rr/integrations.rb +7 -0
  6. data/lib/rr/{adapters → integrations}/minitest.rb +4 -4
  7. data/lib/rr/{adapters → integrations}/minitest_active_support.rb +4 -4
  8. data/lib/rr/{adapters → integrations}/none.rb +1 -1
  9. data/lib/rr/{adapters → integrations}/rspec/invocation_matcher.rb +9 -1
  10. data/lib/rr/{adapters → integrations}/rspec_1.rb +4 -4
  11. data/lib/rr/{adapters → integrations}/rspec_2.rb +3 -3
  12. data/lib/rr/{adapters → integrations}/test_unit_1.rb +4 -4
  13. data/lib/rr/{adapters → integrations}/test_unit_2.rb +1 -1
  14. data/lib/rr/{adapters → integrations}/test_unit_2_active_support.rb +3 -3
  15. data/lib/rr/without_autohook.rb +11 -9
  16. data/spec/suites/common/adapter_integration_tests.rb +88 -0
  17. data/spec/suites/common/rails_integration_test.rb +0 -51
  18. data/spec/suites/rspec_1/integration/rspec_1_spec.rb +59 -4
  19. data/spec/suites/rspec_1/integration/test_unit_1_rails_spec.rb +36 -1
  20. data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +45 -0
  21. data/spec/suites/rspec_1/integration/test_unit_2_rails_spec.rb +60 -3
  22. data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +64 -0
  23. data/spec/suites/rspec_2/integration/minitest_rails_spec.rb +56 -3
  24. data/spec/suites/rspec_2/integration/minitest_spec.rb +59 -0
  25. data/spec/suites/rspec_2/integration/rspec_2_spec.rb +109 -4
  26. data/spec/suites/rspec_2/integration/test_unit_rails_spec.rb +57 -3
  27. data/spec/suites/rspec_2/integration/test_unit_spec.rb +59 -0
  28. data/spec/suites/rspec_2/unit/{adapters → integrations}/rspec/invocation_matcher_spec.rb +1 -1
  29. data/spec/suites/rspec_2/unit/{adapters → integrations}/rspec_spec.rb +6 -6
  30. metadata +27 -15
@@ -1,8 +1,16 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
  require File.expand_path('../../../common/adapter_tests', __FILE__)
3
+ require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
4
 
4
5
  describe 'Integration with RSpec 2' do
5
6
  include AdapterTests
7
+ instance_methods.each do |method_name|
8
+ if method_name =~ /^test_(.+)$/
9
+ it(method_name) { __send__(method_name) }
10
+ end
11
+ end
12
+
13
+ include AdapterIntegrationTests
6
14
 
7
15
  def assert_equal(expected, actual)
8
16
  expect(actual).to eq actual
@@ -12,9 +20,106 @@ describe 'Integration with RSpec 2' do
12
20
  expect(&block).to raise_error(error, message)
13
21
  end
14
22
 
15
- instance_methods.each do |method_name|
16
- if method_name =~ /^test_(.+)$/
17
- it(method_name) { __send__(method_name) }
18
- end
23
+ def test_framework_path
24
+ 'rspec/autorun'
25
+ end
26
+
27
+ def error_test
28
+ <<-EOT
29
+ #{bootstrap}
30
+
31
+ describe 'A test' do
32
+ it 'is a test' do
33
+ object = Object.new
34
+ mock(object).foo
35
+ end
36
+ end
37
+ EOT
38
+ end
39
+
40
+ def include_adapter_test
41
+ <<-EOT
42
+ #{bootstrap}
43
+
44
+ RSpec.configure do |c|
45
+ c.mock_with :rr
46
+ end
47
+
48
+ describe 'A test' do
49
+ it 'is a test' do
50
+ object = Object.new
51
+ mock(object).foo
52
+ object.foo
53
+ end
54
+ end
55
+ EOT
56
+ end
57
+
58
+ def include_adapter_where_rr_included_before_test_framework_test
59
+ <<-EOT
60
+ #{bootstrap :include_rr_before => true}
61
+
62
+ RSpec.configure do |c|
63
+ c.mock_with :rr
64
+ end
65
+
66
+ describe 'A test' do
67
+ it 'is a test' do
68
+ object = Object.new
69
+ mock(object).foo
70
+ object.foo
71
+ end
72
+ end
73
+ EOT
74
+ end
75
+
76
+ specify "it is still possible to use a custom RSpec-2 adapter" do
77
+ output = run_fixture_tests <<-EOT
78
+ #{bootstrap}
79
+
80
+ module RR
81
+ module Adapters
82
+ module RSpec2
83
+ include RRMethods
84
+
85
+ def setup_mocks_for_rspec
86
+ RR.reset
87
+ end
88
+
89
+ def verify_mocks_for_rspec
90
+ RR.verify
91
+ end
92
+
93
+ def teardown_mocks_for_rspec
94
+ RR.reset
95
+ end
96
+
97
+ def have_received(method = nil)
98
+ RR::Adapters::Rspec::InvocationMatcher.new(method)
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ RSpec.configure do |c|
105
+ c.mock_with RR::Adapters::RSpec2
106
+ end
107
+
108
+ describe 'RR' do
109
+ specify 'mocks work' do
110
+ object = Object.new
111
+ mock(object).foo
112
+ object.foo
113
+ end
114
+
115
+ specify 'have_received works' do
116
+ object = Object.new
117
+ stub(object).foo
118
+ object.foo
119
+ object.should have_received.foo
120
+ end
121
+ end
122
+ EOT
123
+ all_tests_should_pass(output)
19
124
  end
20
125
  end
@@ -1,14 +1,68 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+ require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
1
3
  require File.expand_path('../../../common/rails_integration_test', __FILE__)
2
4
 
3
5
  describe 'Integration between TestUnit and Rails' do
6
+ include AdapterIntegrationTests
4
7
  include IntegrationWithRails
5
8
 
6
- def bootstrap
9
+ def additional_bootstrap
7
10
  <<-EOT
8
- require 'rubygems'
9
- require 'test/unit'
10
11
  require 'rails'
11
12
  require 'active_support'
12
13
  EOT
13
14
  end
15
+
16
+ def test_framework_path
17
+ 'test/unit'
18
+ end
19
+
20
+ def error_test
21
+ <<-EOT
22
+ #{bootstrap}
23
+
24
+ class FooTest < ActiveSupport::TestCase
25
+ def test_foo
26
+ object = Object.new
27
+ mock(object).foo
28
+ end
29
+ end
30
+ EOT
31
+ end
32
+
33
+ def include_adapter_test
34
+ <<-EOT
35
+ #{bootstrap}
36
+
37
+ class ActiveSupport::TestCase
38
+ include RR::Adapters::TestUnit
39
+ end
40
+
41
+ class FooTest < ActiveSupport::TestCase
42
+ def test_foo
43
+ object = Object.new
44
+ mock(object).foo
45
+ object.foo
46
+ end
47
+ end
48
+ EOT
49
+ end
50
+
51
+ def include_adapter_where_rr_included_before_test_framework_test
52
+ <<-EOT
53
+ #{bootstrap :include_rr_before => true}
54
+
55
+ class ActiveSupport::TestCase
56
+ include RR::Adapters::TestUnit
57
+ end
58
+
59
+ class FooTest < ActiveSupport::TestCase
60
+ def test_foo
61
+ object = Object.new
62
+ mock(object).foo
63
+ object.foo
64
+ end
65
+ end
66
+ EOT
67
+ end
14
68
  end
@@ -0,0 +1,59 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+ require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
+
4
+ describe 'TestUnit integration' do
5
+ include AdapterIntegrationTests
6
+
7
+ def test_framework_path
8
+ 'test/unit'
9
+ end
10
+
11
+ def error_test
12
+ <<-EOT
13
+ #{bootstrap}
14
+
15
+ class FooTest < Test::Unit::TestCase
16
+ def test_foo
17
+ object = Object.new
18
+ mock(object).foo
19
+ end
20
+ end
21
+ EOT
22
+ end
23
+
24
+ def include_adapter_test
25
+ <<-EOT
26
+ #{bootstrap}
27
+
28
+ class Test::Unit::TestCase
29
+ include RR::Adapters::TestUnit
30
+ end
31
+
32
+ class FooTest < Test::Unit::TestCase
33
+ def test_foo
34
+ object = Object.new
35
+ mock(object).foo
36
+ object.foo
37
+ end
38
+ end
39
+ EOT
40
+ end
41
+
42
+ def include_adapter_where_rr_included_before_test_framework_test
43
+ <<-EOT
44
+ #{bootstrap :include_rr_before => true}
45
+
46
+ class Test::Unit::TestCase
47
+ include RR::Adapters::TestUnit
48
+ end
49
+
50
+ class FooTest < Test::Unit::TestCase
51
+ def test_foo
52
+ object = Object.new
53
+ mock(object).foo
54
+ object.foo
55
+ end
56
+ end
57
+ EOT
58
+ end
59
+ end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
2
 
3
3
  module RR
4
- module Adapters
4
+ module Integrations
5
5
  module RSpec
6
6
  describe InvocationMatcher do
7
7
  describe "matching against a method with no doubles" do
@@ -1,7 +1,7 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
2
2
 
3
3
  module RR
4
- module Adapters
4
+ module Integrations
5
5
  describe RSpec1 do
6
6
  attr_reader :fixture, :method_name
7
7
 
@@ -10,7 +10,7 @@ module RR
10
10
 
11
11
  before do
12
12
  @fixture = Object.new
13
- fixture.extend RSpec1::AdapterMethods
13
+ fixture.extend RSpec1::Mixin
14
14
  @method_name = :foobar
15
15
  end
16
16
 
@@ -28,7 +28,7 @@ module RR
28
28
 
29
29
  before do
30
30
  @fixture = Object.new
31
- fixture.extend RSpec1::AdapterMethods
31
+ fixture.extend RSpec1::Mixin
32
32
  @method_name = :foobar
33
33
  end
34
34
 
@@ -47,7 +47,7 @@ module RR
47
47
 
48
48
  before do
49
49
  @fixture = Object.new
50
- fixture.extend RSpec1::AdapterMethods
50
+ fixture.extend RSpec1::Mixin
51
51
  @method_name = :foobar
52
52
  end
53
53
 
@@ -70,13 +70,13 @@ module RR
70
70
  it "creates an invocation matcher with a method name" do
71
71
  method = :test
72
72
  matcher = 'fake'
73
- mock(RR::Adapters::RSpec::InvocationMatcher).new(method) { matcher }
73
+ mock(RR::Integrations::RSpec::InvocationMatcher).new(method) { matcher }
74
74
  expect(have_received(method)).to eq matcher
75
75
  end
76
76
 
77
77
  it "creates an invocation matcher without a method name" do
78
78
  matcher = 'fake'
79
- mock(RR::Adapters::RSpec::InvocationMatcher).new(nil) { matcher }
79
+ mock(RR::Integrations::RSpec::InvocationMatcher).new(nil) { matcher }
80
80
  expect(have_received).to eq matcher
81
81
  end
82
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.rc1
4
+ version: 1.1.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Takita
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-09 00:00:00.000000000 Z
12
+ date: 2013-05-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: RR is a double framework that features a rich selection of double techniques
15
15
  and a terse syntax.
@@ -24,16 +24,8 @@ files:
24
24
  - README.md
25
25
  - VERSION
26
26
  - lib/rr.rb
27
- - lib/rr/adapters/minitest.rb
28
- - lib/rr/adapters/minitest_active_support.rb
29
- - lib/rr/adapters/none.rb
27
+ - lib/rr/adapters.rb
30
28
  - lib/rr/adapters/rr_methods.rb
31
- - lib/rr/adapters/rspec/invocation_matcher.rb
32
- - lib/rr/adapters/rspec_1.rb
33
- - lib/rr/adapters/rspec_2.rb
34
- - lib/rr/adapters/test_unit_1.rb
35
- - lib/rr/adapters/test_unit_2.rb
36
- - lib/rr/adapters/test_unit_2_active_support.rb
37
29
  - lib/rr/autohook.rb
38
30
  - lib/rr/blank_slate.rb
39
31
  - lib/rr/class_instance_method_defined.rb
@@ -82,6 +74,16 @@ files:
82
74
  - lib/rr/injections/injection.rb
83
75
  - lib/rr/injections/method_missing_injection.rb
84
76
  - lib/rr/injections/singleton_method_added_injection.rb
77
+ - lib/rr/integrations.rb
78
+ - lib/rr/integrations/minitest.rb
79
+ - lib/rr/integrations/minitest_active_support.rb
80
+ - lib/rr/integrations/none.rb
81
+ - lib/rr/integrations/rspec/invocation_matcher.rb
82
+ - lib/rr/integrations/rspec_1.rb
83
+ - lib/rr/integrations/rspec_2.rb
84
+ - lib/rr/integrations/test_unit_1.rb
85
+ - lib/rr/integrations/test_unit_2.rb
86
+ - lib/rr/integrations/test_unit_2_active_support.rb
85
87
  - lib/rr/method_dispatches/base_method_dispatch.rb
86
88
  - lib/rr/method_dispatches/method_dispatch.rb
87
89
  - lib/rr/method_dispatches/method_missing_dispatch.rb
@@ -113,6 +115,7 @@ files:
113
115
  - rr.gemspec
114
116
  - spec/global_helper.rb
115
117
  - spec/suite.rb
118
+ - spec/suites/common/adapter_integration_tests.rb
116
119
  - spec/suites/common/adapter_tests.rb
117
120
  - spec/suites/common/rails_integration_test.rb
118
121
  - spec/suites/common/test_unit_tests.rb
@@ -120,7 +123,9 @@ files:
120
123
  - spec/suites/minitest/test_helper.rb
121
124
  - spec/suites/rspec_1/integration/rspec_1_spec.rb
122
125
  - spec/suites/rspec_1/integration/test_unit_1_rails_spec.rb
126
+ - spec/suites/rspec_1/integration/test_unit_1_spec.rb
123
127
  - spec/suites/rspec_1/integration/test_unit_2_rails_spec.rb
128
+ - spec/suites/rspec_1/integration/test_unit_2_spec.rb
124
129
  - spec/suites/rspec_1/spec_helper.rb
125
130
  - spec/suites/rspec_2/functional/any_instance_of_spec.rb
126
131
  - spec/suites/rspec_2/functional/dont_allow_spec.rb
@@ -133,8 +138,10 @@ files:
133
138
  - spec/suites/rspec_2/functional/stub_spec.rb
134
139
  - spec/suites/rspec_2/functional/wildcard_matchers_spec.rb
135
140
  - spec/suites/rspec_2/integration/minitest_rails_spec.rb
141
+ - spec/suites/rspec_2/integration/minitest_spec.rb
136
142
  - spec/suites/rspec_2/integration/rspec_2_spec.rb
137
143
  - spec/suites/rspec_2/integration/test_unit_rails_spec.rb
144
+ - spec/suites/rspec_2/integration/test_unit_spec.rb
138
145
  - spec/suites/rspec_2/spec_helper.rb
139
146
  - spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb
140
147
  - spec/suites/rspec_2/support/shared_examples/space.rb
@@ -142,8 +149,6 @@ files:
142
149
  - spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb
143
150
  - spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb
144
151
  - spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb
145
- - spec/suites/rspec_2/unit/adapters/rspec/invocation_matcher_spec.rb
146
- - spec/suites/rspec_2/unit/adapters/rspec_spec.rb
147
152
  - spec/suites/rspec_2/unit/core_ext/array_spec.rb
148
153
  - spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb
149
154
  - spec/suites/rspec_2/unit/core_ext/hash_spec.rb
@@ -168,6 +173,8 @@ files:
168
173
  - spec/suites/rspec_2/unit/hash_with_object_id_key_spec.rb
169
174
  - spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb
170
175
  - spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb
176
+ - spec/suites/rspec_2/unit/integrations/rspec/invocation_matcher_spec.rb
177
+ - spec/suites/rspec_2/unit/integrations/rspec_spec.rb
171
178
  - spec/suites/rspec_2/unit/proc_from_block_spec.rb
172
179
  - spec/suites/rspec_2/unit/rr_spec.rb
173
180
  - spec/suites/rspec_2/unit/space_spec.rb
@@ -218,6 +225,7 @@ summary: RR is a double framework that features a rich selection of double techn
218
225
  test_files:
219
226
  - spec/global_helper.rb
220
227
  - spec/suite.rb
228
+ - spec/suites/common/adapter_integration_tests.rb
221
229
  - spec/suites/common/adapter_tests.rb
222
230
  - spec/suites/common/rails_integration_test.rb
223
231
  - spec/suites/common/test_unit_tests.rb
@@ -225,7 +233,9 @@ test_files:
225
233
  - spec/suites/minitest/test_helper.rb
226
234
  - spec/suites/rspec_1/integration/rspec_1_spec.rb
227
235
  - spec/suites/rspec_1/integration/test_unit_1_rails_spec.rb
236
+ - spec/suites/rspec_1/integration/test_unit_1_spec.rb
228
237
  - spec/suites/rspec_1/integration/test_unit_2_rails_spec.rb
238
+ - spec/suites/rspec_1/integration/test_unit_2_spec.rb
229
239
  - spec/suites/rspec_1/spec_helper.rb
230
240
  - spec/suites/rspec_2/functional/any_instance_of_spec.rb
231
241
  - spec/suites/rspec_2/functional/dont_allow_spec.rb
@@ -238,8 +248,10 @@ test_files:
238
248
  - spec/suites/rspec_2/functional/stub_spec.rb
239
249
  - spec/suites/rspec_2/functional/wildcard_matchers_spec.rb
240
250
  - spec/suites/rspec_2/integration/minitest_rails_spec.rb
251
+ - spec/suites/rspec_2/integration/minitest_spec.rb
241
252
  - spec/suites/rspec_2/integration/rspec_2_spec.rb
242
253
  - spec/suites/rspec_2/integration/test_unit_rails_spec.rb
254
+ - spec/suites/rspec_2/integration/test_unit_spec.rb
243
255
  - spec/suites/rspec_2/spec_helper.rb
244
256
  - spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb
245
257
  - spec/suites/rspec_2/support/shared_examples/space.rb
@@ -247,8 +259,6 @@ test_files:
247
259
  - spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb
248
260
  - spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb
249
261
  - spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb
250
- - spec/suites/rspec_2/unit/adapters/rspec/invocation_matcher_spec.rb
251
- - spec/suites/rspec_2/unit/adapters/rspec_spec.rb
252
262
  - spec/suites/rspec_2/unit/core_ext/array_spec.rb
253
263
  - spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb
254
264
  - spec/suites/rspec_2/unit/core_ext/hash_spec.rb
@@ -273,6 +283,8 @@ test_files:
273
283
  - spec/suites/rspec_2/unit/hash_with_object_id_key_spec.rb
274
284
  - spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb
275
285
  - spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb
286
+ - spec/suites/rspec_2/unit/integrations/rspec/invocation_matcher_spec.rb
287
+ - spec/suites/rspec_2/unit/integrations/rspec_spec.rb
276
288
  - spec/suites/rspec_2/unit/proc_from_block_spec.rb
277
289
  - spec/suites/rspec_2/unit/rr_spec.rb
278
290
  - spec/suites/rspec_2/unit/space_spec.rb