File tree 3 files changed +16
-11
lines changed
3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -181,5 +181,15 @@ def assertion_delegator
181
181
#
182
182
# @private
183
183
TestUnitAssertionAdapter = MinitestAssertionAdapter
184
+
185
+ # @private
186
+ module TaggedLoggingAdapter
187
+ require 'active_support/testing/tagged_logging'
188
+ include ActiveSupport ::Testing ::TaggedLogging
189
+
190
+ # Just a stub as TaggedLogging is calling `name`
191
+ def name
192
+ end
193
+ end
184
194
end
185
195
end
Original file line number Diff line number Diff line change @@ -12,11 +12,7 @@ module RailsExampleGroup
12
12
include RSpec ::Rails ::MinitestLifecycleAdapter
13
13
include RSpec ::Rails ::MinitestAssertionAdapter
14
14
include RSpec ::Rails ::FixtureSupport
15
-
16
- if ::Rails ::VERSION ::MAJOR >= 7
17
- require 'active_support/testing/tagged_logging'
18
- include ActiveSupport ::Testing ::TaggedLogging
19
- end
15
+ include RSpec ::Rails ::TaggedLoggingAdapter if ::Rails ::VERSION ::MAJOR >= 7
20
16
end
21
17
end
22
18
end
Original file line number Diff line number Diff line change 20
20
# Those Gemfiles carefully pick the right versions depending on
21
21
# settings in the ENV, `.rails-version` and `maintenance-branch`.
22
22
Dir . chdir ( '..' ) do
23
- eval_gemfile 'Gemfile-sqlite-dependencies'
24
23
# This Gemfile expects `maintenance-branch` file to be present
25
24
# in the current directory.
26
25
eval_gemfile 'Gemfile-rspec-dependencies'
44
43
# This connection will do for database-independent bug reports
45
44
ActiveRecord ::Base . establish_connection ( adapter : "sqlite3" , database : ":memory:" )
46
45
46
+ class TestError < StandardError ; end
47
+
47
48
class TestJob < ActiveJob ::Base
48
- def perform ; end
49
+ def perform
50
+ raise TestError
51
+ end
49
52
end
50
53
51
- class TestError < StandardError ; end
52
-
53
54
RSpec . describe 'Foo' , type : :job do
54
55
include ::ActiveJob ::TestHelper
55
56
56
57
describe 'error raised in perform_enqueued_jobs with block' do
57
58
it 'raises the explicitly thrown error' do
58
- allow_any_instance_of ( TestJob ) . to receive ( :perform ) . and_raise ( TestError )
59
-
60
59
# Rails 6.1+ wraps unexpected errors in tests
61
60
expected_error = if Rails ::VERSION ::STRING . to_f >= 6.1
62
61
Minitest ::UnexpectedError . new ( TestError )
You can’t perform that action at this time.
0 commit comments