Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 64b7ad3

Browse files
committed
Prevent should from circumventing target check
By directly instantiating expectation handler, should/should_not was circumventing enforce_value_expectation check. subject(:action) { -> { raise } } it { should raise_error StandardError } would not print "The implicit block expectation syntax is deprecated", while subject(:action) { -> { raise } } it { is_expected.to raise_error StandardError } will. See rspec/rspec-expectations#1139
1 parent a9c7b9c commit 64b7ad3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/rspec/core/memoized_helpers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def subject
7878
# @note If you are using RSpec's newer expect-based syntax you may
7979
# want to use `is_expected.to` instead of `should`.
8080
def should(matcher=nil, message=nil)
81-
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
81+
is_expected.to(matcher, message)
8282
end
8383

8484
# Just like `should`, `should_not` delegates to the subject (implicit or
@@ -97,7 +97,7 @@ def should(matcher=nil, message=nil)
9797
# @note If you are using RSpec's newer expect-based syntax you may
9898
# want to use `is_expected.to_not` instead of `should_not`.
9999
def should_not(matcher=nil, message=nil)
100-
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
100+
is_expected.not_to(matcher, message)
101101
end
102102

103103
# Wraps the `subject` in `expect` to make it the target of an expectation.

0 commit comments

Comments
 (0)