Skip to content

Commit

Permalink
Merge pull request #1155 from tejasbubane/implicit-subject-missing-doc
Browse files Browse the repository at this point in the history
Add missing documentation for `single_statement_only` style of `RSpec/ImplicitSubject` cop
  • Loading branch information
pirj authored May 21, 2021
2 parents 78d1ae4 + 35fe00b commit a01cc07
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Master (Unreleased)

* Add missing documentation for `single_statement_only` style of `RSpec/ImplicitSubject` cop. ([@tejasbubane][])

## 2.3.0 (2021-04-28)

* Allow `RSpec/ContextWording` to accept multi-word prefixes. ([@hosamaly][])
Expand Down
22 changes: 21 additions & 1 deletion docs/modules/ROOT/pages/cops_rspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ This cop can be configured using the `EnforcedStyle` option

=== Examples

==== `EnforcedStyle: single_line_only`
==== `EnforcedStyle: single_line_only` (default)

[source,ruby]
----
Expand All @@ -1843,6 +1843,26 @@ it do
end
----

==== `EnforcedStyle: single_statement_only`

[source,ruby]
----
# bad
it do
foo = 1
is_expected.to be_truthy
end
# good
it do
foo = 1
expect(subject).to be_truthy
end
it do
is_expected.to be_truthy
end
----

==== `EnforcedStyle: disallow`

[source,ruby]
Expand Down
18 changes: 17 additions & 1 deletion lib/rubocop/cop/rspec/implicit_subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module RSpec
#
# This cop can be configured using the `EnforcedStyle` option
#
# @example `EnforcedStyle: single_line_only`
# @example `EnforcedStyle: single_line_only` (default)
# # bad
# it do
# is_expected.to be_truthy
Expand All @@ -19,6 +19,22 @@ module RSpec
# expect(subject).to be_truthy
# end
#
# @example `EnforcedStyle: single_statement_only`
# # bad
# it do
# foo = 1
# is_expected.to be_truthy
# end
#
# # good
# it do
# foo = 1
# expect(subject).to be_truthy
# end
# it do
# is_expected.to be_truthy
# end
#
# @example `EnforcedStyle: disallow`
# # bad
# it { is_expected.to be_truthy }
Expand Down

0 comments on commit a01cc07

Please sign in to comment.