Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

it { should matcher } delegates directly to ExpectationHandler.

Not only is this cleaner, but it also makes it feasible to turn of the
global 'should' (see #119).
  • Loading branch information...
commit b93433d97f58976f50a26920c29b112b901322bc 1 parent 1e8c6e0
@dchelimsky dchelimsky authored
Showing with 3 additions and 5 deletions.
  1. +3 −5 lib/rspec/core/subject.rb
View
8 lib/rspec/core/subject.rb
@@ -36,9 +36,7 @@ def subject
end
begin
- require 'rspec/expectations/extensions/kernel'
- alias_method :__should_for_example_group__, :should
- alias_method :__should_not_for_example_group__, :should_not
+ require 'rspec/expectations/handler'
# When +should+ is called with no explicit receiver, the call is
# delegated to the object returned by +subject+. Combined with
@@ -51,7 +49,7 @@ def subject
# it { should be_eligible_to_vote }
# end
def should(matcher=nil, message=nil)
- self == subject ? self.__should_for_example_group__(matcher) : subject.should(matcher,message)
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
end
# Just like +should+, +should_not+ delegates to the subject (implicit or
@@ -63,7 +61,7 @@ def should(matcher=nil, message=nil)
# it { should_not be_eligible_to_vote }
# end
def should_not(matcher=nil, message=nil)
- self == subject ? self.__should_not_for_example_group__(matcher) : subject.should_not(matcher,message)
+ RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
end
rescue LoadError
end

1 comment on commit b93433d

@dchelimsky
Owner

The commit comment is in reference to rspec/rspec-expectations#119 (not in rspec-core).

Please sign in to comment.
Something went wrong with that request. Please try again.