Skip to content

Commit 8014b6b

Browse files
committed
Use subject and subject! in message
Also, add "an" to error message.
1 parent b948759 commit 8014b6b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/rubocop/cop/rspec/empty_line_after_subject.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ class EmptyLineAfterSubject < Cop
1818
extend AutoCorrector
1919
include RuboCop::RSpec::BlankLineSeparation
2020

21-
MSG = 'Add empty line after `subject`.'
21+
MSG = 'Add an empty line after `%<subject>s`.'
2222

2323
def on_block(node)
2424
return unless subject?(node) && !in_spec_block?(node)
2525
return if last_child?(node)
2626

2727
missing_separating_line(node) do |location|
28-
add_offense(location) do |corrector|
28+
msg = format(MSG, subject: node.method_name)
29+
add_offense(location, message: msg) do |corrector|
2930
corrector.insert_after(location.end, "\n")
3031
end
3132
end

spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
expect_offense(<<-RUBY)
88
RSpec.describe User do
99
subject { described_class.new }
10-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add empty line after `subject`.
10+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add an empty line after `subject`.
1111
let(:params) { foo }
1212
end
1313
RUBY
@@ -25,7 +25,7 @@
2525
expect_offense(<<-RUBY)
2626
RSpec.describe User do
2727
subject! { described_class.new }
28-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add empty line after `subject`.
28+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add an empty line after `subject!`.
2929
let(:params) { foo }
3030
end
3131
RUBY

0 commit comments

Comments
 (0)