rubocop-rspec 1.32.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/config/default.yml +6 -0
- data/lib/rubocop-rspec.rb +3 -0
- data/lib/rubocop/cop/rspec/align_left_let_brace.rb +1 -1
- data/lib/rubocop/cop/rspec/align_right_let_brace.rb +1 -1
- data/lib/rubocop/cop/rspec/any_instance.rb +3 -1
- data/lib/rubocop/cop/rspec/around_block.rb +4 -2
- data/lib/rubocop/cop/rspec/be.rb +4 -2
- data/lib/rubocop/cop/rspec/be_eql.rb +3 -1
- data/lib/rubocop/cop/rspec/before_after_all.rb +1 -1
- data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +5 -3
- data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +3 -3
- data/lib/rubocop/cop/rspec/context_wording.rb +2 -2
- data/lib/rubocop/cop/rspec/describe_class.rb +4 -4
- data/lib/rubocop/cop/rspec/describe_method.rb +2 -2
- data/lib/rubocop/cop/rspec/describe_symbol.rb +2 -2
- data/lib/rubocop/cop/rspec/described_class.rb +3 -3
- data/lib/rubocop/cop/rspec/dialect.rb +76 -0
- data/lib/rubocop/cop/rspec/empty_example_group.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_final_let.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_hook.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +1 -1
- data/lib/rubocop/cop/rspec/example_length.rb +1 -1
- data/lib/rubocop/cop/rspec/example_without_description.rb +2 -2
- data/lib/rubocop/cop/rspec/example_wording.rb +2 -2
- data/lib/rubocop/cop/rspec/expect_actual.rb +1 -1
- data/lib/rubocop/cop/rspec/expect_change.rb +2 -2
- data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -1
- data/lib/rubocop/cop/rspec/expect_output.rb +1 -1
- data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +21 -40
- data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +2 -2
- data/lib/rubocop/cop/rspec/file_path.rb +2 -2
- data/lib/rubocop/cop/rspec/focus.rb +3 -3
- data/lib/rubocop/cop/rspec/hook_argument.rb +4 -6
- data/lib/rubocop/cop/rspec/hooks_before_examples.rb +2 -5
- data/lib/rubocop/cop/rspec/implicit_expect.rb +2 -2
- data/lib/rubocop/cop/rspec/implicit_subject.rb +1 -1
- data/lib/rubocop/cop/rspec/instance_spy.rb +1 -1
- data/lib/rubocop/cop/rspec/instance_variable.rb +1 -1
- data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +4 -2
- data/lib/rubocop/cop/rspec/it_behaves_like.rb +1 -1
- data/lib/rubocop/cop/rspec/iterated_expectation.rb +3 -1
- data/lib/rubocop/cop/rspec/leading_subject.rb +1 -2
- data/lib/rubocop/cop/rspec/let_before_examples.rb +2 -5
- data/lib/rubocop/cop/rspec/let_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/message_chain.rb +3 -1
- data/lib/rubocop/cop/rspec/message_expectation.rb +1 -1
- data/lib/rubocop/cop/rspec/message_spies.rb +3 -4
- data/lib/rubocop/cop/rspec/missing_example_group_argument.rb +1 -1
- data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -1
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +1 -1
- data/lib/rubocop/cop/rspec/multiple_subjects.rb +6 -2
- data/lib/rubocop/cop/rspec/named_subject.rb +1 -1
- data/lib/rubocop/cop/rspec/nested_groups.rb +3 -4
- data/lib/rubocop/cop/rspec/not_to_not.rb +3 -1
- data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/pending.rb +3 -3
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +17 -14
- data/lib/rubocop/cop/rspec/rails/http_status.rb +2 -2
- data/lib/rubocop/cop/rspec/receive_counts.rb +5 -6
- data/lib/rubocop/cop/rspec/receive_never.rb +4 -7
- data/lib/rubocop/cop/rspec/repeated_description.rb +3 -1
- data/lib/rubocop/cop/rspec/repeated_example.rb +3 -1
- data/lib/rubocop/cop/rspec/return_from_stub.rb +2 -2
- data/lib/rubocop/cop/rspec/scattered_let.rb +1 -1
- data/lib/rubocop/cop/rspec/scattered_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/shared_context.rb +2 -2
- data/lib/rubocop/cop/rspec/shared_examples.rb +7 -7
- data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +3 -1
- data/lib/rubocop/cop/rspec/subject_stub.rb +1 -1
- data/lib/rubocop/cop/rspec/unspecified_exception.rb +5 -3
- data/lib/rubocop/cop/rspec/verified_doubles.rb +2 -2
- data/lib/rubocop/cop/rspec/void_expect.rb +1 -1
- data/lib/rubocop/cop/rspec/yield.rb +2 -4
- data/lib/rubocop/cop/rspec_cops.rb +3 -0
- data/lib/rubocop/rspec.rb +2 -0
- data/lib/rubocop/rspec/blank_line_separation.rb +3 -1
- data/lib/rubocop/rspec/config_formatter.rb +3 -1
- data/lib/rubocop/rspec/description_extractor.rb +3 -1
- data/lib/rubocop/rspec/factory_bot.rb +58 -0
- data/lib/rubocop/rspec/final_end_location.rb +2 -0
- data/lib/rubocop/rspec/inject.rb +2 -0
- data/lib/rubocop/rspec/language.rb +9 -2
- data/lib/rubocop/rspec/top_level_describe.rb +2 -0
- data/lib/rubocop/rspec/version.rb +1 -1
- data/rubocop-rspec.gemspec +3 -1
- data/spec/project/changelog_spec.rb +2 -0
- data/spec/project/default_config_spec.rb +2 -0
- data/spec/project/project_requires_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +22 -37
- data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +21 -36
- data/spec/rubocop/cop/rspec/any_instance_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/around_block_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/be_eql_spec.rb +25 -4
- data/spec/rubocop/cop/rspec/be_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/before_after_all_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/context_wording_spec.rb +32 -0
- data/spec/rubocop/cop/rspec/describe_class_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/describe_method_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/described_class_spec.rb +4 -1
- data/spec/rubocop/cop/rspec/dialect_spec.rb +78 -0
- data/spec/rubocop/cop/rspec/empty_line_after_example_group_spec.rb +40 -21
- data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +77 -69
- data/spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb +24 -19
- data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +16 -19
- data/spec/rubocop/cop/rspec/example_length_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/example_without_description_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/example_wording_spec.rb +45 -24
- data/spec/rubocop/cop/rspec/expect_change_spec.rb +22 -14
- data/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb +36 -0
- data/spec/rubocop/cop/rspec/factory_bot/create_list_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/file_path_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/focus_spec.rb +2 -2
- data/spec/rubocop/cop/rspec/hook_argument_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/hooks_before_examples_spec.rb +47 -32
- data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +20 -19
- data/spec/rubocop/cop/rspec/implicit_subject_spec.rb +56 -68
- data/spec/rubocop/cop/rspec/instance_spy_spec.rb +16 -15
- data/spec/rubocop/cop/rspec/instance_variable_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +10 -12
- data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/leading_subject_spec.rb +31 -47
- data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +27 -26
- data/spec/rubocop/cop/rspec/message_chain_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +24 -37
- data/spec/rubocop/cop/rspec/not_to_not_spec.rb +22 -32
- data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/pending_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/receive_counts_spec.rb +47 -8
- data/spec/rubocop/cop/rspec/receive_never_spec.rb +16 -4
- data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +95 -72
- data/spec/rubocop/cop/rspec/scattered_let_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/shared_context_spec.rb +29 -34
- data/spec/rubocop/cop/rspec/shared_examples_spec.rb +16 -34
- data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +44 -48
- data/spec/rubocop/cop/rspec/unspecified_exception_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/void_expect_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/yield_spec.rb +22 -21
- data/spec/rubocop/rspec/config_formatter_spec.rb +2 -0
- data/spec/rubocop/rspec/description_extractor_spec.rb +2 -0
- data/spec/rubocop/rspec/language/selector_set_spec.rb +2 -0
- data/spec/rubocop/rspec/util/one_spec.rb +2 -0
- data/spec/rubocop/rspec/wording_spec.rb +2 -0
- data/spec/shared/autocorrect_behavior.rb +2 -0
- data/spec/shared/detects_style_behavior.rb +2 -0
- data/spec/shared/smoke_test_examples.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/expect_offense.rb +3 -1
- metadata +8 -4
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
# instance_double("ClassName", method_name: 'returned value')
|
24
24
|
# end
|
25
25
|
class VerifiedDoubles < Cop
|
26
|
-
MSG = 'Prefer using verifying doubles over normal doubles.'
|
26
|
+
MSG = 'Prefer using verifying doubles over normal doubles.'
|
27
27
|
|
28
28
|
def_node_matcher :unverified_double, <<-PATTERN
|
29
29
|
{(send nil? {:double :spy} $...)}
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def symbol?(name)
|
44
|
-
name
|
44
|
+
name&.sym_type?
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -13,7 +13,7 @@ module RuboCop
|
|
13
13
|
# expect(something).to be(1)
|
14
14
|
class VoidExpect < Cop
|
15
15
|
MSG = 'Do not use `expect()` without `.to` or `.not_to`. ' \
|
16
|
-
'Chain the methods or remove it.'
|
16
|
+
'Chain the methods or remove it.'
|
17
17
|
|
18
18
|
def_node_matcher :expect?, <<-PATTERN
|
19
19
|
(send nil? :expect ...)
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
class Yield < Cop
|
15
15
|
include RangeHelp
|
16
16
|
|
17
|
-
MSG = 'Use `.and_yield`.'
|
17
|
+
MSG = 'Use `.and_yield`.'
|
18
18
|
|
19
19
|
def_node_search :method_on_stub?, '(send nil? :receive ...)'
|
20
20
|
|
@@ -52,9 +52,7 @@ module RuboCop
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def block_range(node)
|
55
|
-
|
56
|
-
block_end = node.loc.end.end_pos
|
57
|
-
range_between(block_start, block_end)
|
55
|
+
node.loc.begin.with(end_pos: node.loc.end.end_pos)
|
58
56
|
end
|
59
57
|
|
60
58
|
def generate_replacement(node)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'rspec/capybara/current_path_expectation'
|
2
4
|
require_relative 'rspec/capybara/feature_methods'
|
3
5
|
|
@@ -22,6 +24,7 @@ require_relative 'rspec/describe_class'
|
|
22
24
|
require_relative 'rspec/describe_method'
|
23
25
|
require_relative 'rspec/describe_symbol'
|
24
26
|
require_relative 'rspec/described_class'
|
27
|
+
require_relative 'rspec/dialect'
|
25
28
|
require_relative 'rspec/empty_example_group'
|
26
29
|
require_relative 'rspec/empty_line_after_example_group'
|
27
30
|
require_relative 'rspec/empty_line_after_final_let'
|
data/lib/rubocop/rspec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module RSpec
|
3
5
|
# Helps determine the offending location if there is not a blank line
|
@@ -26,7 +28,7 @@ module RuboCop
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def last_child?(node)
|
29
|
-
return true unless node.parent
|
31
|
+
return true unless node.parent&.begin_type?
|
30
32
|
|
31
33
|
node.equal?(node.parent.children.last)
|
32
34
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
|
3
5
|
module RuboCop
|
@@ -5,7 +7,7 @@ module RuboCop
|
|
5
7
|
# Builds a YAML config file from two config hashes
|
6
8
|
class ConfigFormatter
|
7
9
|
NAMESPACES = /^(RSpec|Capybara|FactoryBot|Rails)/.freeze
|
8
|
-
STYLE_GUIDE_BASE_URL = 'http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'
|
10
|
+
STYLE_GUIDE_BASE_URL = 'http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'
|
9
11
|
|
10
12
|
def initialize(config, descriptions)
|
11
13
|
@config = config
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module RSpec
|
3
5
|
# Extracts cop descriptions from YARD docstrings
|
@@ -20,7 +22,7 @@ module RuboCop
|
|
20
22
|
# Decorator of a YARD code object for working with documented rspec cops
|
21
23
|
class CodeObject
|
22
24
|
COP_CLASS_NAMES = %w[RuboCop::Cop RuboCop::Cop::RSpec::Cop].freeze
|
23
|
-
RSPEC_NAMESPACE = 'RuboCop::Cop::RSpec'
|
25
|
+
RSPEC_NAMESPACE = 'RuboCop::Cop::RSpec'
|
24
26
|
|
25
27
|
def initialize(yardoc)
|
26
28
|
@yardoc = yardoc
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module RSpec
|
5
|
+
# RuboCop FactoryBot project namespace
|
6
|
+
module FactoryBot
|
7
|
+
ATTRIBUTE_DEFINING_METHODS = %i[factory trait transient ignore].freeze
|
8
|
+
|
9
|
+
UNPROXIED_METHODS = %i[
|
10
|
+
__send__
|
11
|
+
__id__
|
12
|
+
nil?
|
13
|
+
send
|
14
|
+
object_id
|
15
|
+
extend
|
16
|
+
instance_eval
|
17
|
+
initialize
|
18
|
+
block_given?
|
19
|
+
raise
|
20
|
+
caller
|
21
|
+
method
|
22
|
+
].freeze
|
23
|
+
|
24
|
+
DEFINITION_PROXY_METHODS = %i[
|
25
|
+
add_attribute
|
26
|
+
after
|
27
|
+
association
|
28
|
+
before
|
29
|
+
callback
|
30
|
+
ignore
|
31
|
+
initialize_with
|
32
|
+
sequence
|
33
|
+
skip_create
|
34
|
+
to_create
|
35
|
+
].freeze
|
36
|
+
|
37
|
+
RESERVED_METHODS =
|
38
|
+
DEFINITION_PROXY_METHODS +
|
39
|
+
UNPROXIED_METHODS +
|
40
|
+
ATTRIBUTE_DEFINING_METHODS
|
41
|
+
|
42
|
+
private_constant(
|
43
|
+
:ATTRIBUTE_DEFINING_METHODS,
|
44
|
+
:UNPROXIED_METHODS,
|
45
|
+
:DEFINITION_PROXY_METHODS,
|
46
|
+
:RESERVED_METHODS
|
47
|
+
)
|
48
|
+
|
49
|
+
def self.attribute_defining_methods
|
50
|
+
ATTRIBUTE_DEFINING_METHODS
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.reserved_methods
|
54
|
+
RESERVED_METHODS
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/rubocop/rspec/inject.rb
CHANGED
@@ -4,6 +4,8 @@ module RuboCop
|
|
4
4
|
module RSpec
|
5
5
|
# RSpec public API methods that are commonly used in cops
|
6
6
|
module Language
|
7
|
+
RSPEC = '{(const nil? :RSpec) nil?}'
|
8
|
+
|
7
9
|
# Set of method selectors
|
8
10
|
class SelectorSet
|
9
11
|
def initialize(selectors)
|
@@ -27,7 +29,7 @@ module RuboCop
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def send_pattern
|
30
|
-
"(send {
|
32
|
+
"(send #{RSPEC} #{node_pattern_union} ...)"
|
31
33
|
end
|
32
34
|
|
33
35
|
def node_pattern_union
|
@@ -106,6 +108,10 @@ module RuboCop
|
|
106
108
|
ALL = SelectorSet.new(%i[expect is_expected expect_any_instance_of])
|
107
109
|
end
|
108
110
|
|
111
|
+
module Runners
|
112
|
+
ALL = SelectorSet.new(%i[to to_not not_to])
|
113
|
+
end
|
114
|
+
|
109
115
|
ALL =
|
110
116
|
ExampleGroups::ALL +
|
111
117
|
SharedGroups::ALL +
|
@@ -113,7 +119,8 @@ module RuboCop
|
|
113
119
|
Hooks::ALL +
|
114
120
|
Helpers::ALL +
|
115
121
|
Subject::ALL +
|
116
|
-
Expectations::ALL
|
122
|
+
Expectations::ALL +
|
123
|
+
Runners::ALL
|
117
124
|
end
|
118
125
|
end
|
119
126
|
end
|
data/rubocop-rspec.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
2
4
|
require 'rubocop/rspec/version'
|
3
5
|
|
@@ -19,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
19
21
|
|
20
22
|
spec.version = RuboCop::RSpec::Version::STRING
|
21
23
|
spec.platform = Gem::Platform::RUBY
|
22
|
-
spec.required_ruby_version = '>= 2.
|
24
|
+
spec.required_ruby_version = '>= 2.3.0'
|
23
25
|
|
24
26
|
spec.require_paths = ['lib']
|
25
27
|
spec.files = Dir[
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe RuboCop::Cop::RSpec::AlignLeftLetBrace do
|
2
4
|
subject(:cop) { described_class.new }
|
3
5
|
|
6
|
+
# rubocop:disable RSpec/ExampleLength
|
4
7
|
it 'registers offense for unaligned braces' do
|
5
8
|
expect_offense(<<-RUBY)
|
6
9
|
let(:foo) { bar }
|
@@ -15,52 +18,34 @@ RSpec.describe RuboCop::Cop::RSpec::AlignLeftLetBrace do
|
|
15
18
|
}
|
16
19
|
|
17
20
|
describe 'blah' do
|
18
|
-
let(:
|
21
|
+
let(:long_name) { thing }
|
19
22
|
let(:blah) { thing }
|
20
23
|
^ Align left let brace
|
21
24
|
let(:a) { thing }
|
22
25
|
^ Align left let brace
|
23
26
|
end
|
24
27
|
RUBY
|
28
|
+
|
29
|
+
expect_correction(<<-RUBY)
|
30
|
+
let(:foo) { bar }
|
31
|
+
let(:hi) { baz }
|
32
|
+
let(:blahblah) { baz }
|
33
|
+
|
34
|
+
let(:thing) { ignore_this }
|
35
|
+
let(:other) {
|
36
|
+
ignore_this_too
|
37
|
+
}
|
38
|
+
|
39
|
+
describe 'blah' do
|
40
|
+
let(:long_name) { thing }
|
41
|
+
let(:blah) { thing }
|
42
|
+
let(:a) { thing }
|
43
|
+
end
|
44
|
+
RUBY
|
25
45
|
end
|
46
|
+
# rubocop:enable RSpec/ExampleLength
|
26
47
|
|
27
48
|
it 'works with empty file' do
|
28
49
|
expect_no_offenses('')
|
29
50
|
end
|
30
|
-
|
31
|
-
offensive_source = <<-RUBY
|
32
|
-
let(:foo) { bar }
|
33
|
-
let(:hi) { baz }
|
34
|
-
let(:blahblah) { baz }
|
35
|
-
|
36
|
-
let(:thing) { ignore_this }
|
37
|
-
let(:other) {
|
38
|
-
ignore_this_too
|
39
|
-
}
|
40
|
-
|
41
|
-
describe 'blah' do
|
42
|
-
let(:long_name) { thing }
|
43
|
-
let(:blah) { thing }
|
44
|
-
let(:a) { thing }
|
45
|
-
end
|
46
|
-
RUBY
|
47
|
-
|
48
|
-
corrected_source = <<-RUBY
|
49
|
-
let(:foo) { bar }
|
50
|
-
let(:hi) { baz }
|
51
|
-
let(:blahblah) { baz }
|
52
|
-
|
53
|
-
let(:thing) { ignore_this }
|
54
|
-
let(:other) {
|
55
|
-
ignore_this_too
|
56
|
-
}
|
57
|
-
|
58
|
-
describe 'blah' do
|
59
|
-
let(:long_name) { thing }
|
60
|
-
let(:blah) { thing }
|
61
|
-
let(:a) { thing }
|
62
|
-
end
|
63
|
-
RUBY
|
64
|
-
|
65
|
-
include_examples 'autocorrect', offensive_source, corrected_source
|
66
51
|
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe RuboCop::Cop::RSpec::AlignRightLetBrace do
|
2
4
|
subject(:cop) { described_class.new }
|
3
5
|
|
6
|
+
# rubocop:disable RSpec/ExampleLength
|
4
7
|
it 'registers offense for unaligned braces' do
|
5
8
|
expect_offense(<<-RUBY)
|
6
9
|
let(:foo) { a }
|
@@ -22,45 +25,27 @@ RSpec.describe RuboCop::Cop::RSpec::AlignRightLetBrace do
|
|
22
25
|
let(:a) { abc }
|
23
26
|
end
|
24
27
|
RUBY
|
28
|
+
|
29
|
+
expect_correction(<<-RUBY)
|
30
|
+
let(:foo) { a }
|
31
|
+
let(:hi) { ab }
|
32
|
+
let(:blahblah) { abcd }
|
33
|
+
|
34
|
+
let(:thing) { ignore_this }
|
35
|
+
let(:other) {
|
36
|
+
ignore_this_too
|
37
|
+
}
|
38
|
+
|
39
|
+
describe 'blah' do
|
40
|
+
let(:blahblah) { a }
|
41
|
+
let(:blah) { bc }
|
42
|
+
let(:a) { abc }
|
43
|
+
end
|
44
|
+
RUBY
|
25
45
|
end
|
46
|
+
# rubocop:enable RSpec/ExampleLength
|
26
47
|
|
27
48
|
it 'works with empty file' do
|
28
49
|
expect_no_offenses('')
|
29
50
|
end
|
30
|
-
|
31
|
-
offensive_source = <<-RUBY
|
32
|
-
let(:foo) { a }
|
33
|
-
let(:hi) { ab }
|
34
|
-
let(:blahblah) { abcd }
|
35
|
-
|
36
|
-
let(:thing) { ignore_this }
|
37
|
-
let(:other) {
|
38
|
-
ignore_this_too
|
39
|
-
}
|
40
|
-
|
41
|
-
describe 'blah' do
|
42
|
-
let(:blahblah) { a }
|
43
|
-
let(:blah) { bc }
|
44
|
-
let(:a) { abc }
|
45
|
-
end
|
46
|
-
RUBY
|
47
|
-
|
48
|
-
corrected_source = <<-RUBY
|
49
|
-
let(:foo) { a }
|
50
|
-
let(:hi) { ab }
|
51
|
-
let(:blahblah) { abcd }
|
52
|
-
|
53
|
-
let(:thing) { ignore_this }
|
54
|
-
let(:other) {
|
55
|
-
ignore_this_too
|
56
|
-
}
|
57
|
-
|
58
|
-
describe 'blah' do
|
59
|
-
let(:blahblah) { a }
|
60
|
-
let(:blah) { bc }
|
61
|
-
let(:a) { abc }
|
62
|
-
end
|
63
|
-
RUBY
|
64
|
-
|
65
|
-
include_examples 'autocorrect', offensive_source, corrected_source
|
66
51
|
end
|