Skip to content

Commit

Permalink
fixup! Relax deprecation message wording
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Dec 2, 2020
1 parent e9375db commit 33a8a53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/rspec/expectations/expectation_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def enforce_value_expectation(matcher)
RSpec.deprecate(
"expect(value).to #{RSpec::Support::ObjectFormatter.format(matcher)}",
:message =>
"You must pass a block rather than an argument to `expect` to use the provided " \
"The implicit block expectation syntax is deprecated, you should pass " \
"a block rather than an argument to `expect` to use the provided " \
"block expectation matcher (#{RSpec::Support::ObjectFormatter.format(matcher)}), " \
"or the matcher must implement `supports_value_expectations?`."
)
Expand Down
12 changes: 10 additions & 2 deletions spec/support/shared_examples/block_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@
end

it 'prints a deprecation warning when given a value' do
expect_warn_deprecation(/You must pass a block/)
# NOTE: See #1233 for the explanation why
# expect_warn_deprecation(/The implicit block expectation syntax is deprecated, you should pass/)
# can't be used.
expect(RSpec.configuration.reporter).
to receive(:deprecation).with(include(message: match(/The implicit block expectation syntax is deprecated, you should pass/)))

expect { expect(3).to matcher }.to fail
end unless options[:skip_deprecation_check] || options[:expects_lambda]

it 'prints a deprecation warning when given a value and negated' do
expect_warn_deprecation(/You must pass a block/)
# NOTE: See #1233 for the explanation why `expect_warn_deprecation` can't be used
expect(RSpec.configuration.reporter).
to receive(:deprecation).with(include(message: match(/The implicit block expectation syntax is deprecated, you should pass/)))

expect { expect(3).not_to matcher }.to fail
end unless options[:disallows_negation] || options[:expects_lambda]

Expand Down

0 comments on commit 33a8a53

Please sign in to comment.