rr 1.2.1 → 3.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.
- checksums.yaml +5 -5
- data/CHANGES.md +25 -0
- data/Gemfile +1 -8
- data/README.md +8 -13
- data/Rakefile +16 -6
- data/lib/rr/class_instance_method_defined.rb +1 -1
- data/lib/rr/double.rb +28 -10
- data/lib/rr/double_definitions/double_definition.rb +39 -16
- data/lib/rr/double_definitions/double_definition_create.rb +5 -5
- data/lib/rr/double_definitions/double_definition_create_blank_slate.rb +10 -4
- data/lib/rr/double_definitions/strategies/strategy.rb +27 -8
- data/lib/rr/double_definitions/strategies/verification/mock.rb +8 -2
- data/lib/rr/double_matches.rb +4 -3
- data/lib/rr/expectations/any_argument_expectation.rb +4 -4
- data/lib/rr/expectations/argument_equality_expectation.rb +43 -5
- data/lib/rr/injections/double_injection.rb +65 -18
- data/lib/rr/injections/method_missing_injection.rb +36 -9
- data/lib/rr/keyword_arguments.rb +15 -0
- data/lib/rr/method_dispatches/base_method_dispatch.rb +22 -5
- data/lib/rr/method_dispatches/method_dispatch.rb +21 -10
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +14 -5
- data/lib/rr/recorded_call.rb +9 -3
- data/lib/rr/recorded_calls.rb +17 -7
- data/lib/rr/space.rb +15 -5
- data/lib/rr/version.rb +1 -1
- data/lib/rr/without_autohook.rb +2 -1
- data/rr.gemspec +5 -0
- data/spec/suites.yml +1 -15
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +18 -18
- data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +9 -9
- data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +21 -21
- data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +4 -4
- data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +31 -21
- data/spec/suites/rspec_2/unit/space_spec.rb +4 -3
- metadata +61 -10
- data/lib/rr/proc_from_block.rb +0 -11
- data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +0 -14
- data/spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb +0 -142
- data/spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb +0 -149
- data/spec/suites/rspec_2_rails_4/spec_helper.rb +0 -3
@@ -7,20 +7,20 @@ module RR
|
|
7
7
|
attr_reader :expectation
|
8
8
|
|
9
9
|
before do
|
10
|
-
@expectation = ArgumentEqualityExpectation.new(boolean)
|
10
|
+
@expectation = ArgumentEqualityExpectation.new([boolean], {})
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#wildcard_match?" do
|
14
14
|
context "when passed a Boolean" do
|
15
15
|
it "returns true" do
|
16
|
-
expect(expectation).to be_wildcard_match(true)
|
17
|
-
expect(expectation).to be_wildcard_match(false)
|
16
|
+
expect(expectation).to be_wildcard_match([true], {})
|
17
|
+
expect(expectation).to be_wildcard_match([false], {})
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
context "when not passed a Boolean" do
|
22
22
|
it "returns false" do
|
23
|
-
expectation.should_not be_wildcard_match(:not_a_boolean)
|
23
|
+
expectation.should_not be_wildcard_match([:not_a_boolean], {})
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb
CHANGED
@@ -11,70 +11,80 @@ module Expectations
|
|
11
11
|
|
12
12
|
describe "#exact_match?" do
|
13
13
|
before do
|
14
|
-
@expectation = ArgumentEqualityExpectation.new(hash_including(expected_hash))
|
14
|
+
@expectation = ArgumentEqualityExpectation.new([hash_including(expected_hash)], {})
|
15
15
|
end
|
16
16
|
|
17
17
|
it "returns true when passed in a HashIncluding matcher with the same hash" do
|
18
|
-
expect(expectation).to be_exact_match(RR::WildcardMatchers::HashIncluding.new(expected_hash)
|
18
|
+
expect(expectation).to be_exact_match([RR::WildcardMatchers::HashIncluding.new(expected_hash)],
|
19
|
+
{})
|
19
20
|
end
|
20
21
|
|
21
22
|
it "returns false when passed in a HashIncluding matcher with a different argument list" do
|
22
|
-
expectation.should_not be_exact_match(RR::WildcardMatchers::HashIncluding.new(:foo => 1)
|
23
|
+
expectation.should_not be_exact_match([RR::WildcardMatchers::HashIncluding.new(:foo => 1)],
|
24
|
+
{})
|
23
25
|
end
|
24
26
|
|
25
27
|
it "returns false otherwise" do
|
26
|
-
expectation.should_not be_exact_match("hello")
|
27
|
-
expectation.should_not be_exact_match(:hello)
|
28
|
-
expectation.should_not be_exact_match(1)
|
29
|
-
expectation.should_not be_exact_match(nil)
|
30
|
-
expectation.should_not be_exact_match(true)
|
31
|
-
expectation.should_not be_exact_match()
|
28
|
+
expectation.should_not be_exact_match(["hello"], {})
|
29
|
+
expectation.should_not be_exact_match([:hello], {})
|
30
|
+
expectation.should_not be_exact_match([1], {})
|
31
|
+
expectation.should_not be_exact_match([nil], {})
|
32
|
+
expectation.should_not be_exact_match([true], {})
|
33
|
+
expectation.should_not be_exact_match([], {})
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
37
|
describe "#wildcard_match?" do
|
36
38
|
before do
|
37
|
-
@expectation = ArgumentEqualityExpectation.new(hash_including(expected_hash)
|
39
|
+
@expectation = ArgumentEqualityExpectation.new([hash_including(expected_hash)],
|
40
|
+
{})
|
38
41
|
end
|
39
42
|
|
40
43
|
it "returns true when hash contains same key/values as the expectation" do
|
41
|
-
expect(expectation).to be_wildcard_match(expected_hash)
|
44
|
+
expect(expectation).to be_wildcard_match([expected_hash], {})
|
42
45
|
end
|
43
46
|
|
44
47
|
it "returns true when hash contains at least expectation's key/values" do
|
45
|
-
expect(expectation).to be_wildcard_match(expected_hash.merge(:oregon => "Salem")
|
48
|
+
expect(expectation).to be_wildcard_match([expected_hash.merge(:oregon => "Salem")],
|
49
|
+
{})
|
46
50
|
end
|
47
51
|
|
48
52
|
it "returns true when passed the same hash, even after the original is modified" do
|
49
53
|
original_expected_hash = expected_hash.clone
|
50
54
|
expected_hash[:texas] = nil
|
51
|
-
expect(expectation).to be_wildcard_match(original_expected_hash)
|
55
|
+
expect(expectation).to be_wildcard_match([original_expected_hash], {})
|
52
56
|
end
|
53
57
|
|
54
58
|
it "returns true even if one of the expectation's values is nil" do
|
55
|
-
expectation = ArgumentEqualityExpectation.new(hash_including(:foo => nil)
|
56
|
-
|
59
|
+
expectation = ArgumentEqualityExpectation.new([hash_including(:foo => nil)],
|
60
|
+
{})
|
61
|
+
expect(expectation).to be_wildcard_match([{:foo => nil}],
|
62
|
+
{})
|
57
63
|
end
|
58
64
|
|
59
65
|
it "returns false when hash matches only some required key/values" do
|
60
|
-
expectation.should_not be_wildcard_match({:texas => "Austin"}
|
66
|
+
expectation.should_not be_wildcard_match([{:texas => "Austin"}],
|
67
|
+
{})
|
61
68
|
end
|
62
69
|
|
63
70
|
it "returns false when hash matches all the keys but not all the values" do
|
64
|
-
expectation.should_not be_wildcard_match({:texas => "Austin", :maine => "Portland"}
|
71
|
+
expectation.should_not be_wildcard_match([{:texas => "Austin", :maine => "Portland"}],
|
72
|
+
{})
|
65
73
|
end
|
66
74
|
|
67
75
|
it "returns false when passed a hash that matches all values but not all keys" do
|
68
|
-
expectation.should_not be_wildcard_match({:texas => "Austin", :georgia => "Augusta"}
|
76
|
+
expectation.should_not be_wildcard_match([{:texas => "Austin", :georgia => "Augusta"}],
|
77
|
+
{})
|
69
78
|
end
|
70
79
|
|
71
80
|
it "returns true when an exact match" do
|
72
|
-
expect(expectation).to be_wildcard_match(hash_including(expected_hash)
|
81
|
+
expect(expectation).to be_wildcard_match([hash_including(expected_hash)],
|
82
|
+
{})
|
73
83
|
end
|
74
84
|
|
75
85
|
it "returns false when not passed correct number of arguments" do
|
76
|
-
expectation.should_not be_wildcard_match()
|
77
|
-
expectation.should_not be_wildcard_match(:a, :b)
|
86
|
+
expectation.should_not be_wildcard_match([], {})
|
87
|
+
expectation.should_not be_wildcard_match([:a, :b], {})
|
78
88
|
end
|
79
89
|
end
|
80
90
|
end
|
@@ -13,9 +13,10 @@ module RR
|
|
13
13
|
object = Object.new
|
14
14
|
method_name = :to_s
|
15
15
|
arguments = []
|
16
|
-
|
16
|
+
keyword_arguments = {}
|
17
|
+
space.record_call(object, method_name, arguments, keyword_arguments, lambda {})
|
17
18
|
expect(space.recorded_calls[0]).to eq \
|
18
|
-
RR::RecordedCall.new(object, method_name, arguments, lambda {})
|
19
|
+
RR::RecordedCall.new(object, method_name, arguments, keyword_arguments, lambda {})
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
@@ -202,7 +203,7 @@ module RR
|
|
202
203
|
|
203
204
|
it "should clear the #recorded_calls" do
|
204
205
|
object = Object.new
|
205
|
-
space.record_call(object, :to_s, [], nil)
|
206
|
+
space.record_call(object, :to_s, [], {}, nil)
|
206
207
|
|
207
208
|
space.reset
|
208
209
|
expect(space.recorded_calls).to eq RR::RecordedCalls.new([])
|
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -10,8 +10,64 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
13
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: test-unit
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: test-unit-rr
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
15
71
|
description: RR is a test double framework that features a rich selection of double
|
16
72
|
techniques and a terse syntax.
|
17
73
|
email:
|
@@ -93,10 +149,10 @@ files:
|
|
93
149
|
- lib/rr/integrations/minitest_active_support.rb
|
94
150
|
- lib/rr/integrations/rspec/invocation_matcher.rb
|
95
151
|
- lib/rr/integrations/rspec_2.rb
|
152
|
+
- lib/rr/keyword_arguments.rb
|
96
153
|
- lib/rr/method_dispatches/base_method_dispatch.rb
|
97
154
|
- lib/rr/method_dispatches/method_dispatch.rb
|
98
155
|
- lib/rr/method_dispatches/method_missing_dispatch.rb
|
99
|
-
- lib/rr/proc_from_block.rb
|
100
156
|
- lib/rr/recorded_call.rb
|
101
157
|
- lib/rr/recorded_calls.rb
|
102
158
|
- lib/rr/space.rb
|
@@ -214,7 +270,6 @@ files:
|
|
214
270
|
- spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb
|
215
271
|
- spec/suites/rspec_2/unit/integrations/rspec/invocation_matcher_spec.rb
|
216
272
|
- spec/suites/rspec_2/unit/integrations/rspec_spec.rb
|
217
|
-
- spec/suites/rspec_2/unit/proc_from_block_spec.rb
|
218
273
|
- spec/suites/rspec_2/unit/rr_spec.rb
|
219
274
|
- spec/suites/rspec_2/unit/space_spec.rb
|
220
275
|
- spec/suites/rspec_2/unit/spy_verification_spec.rb
|
@@ -232,9 +287,6 @@ files:
|
|
232
287
|
- spec/suites/rspec_2/unit/wildcard_matchers/is_a_spec.rb
|
233
288
|
- spec/suites/rspec_2/unit/wildcard_matchers/numeric_spec.rb
|
234
289
|
- spec/suites/rspec_2/unit/wildcard_matchers/satisfy_spec.rb
|
235
|
-
- spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb
|
236
|
-
- spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb
|
237
|
-
- spec/suites/rspec_2_rails_4/spec_helper.rb
|
238
290
|
- spec/support/adapter.rb
|
239
291
|
- spec/support/adapter_tests/base.rb
|
240
292
|
- spec/support/adapter_tests/minitest.rb
|
@@ -310,8 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
310
362
|
- !ruby/object:Gem::Version
|
311
363
|
version: '0'
|
312
364
|
requirements: []
|
313
|
-
|
314
|
-
rubygems_version: 2.5.2
|
365
|
+
rubygems_version: 3.3.0.dev
|
315
366
|
signing_key:
|
316
367
|
specification_version: 4
|
317
368
|
summary: RR is a test double framework that features a rich selection of double techniques
|
data/lib/rr/proc_from_block.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
describe ProcFromBlock do
|
5
|
-
describe "#==" do
|
6
|
-
it "acts the same as #== on a Proc" do
|
7
|
-
original_proc = lambda {}
|
8
|
-
expect(Proc.new(&original_proc)).to eq original_proc
|
9
|
-
|
10
|
-
expect(ProcFromBlock.new(&original_proc)).to eq original_proc
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,142 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe 'Integration with straight ActiveSupport::TestCase and Rails 4' do
|
4
|
-
include IntegrationTests::RailsTestUnitLike
|
5
|
-
|
6
|
-
def configure_rails_project_generator(project_generator)
|
7
|
-
super
|
8
|
-
project_generator.configure do |project|
|
9
|
-
project.rails_version = 4
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.including_the_adapter_manually_works
|
14
|
-
specify "including the adapter manually works" do
|
15
|
-
project = generate_project do |project|
|
16
|
-
project.add_to_prelude <<-EOT
|
17
|
-
class ActiveSupport::TestCase
|
18
|
-
include RR::Adapters::TestUnit
|
19
|
-
end
|
20
|
-
EOT
|
21
|
-
end
|
22
|
-
project.add_test_file do |file|
|
23
|
-
file.add_working_test_case_with_adapter_tests do |test_case|
|
24
|
-
test_case.add_to_body <<-EOT
|
25
|
-
def test_the_correct_adapters_are_loaded
|
26
|
-
assert_adapters_loaded #{adapters_that_should_be_loaded.inspect}
|
27
|
-
end
|
28
|
-
EOT
|
29
|
-
end
|
30
|
-
end
|
31
|
-
result = project.run_tests
|
32
|
-
result.should be_success
|
33
|
-
result.should_not have_errors_or_failures
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.rr_hooks_into_the_test_framework_automatically
|
38
|
-
specify "RR hooks into the test framework automatically" do
|
39
|
-
project = generate_project
|
40
|
-
project.add_test_file do |file|
|
41
|
-
file.add_working_test_case
|
42
|
-
end
|
43
|
-
result = project.run_tests
|
44
|
-
result.should be_success
|
45
|
-
result.should_not have_errors_or_failures
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.using_rr_with_cucumber_works
|
50
|
-
specify "using RR with Cucumber works" do
|
51
|
-
pending "Cucumber doesn't work with Rails 4 just yet"
|
52
|
-
project_generator = build_rails_project_generator do |project_generator|
|
53
|
-
project_generator.mixin Project::Cucumber
|
54
|
-
end
|
55
|
-
project = project_generator.call
|
56
|
-
result = project.run_command_within("bundle exec cucumber")
|
57
|
-
result.should be_success
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when Bundler is autorequiring RR' do
|
62
|
-
def configure_project_generator(project_generator)
|
63
|
-
super
|
64
|
-
project_generator.configure do |project|
|
65
|
-
project.autorequire_gems = true
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def adapters_that_should_be_loaded
|
70
|
-
[:MiniTest4]
|
71
|
-
end
|
72
|
-
|
73
|
-
including_the_adapter_manually_works
|
74
|
-
using_rr_with_cucumber_works
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when RR is being required manually' do
|
78
|
-
def configure_project_generator(project_generator)
|
79
|
-
super
|
80
|
-
project_generator.configure do |project|
|
81
|
-
project.autorequire_gems = false
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def adapters_that_should_be_loaded
|
86
|
-
[:MiniTest4, :MiniTest4ActiveSupport]
|
87
|
-
end
|
88
|
-
|
89
|
-
rr_hooks_into_the_test_framework_automatically
|
90
|
-
including_the_adapter_manually_works
|
91
|
-
using_rr_with_cucumber_works
|
92
|
-
|
93
|
-
specify "when RR raises an error it raises a failure not an exception" do
|
94
|
-
project = generate_project
|
95
|
-
project.add_test_file do |file|
|
96
|
-
file.add_test_case do |test_case|
|
97
|
-
test_case.add_test <<-EOT
|
98
|
-
object = Object.new
|
99
|
-
mock(object).foo
|
100
|
-
EOT
|
101
|
-
end
|
102
|
-
end
|
103
|
-
result = project.run_tests
|
104
|
-
result.should fail_with_output(/1 failure/)
|
105
|
-
end
|
106
|
-
|
107
|
-
specify "the database is properly rolled back after an RR error" do
|
108
|
-
project = generate_project do |project|
|
109
|
-
project.add_model_and_migration(:person, :people, :name => :string)
|
110
|
-
end
|
111
|
-
project.add_test_file do |file|
|
112
|
-
file.add_test_case do |test_case|
|
113
|
-
test_case.add_test <<-EOT
|
114
|
-
Person.create!(:name => 'Joe Blow')
|
115
|
-
object = Object.new
|
116
|
-
mock(object).foo
|
117
|
-
EOT
|
118
|
-
end
|
119
|
-
end
|
120
|
-
expect {
|
121
|
-
result = project.run_tests
|
122
|
-
result.should have_errors_or_failures
|
123
|
-
}.to leave_database_table_clear(project, :people)
|
124
|
-
end
|
125
|
-
|
126
|
-
specify "throwing an error in teardown doesn't mess things up" do
|
127
|
-
project = generate_project
|
128
|
-
project.add_test_file do |file|
|
129
|
-
file.add_test_case do |test_case|
|
130
|
-
test_case.add_to_body <<-EOT
|
131
|
-
def teardown
|
132
|
-
raise 'hell'
|
133
|
-
end
|
134
|
-
EOT
|
135
|
-
test_case.add_test("") # doesn't matter
|
136
|
-
end
|
137
|
-
end
|
138
|
-
result = project.run_tests
|
139
|
-
result.should fail_with_output(/1 error/)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
@@ -1,149 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe 'Integration with MiniTest 4 and Rails 4' do
|
4
|
-
include IntegrationTests::RailsMinitest
|
5
|
-
|
6
|
-
def configure_rails_project_generator(project_generator)
|
7
|
-
super
|
8
|
-
project_generator.configure do |project|
|
9
|
-
project.rails_version = 4
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def configure_project_generator(project_generator)
|
14
|
-
super
|
15
|
-
project_generator.configure do |project|
|
16
|
-
project.minitest_version = 4
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.including_the_adapter_manually_works
|
21
|
-
specify "including the adapter manually works" do
|
22
|
-
project = generate_project do |project|
|
23
|
-
project.add_to_prelude <<-EOT
|
24
|
-
class ActiveSupport::TestCase
|
25
|
-
include RR::Adapters::MiniTest
|
26
|
-
end
|
27
|
-
EOT
|
28
|
-
end
|
29
|
-
project.add_test_file do |file|
|
30
|
-
file.add_working_test_case_with_adapter_tests do |test_case|
|
31
|
-
test_case.add_to_body <<-EOT
|
32
|
-
def test_the_correct_adapters_are_loaded
|
33
|
-
assert_adapters_loaded #{adapters_that_should_be_loaded.inspect}
|
34
|
-
end
|
35
|
-
EOT
|
36
|
-
end
|
37
|
-
end
|
38
|
-
result = project.run_tests
|
39
|
-
result.should be_success
|
40
|
-
result.should_not have_errors_or_failures
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.rr_hooks_into_the_test_framework_automatically
|
45
|
-
specify "RR hooks into the test framework automatically" do
|
46
|
-
project = generate_project
|
47
|
-
project.add_test_file do |file|
|
48
|
-
file.add_working_test_case
|
49
|
-
end
|
50
|
-
result = project.run_tests
|
51
|
-
result.should be_success
|
52
|
-
result.should_not have_errors_or_failures
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.using_rr_with_cucumber_works
|
57
|
-
specify "using RR with Cucumber works" do
|
58
|
-
pending "Cucumber doesn't work with Rails 4 just yet"
|
59
|
-
project_generator = build_rails_project_generator do |project_generator|
|
60
|
-
project_generator.mixin Project::Cucumber
|
61
|
-
end
|
62
|
-
project = project_generator.call
|
63
|
-
result = project.run_command_within("bundle exec cucumber")
|
64
|
-
result.should be_success
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'when Bundler is autorequiring RR' do
|
69
|
-
def configure_project_generator(project_generator)
|
70
|
-
super
|
71
|
-
project_generator.configure do |project|
|
72
|
-
project.autorequire_gems = true
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def adapters_that_should_be_loaded
|
77
|
-
[:MiniTest4]
|
78
|
-
end
|
79
|
-
|
80
|
-
including_the_adapter_manually_works
|
81
|
-
using_rr_with_cucumber_works
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'when RR is being required manually' do
|
85
|
-
def configure_project_generator(project_generator)
|
86
|
-
super
|
87
|
-
project_generator.configure do |project|
|
88
|
-
project.autorequire_gems = false
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def adapters_that_should_be_loaded
|
93
|
-
[:MiniTest4, :MiniTest4ActiveSupport]
|
94
|
-
end
|
95
|
-
|
96
|
-
rr_hooks_into_the_test_framework_automatically
|
97
|
-
including_the_adapter_manually_works
|
98
|
-
using_rr_with_cucumber_works
|
99
|
-
|
100
|
-
specify "when RR raises an error it raises a failure not an exception" do
|
101
|
-
project = generate_project
|
102
|
-
project.add_test_file do |file|
|
103
|
-
file.add_test_case do |test_case|
|
104
|
-
test_case.add_test <<-EOT
|
105
|
-
object = Object.new
|
106
|
-
mock(object).foo
|
107
|
-
EOT
|
108
|
-
end
|
109
|
-
end
|
110
|
-
result = project.run_tests
|
111
|
-
result.should fail_with_output(/1 failure/)
|
112
|
-
end
|
113
|
-
|
114
|
-
specify "the database is properly rolled back after an RR error" do
|
115
|
-
project = generate_project do |project|
|
116
|
-
project.add_model_and_migration(:person, :people, :name => :string)
|
117
|
-
end
|
118
|
-
project.add_test_file do |file|
|
119
|
-
file.add_test_case do |test_case|
|
120
|
-
test_case.add_test <<-EOT
|
121
|
-
Person.create!(:name => 'Joe Blow')
|
122
|
-
object = Object.new
|
123
|
-
mock(object).foo
|
124
|
-
EOT
|
125
|
-
end
|
126
|
-
end
|
127
|
-
expect {
|
128
|
-
result = project.run_tests
|
129
|
-
result.should have_errors_or_failures
|
130
|
-
}.to leave_database_table_clear(project, :people)
|
131
|
-
end
|
132
|
-
|
133
|
-
specify "throwing an error in teardown doesn't mess things up" do
|
134
|
-
project = generate_project
|
135
|
-
project.add_test_file do |file|
|
136
|
-
file.add_test_case do |test_case|
|
137
|
-
test_case.add_to_body <<-EOT
|
138
|
-
def teardown
|
139
|
-
raise 'hell'
|
140
|
-
end
|
141
|
-
EOT
|
142
|
-
test_case.add_test("") # doesn't matter
|
143
|
-
end
|
144
|
-
end
|
145
|
-
result = project.run_tests
|
146
|
-
result.should fail_with_output(/1 error/)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|