File tree Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -3822,11 +3822,21 @@ Checks for stubbed test subjects.
3822
3822
[source,ruby]
3823
3823
----
3824
3824
# bad
3825
- describe Foo do
3826
- subject(:bar ) { baz }
3825
+ describe Article do
3826
+ subject(:article ) { Article.new }
3827
3827
3828
- before do
3829
- allow(bar).to receive(:qux?).and_return(true)
3828
+ it 'indicates that the author is unknown' do
3829
+ allow(article).to receive(:author).and_return(nil)
3830
+ expect(article.description).to include('by an unknown author')
3831
+ end
3832
+ end
3833
+
3834
+ # good
3835
+ describe Article do
3836
+ subject(:article) { Article.new(author: nil) }
3837
+
3838
+ it 'indicates that the author is unknown' do
3839
+ expect(article.description).to include('by an unknown author')
3830
3840
end
3831
3841
end
3832
3842
----
Original file line number Diff line number Diff line change @@ -13,11 +13,21 @@ module RSpec
13
13
#
14
14
# @example
15
15
# # bad
16
- # describe Foo do
17
- # subject(:bar ) { baz }
16
+ # describe Article do
17
+ # subject(:article ) { Article.new }
18
18
#
19
- # before do
20
- # allow(bar).to receive(:qux?).and_return(true)
19
+ # it 'indicates that the author is unknown' do
20
+ # allow(article).to receive(:author).and_return(nil)
21
+ # expect(article.description).to include('by an unknown author')
22
+ # end
23
+ # end
24
+ #
25
+ # # good
26
+ # describe Article do
27
+ # subject(:article) { Article.new(author: nil) }
28
+ #
29
+ # it 'indicates that the author is unknown' do
30
+ # expect(article.description).to include('by an unknown author')
21
31
# end
22
32
# end
23
33
#
You can’t perform that action at this time.
0 commit comments