rr 1.1.0 → 1.1.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +138 -102
- data/README.md +27 -23
- data/VERSION +1 -1
- data/lib/rr/adapters.rb +2 -19
- data/lib/rr/autohook.rb +3 -29
- data/lib/rr/integrations.rb +44 -2
- data/lib/rr/integrations/decorator.rb +40 -0
- data/lib/rr/integrations/minitest.rb +2 -0
- data/lib/rr/integrations/minitest_4.rb +3 -0
- data/lib/rr/integrations/minitest_4_active_support.rb +2 -0
- data/lib/rr/integrations/minitest_active_support.rb +2 -0
- data/lib/rr/integrations/rspec_1.rb +5 -1
- data/lib/rr/integrations/rspec_2.rb +5 -1
- data/lib/rr/integrations/test_unit_1.rb +11 -2
- data/lib/rr/integrations/test_unit_2.rb +3 -1
- data/lib/rr/integrations/test_unit_200.rb +27 -0
- data/lib/rr/integrations/test_unit_200_active_support.rb +25 -0
- data/lib/rr/integrations/test_unit_2_active_support.rb +6 -3
- data/lib/rr/without_autohook.rb +10 -4
- data/spec/global_helper.rb +45 -4
- data/spec/spec.opts +2 -0
- data/spec/suite.rb +23 -7
- data/spec/suites/common/adapter_integration_tests.rb +94 -31
- data/spec/suites/common/adapter_tests.rb +6 -0
- data/spec/suites/common/{rails_integration_test.rb → rails_integration_tests.rb} +40 -58
- data/spec/suites/minitest/integration/minitest_test.rb +5 -5
- data/spec/suites/minitest/test_helper.rb +5 -1
- data/spec/suites/minitest_4/integration/minitest_test.rb +13 -0
- data/spec/suites/minitest_4/test_helper.rb +7 -0
- data/spec/suites/rspec_1/helper.rb +24 -0
- data/spec/suites/rspec_1/integration/rspec_1_spec.rb +20 -18
- data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +10 -14
- data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +11 -18
- data/spec/suites/rspec_1/spec_helper.rb +2 -23
- data/spec/suites/{rspec_1/integration/test_unit_1_rails_spec.rb → rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb} +15 -16
- data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +57 -0
- data/spec/suites/rspec_1_rails_2/spec_helper.rb +3 -0
- data/spec/suites/rspec_2/helper.rb +27 -0
- data/spec/suites/rspec_2/integration/minitest_4_spec.rb +8 -18
- data/spec/suites/rspec_2/integration/minitest_spec.rb +8 -10
- data/spec/suites/rspec_2/integration/rspec_2_spec.rb +22 -21
- data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +57 -0
- data/spec/suites/rspec_2/integration/{test_unit_spec.rb → test_unit_2_spec.rb} +9 -11
- data/spec/suites/rspec_2/spec_helper.rb +2 -26
- data/spec/suites/{rspec_2/integration/minitest_4_rails_spec.rb → rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb} +12 -18
- data/spec/suites/{rspec_2/integration/test_unit_rails_spec.rb → rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb} +16 -18
- data/spec/suites/{rspec_1/integration/test_unit_2_rails_spec.rb → rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb} +19 -28
- data/spec/suites/rspec_2_rails_3/spec_helper.rb +3 -0
- data/spec/suites/{rspec_2/integration/minitest_rails_spec.rb → rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb} +14 -16
- data/spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb +156 -0
- data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +66 -0
- data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +66 -0
- data/spec/suites/rspec_2_rails_4/spec_helper.rb +3 -0
- data/spec/suites/test_unit_1/integration/test_unit_1_test.rb +4 -0
- data/spec/suites/test_unit_1/test_helper.rb +4 -1
- data/spec/suites/test_unit_2/integration/test_unit_2_test.rb +4 -0
- data/spec/suites/test_unit_2/test_helper.rb +5 -2
- data/spec/suites/test_unit_200/integration/test_unit_200_test.rb +10 -0
- data/spec/suites/test_unit_200/test_helper.rb +6 -0
- data/spec/suites/test_unit_200_rails_3/integration/test_unit_200_rails_3_test.rb +10 -0
- data/spec/suites/test_unit_200_rails_3/test_helper.rb +7 -0
- data/spec/suites/test_unit_200_rails_4/integration/test_unit_200_rails_4_test.rb +10 -0
- data/spec/suites/test_unit_200_rails_4/test_helper.rb +7 -0
- data/spec/suites/test_unit_2_rails_2/integration/test_unit_2_rails_2_test.rb +10 -0
- data/spec/suites/test_unit_2_rails_2/test_helper.rb +7 -0
- data/spec/suites/test_unit_2_rails_3/integration/test_unit_2_rails_3_test.rb +10 -0
- data/spec/suites/test_unit_2_rails_3/test_helper.rb +7 -0
- data/spec/suites/test_unit_2_rails_4/integration/test_unit_2_rails_4_test.rb +10 -0
- data/spec/suites/test_unit_2_rails_4/test_helper.rb +7 -0
- metadata +71 -19
- data/lib/rr/integrations/none.rb +0 -17
@@ -1,23 +1,25 @@
|
|
1
1
|
require File.expand_path('../../spec_helper', __FILE__)
|
2
2
|
require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
|
3
|
-
require File.expand_path('../../../common/
|
3
|
+
require File.expand_path('../../../common/rails_integration_tests', __FILE__)
|
4
4
|
|
5
|
-
describe 'Integration
|
6
|
-
def
|
7
|
-
|
8
|
-
require 'rails'
|
9
|
-
require 'active_support'
|
10
|
-
EOT
|
5
|
+
describe 'Integration with MiniTest 4 and Rails 4' do
|
6
|
+
def adapter_name
|
7
|
+
'minitest_4_rails_3'
|
11
8
|
end
|
12
9
|
|
13
10
|
def test_framework_path
|
14
11
|
'minitest/autorun'
|
15
12
|
end
|
16
13
|
|
17
|
-
def
|
14
|
+
def before_require_test_framework
|
18
15
|
<<-EOT
|
19
|
-
|
16
|
+
require 'rails'
|
17
|
+
require 'active_support'
|
18
|
+
EOT
|
19
|
+
end
|
20
20
|
|
21
|
+
def error_test
|
22
|
+
with_bootstrap <<-EOT
|
21
23
|
class FooTest < ActiveSupport::TestCase
|
22
24
|
def test_foo
|
23
25
|
object = Object.new
|
@@ -28,9 +30,7 @@ describe 'Integration between MiniTest and Rails' do
|
|
28
30
|
end
|
29
31
|
|
30
32
|
def include_adapter_test
|
31
|
-
<<-EOT
|
32
|
-
#{bootstrap}
|
33
|
-
|
33
|
+
with_bootstrap <<-EOT
|
34
34
|
class ActiveSupport::TestCase
|
35
35
|
include RR::Adapters::MiniTest
|
36
36
|
end
|
@@ -46,9 +46,7 @@ describe 'Integration between MiniTest and Rails' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def include_adapter_where_rr_included_before_test_framework_test
|
49
|
-
<<-EOT
|
50
|
-
#{bootstrap :include_rr_before => true}
|
51
|
-
|
49
|
+
with_bootstrap <<-EOT, :include_rr_before_test_framework => true
|
52
50
|
class ActiveSupport::TestCase
|
53
51
|
include RR::Adapters::MiniTest
|
54
52
|
end
|
@@ -64,5 +62,5 @@ describe 'Integration between MiniTest and Rails' do
|
|
64
62
|
end
|
65
63
|
|
66
64
|
include AdapterIntegrationTests
|
67
|
-
include
|
65
|
+
include RailsIntegrationTests
|
68
66
|
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../../../common/adapter_tests', __FILE__)
|
3
|
+
require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
|
4
|
+
require File.expand_path('../../../common/rails_integration_tests', __FILE__)
|
5
|
+
|
6
|
+
describe 'Integration with RSpec 2 and Rails 4' do
|
7
|
+
def assert_equal(expected, actual)
|
8
|
+
expect(actual).to eq actual
|
9
|
+
end
|
10
|
+
|
11
|
+
def assert_raise(error, message=nil, &block)
|
12
|
+
expect(&block).to raise_error(error, message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def adapter_name
|
16
|
+
'rspec_2_rails_4'
|
17
|
+
end
|
18
|
+
|
19
|
+
def applicable_adapter_names
|
20
|
+
[:RSpec2]
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_framework_path
|
24
|
+
%w(rspec/autorun rspec/rails)
|
25
|
+
end
|
26
|
+
|
27
|
+
def before_require_test_framework
|
28
|
+
<<-EOT
|
29
|
+
require 'rails/all'
|
30
|
+
#require 'active_support'
|
31
|
+
#require 'active_support/test_case'
|
32
|
+
EOT
|
33
|
+
end
|
34
|
+
|
35
|
+
def after_require_test_framework
|
36
|
+
<<-EOT
|
37
|
+
RSpec.configure do |c|
|
38
|
+
c.use_transactional_fixtures = true
|
39
|
+
end
|
40
|
+
EOT
|
41
|
+
end
|
42
|
+
|
43
|
+
def error_test
|
44
|
+
with_bootstrap <<-EOT
|
45
|
+
describe 'A test' do
|
46
|
+
it 'is a test' do
|
47
|
+
object = Object.new
|
48
|
+
mock(object).foo
|
49
|
+
end
|
50
|
+
end
|
51
|
+
EOT
|
52
|
+
end
|
53
|
+
|
54
|
+
def include_adapter_test
|
55
|
+
with_bootstrap <<-EOT
|
56
|
+
RSpec.configure do |c|
|
57
|
+
c.mock_with :rr
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'A test' do
|
61
|
+
it 'is a test' do
|
62
|
+
object = Object.new
|
63
|
+
mock(object).foo
|
64
|
+
object.foo
|
65
|
+
end
|
66
|
+
end
|
67
|
+
EOT
|
68
|
+
end
|
69
|
+
|
70
|
+
def include_adapter_where_rr_included_before_test_framework_test
|
71
|
+
with_bootstrap <<-EOT, :include_rr_before_test_framework => true
|
72
|
+
RSpec.configure do |c|
|
73
|
+
c.mock_with :rr
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'A test' do
|
77
|
+
it 'is a test' do
|
78
|
+
object = Object.new
|
79
|
+
mock(object).foo
|
80
|
+
object.foo
|
81
|
+
end
|
82
|
+
end
|
83
|
+
EOT
|
84
|
+
end
|
85
|
+
|
86
|
+
def database_properly_rolled_back_test
|
87
|
+
with_active_record_bootstrap <<-EOT
|
88
|
+
describe Person do
|
89
|
+
it 'is a test' do
|
90
|
+
Person.create!(:name => 'Joe Blow')
|
91
|
+
object = Object.new
|
92
|
+
mock(object).foo
|
93
|
+
end
|
94
|
+
end
|
95
|
+
EOT
|
96
|
+
end
|
97
|
+
|
98
|
+
specify "it is still possible to use a custom RSpec-2 adapter" do
|
99
|
+
suite = with_bootstrap <<-EOT
|
100
|
+
module RR
|
101
|
+
module Adapters
|
102
|
+
module RSpec2
|
103
|
+
include RRMethods
|
104
|
+
|
105
|
+
def setup_mocks_for_rspec
|
106
|
+
RR.reset
|
107
|
+
end
|
108
|
+
|
109
|
+
def verify_mocks_for_rspec
|
110
|
+
RR.verify
|
111
|
+
end
|
112
|
+
|
113
|
+
def teardown_mocks_for_rspec
|
114
|
+
RR.reset
|
115
|
+
end
|
116
|
+
|
117
|
+
def have_received(method = nil)
|
118
|
+
RR::Adapters::Rspec::InvocationMatcher.new(method)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
RSpec.configure do |c|
|
125
|
+
c.mock_with RR::Adapters::RSpec2
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'RR' do
|
129
|
+
specify 'mocks work' do
|
130
|
+
object = Object.new
|
131
|
+
mock(object).foo
|
132
|
+
object.foo
|
133
|
+
end
|
134
|
+
|
135
|
+
specify 'have_received works' do
|
136
|
+
object = Object.new
|
137
|
+
stub(object).foo
|
138
|
+
object.foo
|
139
|
+
object.should have_received.foo
|
140
|
+
end
|
141
|
+
end
|
142
|
+
EOT
|
143
|
+
output = run_fixture_tests(suite)
|
144
|
+
all_tests_should_pass(output)
|
145
|
+
end
|
146
|
+
|
147
|
+
include AdapterTests
|
148
|
+
instance_methods.each do |method_name|
|
149
|
+
if method_name =~ /^test_(.+)$/
|
150
|
+
it(method_name) { __send__(method_name) }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
include AdapterIntegrationTests
|
155
|
+
include RailsIntegrationTests
|
156
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
|
3
|
+
require File.expand_path('../../../common/rails_integration_tests', __FILE__)
|
4
|
+
|
5
|
+
describe 'Integration with Test::Unit 2.0.0 and Rails 4' do
|
6
|
+
def adapter_name
|
7
|
+
'test_unit_2_rails_3'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_framework_path
|
11
|
+
'test/unit'
|
12
|
+
end
|
13
|
+
|
14
|
+
def before_require_test_framework
|
15
|
+
<<-EOT
|
16
|
+
require 'rails'
|
17
|
+
require 'active_support'
|
18
|
+
EOT
|
19
|
+
end
|
20
|
+
|
21
|
+
def error_test
|
22
|
+
with_bootstrap <<-EOT
|
23
|
+
class FooTest < ActiveSupport::TestCase
|
24
|
+
def test_foo
|
25
|
+
object = Object.new
|
26
|
+
mock(object).foo
|
27
|
+
end
|
28
|
+
end
|
29
|
+
EOT
|
30
|
+
end
|
31
|
+
|
32
|
+
def include_adapter_test
|
33
|
+
with_bootstrap <<-EOT
|
34
|
+
class ActiveSupport::TestCase
|
35
|
+
include RR::Adapters::TestUnit
|
36
|
+
end
|
37
|
+
|
38
|
+
class FooTest < ActiveSupport::TestCase
|
39
|
+
def test_foo
|
40
|
+
object = Object.new
|
41
|
+
mock(object).foo
|
42
|
+
object.foo
|
43
|
+
end
|
44
|
+
end
|
45
|
+
EOT
|
46
|
+
end
|
47
|
+
|
48
|
+
def include_adapter_where_rr_included_before_test_framework_test
|
49
|
+
with_bootstrap <<-EOT, :include_rr_before => true
|
50
|
+
class ActiveSupport::TestCase
|
51
|
+
include RR::Adapters::TestUnit
|
52
|
+
end
|
53
|
+
|
54
|
+
class FooTest < ActiveSupport::TestCase
|
55
|
+
def test_foo
|
56
|
+
object = Object.new
|
57
|
+
mock(object).foo
|
58
|
+
object.foo
|
59
|
+
end
|
60
|
+
end
|
61
|
+
EOT
|
62
|
+
end
|
63
|
+
|
64
|
+
include AdapterIntegrationTests
|
65
|
+
include RailsIntegrationTests
|
66
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
|
3
|
+
require File.expand_path('../../../common/rails_integration_tests', __FILE__)
|
4
|
+
|
5
|
+
describe 'Integration with Test::Unit >= 2.5 and Rails 4' do
|
6
|
+
def adapter_name
|
7
|
+
'test_unit_2_rails_3'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_framework_path
|
11
|
+
'test/unit'
|
12
|
+
end
|
13
|
+
|
14
|
+
def before_require_test_framework
|
15
|
+
<<-EOT
|
16
|
+
require 'rails'
|
17
|
+
require 'active_support'
|
18
|
+
EOT
|
19
|
+
end
|
20
|
+
|
21
|
+
def error_test
|
22
|
+
with_bootstrap <<-EOT
|
23
|
+
class FooTest < ActiveSupport::TestCase
|
24
|
+
def test_foo
|
25
|
+
object = Object.new
|
26
|
+
mock(object).foo
|
27
|
+
end
|
28
|
+
end
|
29
|
+
EOT
|
30
|
+
end
|
31
|
+
|
32
|
+
def include_adapter_test
|
33
|
+
with_bootstrap <<-EOT
|
34
|
+
class ActiveSupport::TestCase
|
35
|
+
include RR::Adapters::TestUnit
|
36
|
+
end
|
37
|
+
|
38
|
+
class FooTest < ActiveSupport::TestCase
|
39
|
+
def test_foo
|
40
|
+
object = Object.new
|
41
|
+
mock(object).foo
|
42
|
+
object.foo
|
43
|
+
end
|
44
|
+
end
|
45
|
+
EOT
|
46
|
+
end
|
47
|
+
|
48
|
+
def include_adapter_where_rr_included_before_test_framework_test
|
49
|
+
with_bootstrap <<-EOT, :include_rr_before => true
|
50
|
+
class ActiveSupport::TestCase
|
51
|
+
include RR::Adapters::TestUnit
|
52
|
+
end
|
53
|
+
|
54
|
+
class FooTest < ActiveSupport::TestCase
|
55
|
+
def test_foo
|
56
|
+
object = Object.new
|
57
|
+
mock(object).foo
|
58
|
+
object.foo
|
59
|
+
end
|
60
|
+
end
|
61
|
+
EOT
|
62
|
+
end
|
63
|
+
|
64
|
+
include AdapterIntegrationTests
|
65
|
+
include RailsIntegrationTests
|
66
|
+
end
|
@@ -2,5 +2,9 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
require File.expand_path('../../../common/test_unit_tests', __FILE__)
|
3
3
|
|
4
4
|
class TestUnitIntegrationTest < Test::Unit::TestCase
|
5
|
+
def applicable_adapter_names
|
6
|
+
[:TestUnit1]
|
7
|
+
end
|
8
|
+
|
5
9
|
include TestUnitTests
|
6
10
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
require File.expand_path('../../../global_helper', __FILE__)
|
2
|
+
RR::Test.setup_test_suite(:test_unit_1)
|
3
|
+
|
1
4
|
require 'test/unit'
|
2
5
|
begin; require 'test/unit/version'; rescue LoadError; end
|
3
6
|
if defined?(::Test::Unit::VERSION)
|
4
7
|
raise "You seem to have Test::Unit 2.x loaded!"
|
5
8
|
end
|
6
9
|
|
7
|
-
require
|
10
|
+
require 'rr'
|
@@ -2,5 +2,9 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
require File.expand_path('../../../common/test_unit_tests', __FILE__)
|
3
3
|
|
4
4
|
class TestUnitIntegrationTest < Test::Unit::TestCase
|
5
|
+
def applicable_adapter_names
|
6
|
+
[:TestUnit2]
|
7
|
+
end
|
8
|
+
|
5
9
|
include TestUnitTests
|
6
10
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
require File.expand_path('../../../common/test_unit_tests', __FILE__)
|
3
|
+
|
4
|
+
class TestUnitIntegrationTest < Test::Unit::TestCase
|
5
|
+
def applicable_adapter_names
|
6
|
+
[:TestUnit200, :MiniTest4]
|
7
|
+
end
|
8
|
+
|
9
|
+
include TestUnitTests
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
require File.expand_path('../../../common/test_unit_tests', __FILE__)
|
3
|
+
|
4
|
+
class TestUnit200Rails3IntegrationTest < ActiveSupport::TestCase
|
5
|
+
def applicable_adapter_names
|
6
|
+
[:TestUnit200, :TestUnit200ActiveSupport, :MiniTest4, :MiniTest4ActiveSupport]
|
7
|
+
end
|
8
|
+
|
9
|
+
include TestUnitTests
|
10
|
+
end
|