Skip to content

Commit

Permalink
Add documentation for RSpec/ExampleLength configuration option `Cou…
Browse files Browse the repository at this point in the history
…ntAsOne: [method_call]`

Fix: #1728
  • Loading branch information
ydah committed Oct 3, 2023
1 parent 7b930a0 commit 11e9bc6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
16 changes: 11 additions & 5 deletions docs/modules/ROOT/pages/cops_rspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1542,9 +1542,10 @@ A long example is usually more difficult to understand. Consider
extracting out some behavior, e.g. with a `let` block, or a helper
method.

You can set literals you want to fold with `CountAsOne`.
Available are: 'array', 'hash', and 'heredoc'. Each literal
will be counted as one line regardless of its actual size.
You can set constructs you want to fold with `CountAsOne`.
Available are: 'array', 'hash', 'heredoc', and 'method_call'.
Each construct will be counted as one line regardless of
its actual size.

=== Examples

Expand All @@ -1567,7 +1568,7 @@ it do
end
----

==== CountAsOne: ['array', 'heredoc']
==== CountAsOne: ['array', 'heredoc', 'method_call']

[source,ruby]
----
Expand All @@ -1585,7 +1586,12 @@ it do
Heredoc
content.
HEREDOC
end # 5 points
foo( # +1
1,
2
)
end # 6 points
----

=== Configurable attributes
Expand Down
16 changes: 11 additions & 5 deletions lib/rubocop/cop/rspec/example_length.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ module RSpec
# expect(result).to be(true)
# end
#
# You can set literals you want to fold with `CountAsOne`.
# Available are: 'array', 'hash', and 'heredoc'. Each literal
# will be counted as one line regardless of its actual size.
# You can set constructs you want to fold with `CountAsOne`.
# Available are: 'array', 'hash', 'heredoc', and 'method_call'.
# Each construct will be counted as one line regardless of
# its actual size.
#
# @example CountAsOne: ['array', 'heredoc']
# @example CountAsOne: ['array', 'heredoc', 'method_call']
#
# it do
# array = [ # +1
Expand All @@ -46,7 +47,12 @@ module RSpec
# Heredoc
# content.
# HEREDOC
# end # 5 points
#
# foo( # +1
# 1,
# 2
# )
# end # 6 points
#
class ExampleLength < Base
include CodeLength
Expand Down
2 changes: 1 addition & 1 deletion rubocop-rspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
'rubygems_mfa_required' => 'true'
}

spec.add_runtime_dependency 'rubocop', '~> 1.33'
spec.add_runtime_dependency 'rubocop', '~> 1.40'
spec.add_runtime_dependency 'rubocop-capybara', '~> 2.17'
spec.add_runtime_dependency 'rubocop-factory_bot', '~> 2.22'
end

0 comments on commit 11e9bc6

Please sign in to comment.