Skip to content

Commit 88d2b7c

Browse files
committed
Use let and let! in message
Also, removed redundant "block" from the message.
1 parent 8014b6b commit 88d2b7c

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/rubocop/cop/rspec/empty_line_after_final_let.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EmptyLineAfterFinalLet < Cop
2020
extend AutoCorrector
2121
include RuboCop::RSpec::BlankLineSeparation
2222

23-
MSG = 'Add an empty line after the last `let` block.'
23+
MSG = 'Add an empty line after the last `%<let>s`.'
2424

2525
def on_block(node)
2626
return unless example_group_with_body?(node)
@@ -31,7 +31,8 @@ def on_block(node)
3131
return if last_child?(latest_let)
3232

3333
missing_separating_line(latest_let) do |location|
34-
add_offense(location) do |corrector|
34+
msg = format(MSG, let: latest_let.method_name)
35+
add_offense(location, message: msg) do |corrector|
3536
corrector.insert_after(location.end, "\n")
3637
end
3738
end

spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
RSpec.describe User do
99
let(:a) { a }
1010
let(:b) { b }
11-
^^^^^^^^^^^^^ Add an empty line after the last `let` block.
11+
^^^^^^^^^^^^^ Add an empty line after the last `let`.
1212
it { expect(a).to eq(b) }
1313
end
1414
RUBY
@@ -30,7 +30,7 @@
3030
let!(:b) do
3131
b
3232
end
33-
^^^ Add an empty line after the last `let` block.
33+
^^^ Add an empty line after the last `let!`.
3434
it { expect(a).to eq(b) }
3535
end
3636
RUBY
@@ -52,7 +52,7 @@
5252
RSpec.describe User do
5353
let(:a) { a }
5454
let(:user, &args[:build_user])
55-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add an empty line after the last `let` block.
55+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add an empty line after the last `let`.
5656
it { expect(a).to eq(b) }
5757
end
5858
RUBY
@@ -96,7 +96,7 @@
9696
let(:a) { a }
9797
let(:b) { b }
9898
# end of setup
99-
^^^^^^^^^^^^^^ Add an empty line after the last `let` block.
99+
^^^^^^^^^^^^^^ Add an empty line after the last `let`.
100100
it { expect(a).to eq(b) }
101101
end
102102
RUBY
@@ -119,7 +119,7 @@
119119
let(:b) { b }
120120
# a multiline comment marking
121121
# the end of setup
122-
^^^^^^^^^^^^^^^^^^ Add an empty line after the last `let` block.
122+
^^^^^^^^^^^^^^^^^^ Add an empty line after the last `let`.
123123
it { expect(a).to eq(b) }
124124
end
125125
RUBY
@@ -144,7 +144,7 @@
144144
subject { described_class }
145145
146146
let!(:b) { b }
147-
^^^^^^^^^^^^^^ Add an empty line after the last `let` block.
147+
^^^^^^^^^^^^^^ Add an empty line after the last `let!`.
148148
it { expect(a).to eq(b) }
149149
end
150150
RUBY
@@ -236,7 +236,7 @@
236236
hello
237237
world
238238
BAR
239-
^^^ Add an empty line after the last `let` block.
239+
^^^ Add an empty line after the last `let`.
240240
it 'has tricky syntax' do
241241
expect(foo).to eql(" hello\n world\n")
242242
end

0 commit comments

Comments
 (0)