Skip to content

Commit

Permalink
Reorder specs outside of it block
Browse files Browse the repository at this point in the history
  • Loading branch information
corsonknowles committed Oct 14, 2024
1 parent d99ad1c commit df66d6a
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions spec/rubocop/cop/rspec/void_expect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@
RUBY
end

it 'ignores unrelated expect method' do
expect_no_offenses(<<~RUBY)
MyObject.expect
RUBY
end

it 'ignores unrelated expect method in an it block' do
expect_no_offenses(<<~RUBY)
it 'something' do
Expand All @@ -68,33 +62,44 @@
RUBY
end

it 'rejects bare `expect` in a block' do
expect_offense(<<~RUBY)
method { expect }
^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
RUBY
end

it 'accepts expect.to with no arguments' do
expect_no_offenses(<<~RUBY)
it 'something' do
expect.to
end
RUBY
end

it 'accepts expect.to with no arguments in a block' do
expect_no_offenses(<<~RUBY)
method { expect.to }
RUBY
end

context 'when expect has no parent node' do
it 'still registers an offense' do
expect_offense(<<~RUBY)
expect(something)
^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
RUBY
end

it 'rejects bare expect with no arguments' do
expect_offense(<<~RUBY)
expect
^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
RUBY
end

it 'rejects bare `expect` in a block' do
expect_offense(<<~RUBY)
method { expect }
^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
RUBY
end

it 'accepts expect.to with no arguments' do
expect_no_offenses(<<~RUBY)
expect.to
RUBY
end

it 'accepts expect.to with no arguments in a block' do
expect_no_offenses(<<~RUBY)
method { expect.to }
RUBY
end

it 'ignores unrelated expect method' do
expect_no_offenses(<<~RUBY)
MyObject.expect
RUBY
end
end
end

0 comments on commit df66d6a

Please sign in to comment.