Skip to content

Commit 6e14dcf

Browse files
committed
Map internal ActiveSupport test helpers call to rspec-rails method
This method has been moved in rails/rails@3cece0b We do not include ActiveSupport::Testing::Assertion at the moment. To avoid having to deal with complicated scenarios like Minitest errors. We redefine our own methods in rspec-rails. Related: rails/rails#40780
1 parent 46f8e89 commit 6e14dcf

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

lib/rspec/rails.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Load the rspec-rails parts
99
require 'rspec/rails/view_rendering'
1010
require 'rspec/rails/matchers'
11+
require 'rspec/rails/active_support_testing_assertion'
1112
require 'rspec/rails/fixture_support'
1213
require 'rspec/rails/file_fixture_support'
1314
require 'rspec/rails/fixture_file_upload_support'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module RSpec
2+
module Rails
3+
# @private
4+
# In Rails 6.1 some methods from ActiveSupport::Testcase
5+
# has been moved to ActiveSupport::Testing::Assertion.
6+
# Few of them are required in different scenarios.
7+
module ActiveSupportTestingAssertion
8+
def assert_nothing_raised(&block)
9+
expect(&block).to_not raise_error
10+
end
11+
end
12+
end
13+
end

lib/rspec/rails/configuration.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
8585
config.include RSpec::Rails::FileFixtureSupport
8686
end
8787

88+
if ::Rails.version.to_f >= 6.1
89+
config.include RSpec::Rails::ActiveSupportTestingAssertion
90+
end
91+
8892
# Add support for fixture_path on fixture_file_upload
8993
config.include RSpec::Rails::FixtureFileUploadSupport
9094

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module RSpec::Rails
2+
RSpec.describe ActiveSupportTestingAssertion do
3+
it 'assert_nothing_raised is not undefined' do
4+
expect {
5+
assert_nothing_raised do
6+
:foo
7+
end
8+
}.to_not raise_error
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)