Module: RuboCop::RSpec::Language
Overview
Contains node matchers for common RSpec DSL.
RSpec allows for configuring aliases for commonly used DSL elements, e.g. example groups and hooks. It is possible to configure RuboCop RSpec to be able to properly detect these elements in the `RSpec/Language` section of the RuboCop YAML configuration file.
In addition to providing useful matchers, this class is responsible for using the configured aliases.
Defined Under Namespace
Modules: Helpers, HookScopes, NodePattern, Subjects
Class Attribute Summary collapse
Instance Method Summary
collapse
block_pattern, send_pattern
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
19
20
21
|
# File 'lib/rubocop/rspec/language.rb', line 19
def config
@config
end
|
Instance Method Details
#example?(node) ⇒ Object
41
|
# File 'lib/rubocop/rspec/language.rb', line 41
def_node_matcher :example?, block_pattern('#Examples.all')
|
#example_group?(node) ⇒ Object
26
|
# File 'lib/rubocop/rspec/language.rb', line 26
def_node_matcher :example_group?, block_pattern('#ExampleGroups.all')
|
#example_group_with_body?(node) ⇒ Object
36
37
38
|
# File 'lib/rubocop/rspec/language.rb', line 36
def_node_matcher :example_group_with_body?, <<-PATTERN
(block #{send_pattern('#ExampleGroups.all')} args !nil?)
PATTERN
|
#hook?(node) ⇒ Object
44
|
# File 'lib/rubocop/rspec/language.rb', line 44
def_node_matcher :hook?, block_pattern('#Hooks.all')
|
#include?(node) ⇒ Object
55
56
57
58
59
60
|
# File 'lib/rubocop/rspec/language.rb', line 55
def_node_matcher :include?, <<-PATTERN
{
#{send_pattern('#Includes.all')}
#{block_pattern('#Includes.all')}
}
PATTERN
|
#let?(node) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/rubocop/rspec/language.rb', line 47
def_node_matcher :let?, <<-PATTERN
{
#{block_pattern('#Helpers.all')}
(send #rspec? #Helpers.all _ block_pass)
}
PATTERN
|
#rspec?(node) ⇒ Object
23
|
# File 'lib/rubocop/rspec/language.rb', line 23
def_node_matcher :rspec?, '{(const {nil? cbase} :RSpec) nil?}'
|
#shared_group?(node) ⇒ Object
29
|
# File 'lib/rubocop/rspec/language.rb', line 29
def_node_matcher :shared_group?, block_pattern('#SharedGroups.all')
|
#spec_group?(node) ⇒ Object
32
33
|
# File 'lib/rubocop/rspec/language.rb', line 32
def_node_matcher :spec_group?,
block_pattern('{#SharedGroups.all #ExampleGroups.all}')
|
#subject?(node) ⇒ Object
63
|
# File 'lib/rubocop/rspec/language.rb', line 63
def_node_matcher :subject?, block_pattern('#Subjects.all')
|