@@ -12,8 +12,6 @@ module MemoizedHelpers
1212 #
1313 # RSpec.describe Widget do
1414 # it { is_expected.to validate_presence_of(:name) }
15- # # or
16- # it { should validate_presence_of(:name) }
1715 # end
1816 #
1917 # While the examples below demonstrate how to use `subject`
@@ -25,32 +23,28 @@ module MemoizedHelpers
2523 # # Explicit declaration of subject.
2624 # RSpec.describe Person do
2725 # subject { Person.new(:birthdate => 19.years.ago) }
28- # it "should be eligible to vote" do
29- # should be_eligible_to_vote
26+ # it "is eligible to vote" do
27+ # is_expected.to be_eligible_to_vote
3028 # end
3129 # end
3230 #
3331 # # Implicit subject => { Person.new }.
3432 # RSpec.describe Person do
35- # it "should be eligible to vote" do
36- # should be_eligible_to_vote
33+ # it "is eligible to vote" do
34+ # is_expected.to be_eligible_to_vote
3735 # end
3836 # end
3937 #
4038 # # One-liner syntax - expectation is set on the subject.
4139 # RSpec.describe Person do
4240 # it { is_expected.to be_eligible_to_vote }
43- # # or
44- # it { should be_eligible_to_vote }
4541 # end
4642 #
4743 # @note Because `subject` is designed to create state that is reset
4844 # between each example, and `before(:context)` is designed to setup
4945 # state that is shared across _all_ examples in an example group,
5046 # `subject` is _not_ intended to be used in a `before(:context)` hook.
5147 #
52- # @see #should
53- # @see #should_not
5448 # @see #is_expected
5549 def subject
5650 __memoized . fetch_or_store ( :subject ) do
@@ -59,45 +53,6 @@ def subject
5953 end
6054 end
6155
62- # When `should` is called with no explicit receiver, the call is
63- # delegated to the object returned by `subject`. Combined with an
64- # implicit subject this supports very concise expressions.
65- #
66- # @example
67- #
68- # RSpec.describe Person do
69- # it { should be_eligible_to_vote }
70- # end
71- #
72- # @see #subject
73- # @see #is_expected
74- #
75- # @note This only works if you are using rspec-expectations.
76- # @note If you are using RSpec's newer expect-based syntax you may
77- # want to use `is_expected.to` instead of `should`.
78- def should ( matcher = nil , message = nil )
79- RSpec ::Expectations ::PositiveExpectationHandler . handle_matcher ( subject , matcher , message )
80- end
81-
82- # Just like `should`, `should_not` delegates to the subject (implicit or
83- # explicit) of the example group.
84- #
85- # @example
86- #
87- # RSpec.describe Person do
88- # it { should_not be_eligible_to_vote }
89- # end
90- #
91- # @see #subject
92- # @see #is_expected
93- #
94- # @note This only works if you are using rspec-expectations.
95- # @note If you are using RSpec's newer expect-based syntax you may
96- # want to use `is_expected.to_not` instead of `should_not`.
97- def should_not ( matcher = nil , message = nil )
98- RSpec ::Expectations ::NegativeExpectationHandler . handle_matcher ( subject , matcher , message )
99- end
100-
10156 # Wraps the `subject` in `expect` to make it the target of an expectation.
10257 # Designed to read nicely for one-liners.
10358 #
@@ -109,8 +64,6 @@ def should_not(matcher=nil, message=nil)
10964 # end
11065 #
11166 # @see #subject
112- # @see #should
113- # @see #should_not
11467 #
11568 # @note This only works if you are using rspec-expectations.
11669 def is_expected
@@ -410,8 +363,6 @@ def let!(name, &block)
410363 # end
411364 # end
412365 #
413- # @see MemoizedHelpers#should
414- # @see MemoizedHelpers#should_not
415366 # @see MemoizedHelpers#is_expected
416367 def subject ( name = nil , &block )
417368 if name
0 commit comments