Skip to content

Commit

Permalink
Merge pull request #1154 from tejasbubane/fix-failing-rubocop
Browse files Browse the repository at this point in the history
Fix `InternalAffairs/ExampleDescription` offenses on master
  • Loading branch information
pirj authored May 21, 2021
2 parents 721fd6c + dd40ff8 commit 78d1ae4
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 114 deletions.
4 changes: 2 additions & 2 deletions spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
end
# rubocop:enable RSpec/ExampleLength

it 'does not register offense for let with proc argument' do
it 'does not register an offense for let with proc argument' do
expect_no_offenses(<<-RUBY)
let(:user, &args[:build_user])
RUBY
end

it 'works with empty file' do
it 'does not register an offense with empty file' do
expect_no_offenses('')
end
end
4 changes: 2 additions & 2 deletions spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
end
# rubocop:enable RSpec/ExampleLength

it 'does not register offense for let with proc argument' do
it 'does not register an offense for let with proc argument' do
expect_no_offenses(<<-RUBY)
let(:user, &args[:build_user])
RUBY
end

it 'works with empty file' do
it 'does not register an offense with empty file' do
expect_no_offenses('')
end
end
67 changes: 29 additions & 38 deletions spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::EmptyLineAfterFinalLet do
it 'checks for empty line after last let' do
it 'registers an offense for empty line after last let' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -21,7 +21,7 @@
RUBY
end

it 'check for empty line after the last `let!`' do
it 'registers an offense for empty line after the last `let!`' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -45,7 +45,7 @@
RUBY
end

it 'checks for empty line after let with proc argument' do
it 'registers an offense for empty line after let with proc argument' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -65,30 +65,32 @@
RUBY
end

it 'approves empty line after let' do
it 'does not register an offense for empty line after let' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
let(:a) { a }
let(:b) { b }
RSpec.describe User do
let(:a) { a }
let(:b) { b }
it { expect(a).to eq(b) }
end
it { expect(a).to eq(b) }
end
RUBY
end

it 'allows comment followed by an empty line after let' do
it 'does not register an offense for comment '\
'followed by an empty line after let' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
let(:a) { a }
let(:b) { b }
# end of setup
RSpec.describe User do
let(:a) { a }
let(:b) { b }
# end of setup
it { expect(a).to eq(b) }
end
it { expect(a).to eq(b) }
end
RUBY
end

it 'flags missing empty line after the comment that comes after last let' do
it 'registers an offense for missing empty line after the comment '\
'that comes after last let' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -110,7 +112,8 @@
RUBY
end

it 'flags missing empty line after a multiline comment after last let' do
it 'registers an offense for missing empty line after a multiline comment '\
'after last let' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -134,20 +137,8 @@
RUBY
end

it 'ignores empty lines between the lets' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { a }
subject { described_class }
let!(:b) { b }
^^^^^^^^^^^^^^ Add an empty line after the last `let!`.
it { expect(a).to eq(b) }
end
RUBY

expect_correction(<<-RUBY)
it 'does not register an offense for empty lines between the lets' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -160,7 +151,7 @@
RUBY
end

it 'handles let in tests' do
it 'does not register an offense for let in tests' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
# This shouldn't really ever happen in a sane codebase but I still
Expand All @@ -173,7 +164,7 @@
RUBY
end

it 'handles multiline let block' do
it 'does not register an offense for multiline let block' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -186,7 +177,7 @@
RUBY
end

it 'handles let being the latest node' do
it 'does not register an offense for let being the latest node' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand All @@ -195,7 +186,7 @@
RUBY
end

it 'handles HEREDOC for let' do
it 'does not register an offense for HEREDOC for let' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
let(:foo) do
Expand All @@ -212,7 +203,7 @@
RUBY
end

it 'handles silly HEREDOC syntax for let' do
it 'does not register an offense for silly HEREDOC syntax for let' do
expect_no_offenses(<<-RUBY)
RSpec.describe 'silly heredoc syntax' do
let(:foo) { <<-BAR }
Expand All @@ -227,7 +218,7 @@
RUBY
end

it 'handles silly HEREDOC offense' do
it 'registers an offense for silly HEREDOC offense' do
expect_offense(<<-RUBY)
RSpec.describe 'silly heredoc syntax' do
let(:foo) { <<-BAR }
Expand Down
20 changes: 10 additions & 10 deletions spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::EmptyLineAfterHook do
it 'checks for empty line after `before` hook' do
it 'registers an offense for empty line after `before` hook' do
expect_offense(<<-RUBY)
RSpec.describe User do
before { do_something }
Expand All @@ -19,7 +19,7 @@
RUBY
end

it 'checks for empty line after `after` hook' do
it 'registers an offense for empty line after `after` hook' do
expect_offense(<<-RUBY)
RSpec.describe User do
after { do_something }
Expand All @@ -37,7 +37,7 @@
RUBY
end

it 'checks for empty line after `around` hook' do
it 'registers an offense for empty line after `around` hook' do
expect_offense(<<-RUBY)
RSpec.describe User do
around { |test| test.run }
Expand All @@ -55,7 +55,7 @@
RUBY
end

it 'approves empty line after `before` hook' do
it 'does not register an offense for empty line after `before` hook' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
before { do_something }
Expand All @@ -65,7 +65,7 @@
RUBY
end

it 'approves empty line after `after` hook' do
it 'does not register an offense for empty line after `after` hook' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
after { do_something }
Expand All @@ -75,7 +75,7 @@
RUBY
end

it 'approves empty line after `around` hook' do
it 'does not register an offense for empty line after `around` hook' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
around { |test| test.run }
Expand All @@ -85,7 +85,7 @@
RUBY
end

it 'handles multiline `before` block' do
it 'does not register an offense for multiline `before` block' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
before do
Expand All @@ -97,7 +97,7 @@
RUBY
end

it 'handles multiline `after` block' do
it 'does not register an offense for multiline `after` block' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
after do
Expand All @@ -109,7 +109,7 @@
RUBY
end

it 'handles multiline `around` block' do
it 'does not register an offense for multiline `around` block' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
around do |test|
Expand All @@ -121,7 +121,7 @@
RUBY
end

it 'handles `before` being the latest node' do
it 'does not register an offense for `before` being the latest node' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
before { do_something }
Expand Down
14 changes: 7 additions & 7 deletions spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::EmptyLineAfterSubject do
it 'checks for empty line after subject' do
it 'registers an offense for empty line after subject' do
expect_offense(<<-RUBY)
RSpec.describe User do
subject { described_class.new }
Expand All @@ -19,7 +19,7 @@
RUBY
end

it 'checks for empty line after subject!' do
it 'registers an offense for empty line after subject!' do
expect_offense(<<-RUBY)
RSpec.describe User do
subject! { described_class.new }
Expand All @@ -37,7 +37,7 @@
RUBY
end

it 'approves empty line after subject' do
it 'does not register an offense for empty line after subject' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
subject { described_class.new }
Expand All @@ -47,7 +47,7 @@
RUBY
end

it 'approves empty line after subject!' do
it 'does not register an offense for empty line after subject!' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
subject! { described_class.new }
Expand All @@ -57,7 +57,7 @@
RUBY
end

it 'handles subjects in tests' do
it 'does not register an offense for subjects in tests' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
# This shouldn't really ever happen in a sane codebase but I still
Expand All @@ -70,7 +70,7 @@
RUBY
end

it 'handles multiline subject block' do
it 'does not register an offense for multiline subject block' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
subject do
Expand All @@ -82,7 +82,7 @@
RUBY
end

it 'handles subject being the latest node' do
it 'does not register an offense for subject being the latest node' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
subject { described_user }
Expand Down
Loading

0 comments on commit 78d1ae4

Please sign in to comment.