DEV: Add option to disable rspec diff truncation ENV var (#19861)

Sometimes you may have a large string or object that you are comparing
with some expectation, and you want to see the full diff between actual
and expected without rspec truncating 90% of the diff. Setting the
max_formatted_output_length to nil disables this truncation completely.

c.f. https://www.rubydoc.info/gems/rspec-expectations/RSpec/Expectations/Configuration#max_formatted_output_length=-instance_method

Use `RSPEC_DISABLE_DIFF_TRUNCATION=1` to disable this.
This commit is contained in:
Martin Brennan 2023-01-13 13:31:28 +10:00 committed by GitHub
parent 8ee71d439b
commit b4b8b03461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -190,6 +190,18 @@ RSpec.configure do |config|
# instead of true.
config.use_transactional_fixtures = true
# Sometimes you may have a large string or object that you are comparing
# with some expectation, and you want to see the full diff between actual
# and expected without rspec truncating 90% of the diff. Setting the
# max_formatted_output_length to nil disables this truncation completely.
#
# c.f. https://www.rubydoc.info/gems/rspec-expectations/RSpec/Expectations/Configuration#max_formatted_output_length=-instance_method
if ENV["RSPEC_DISABLE_DIFF_TRUNCATION"]
config.expect_with :rspec do |expectation|
expectation.max_formatted_output_length = nil
end
end
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.