Sha256: df789931e8bd03968b549730ba3d49859b6e3574c3335b861ac8d40a2836c0eb

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

RSpec.describe RuboCop::Cop::RSpec::NotToNot, :config do
  subject(:cop) { described_class.new(config) }

  context 'when EnforcedStyle is `not_to`' do
    let(:cop_config) { { 'EnforcedStyle' => 'not_to' } }

    it 'detects the `to_not` offense' do
      expect_offense(<<-RUBY)
        it { expect(false).to_not be_true }
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `not_to` over `to_not`.
      RUBY
    end

    it 'detects no offense when using `not_to`' do
      expect_no_offenses(<<-RUBY)
        it { expect(false).not_to be_true }
      RUBY
    end

    include_examples 'autocorrect',
                     'it { expect(0).to_not equal 1 }',
                     'it { expect(0).not_to equal 1 }'
  end

  context 'when AcceptedMethod is `to_not`' do
    let(:cop_config) { { 'EnforcedStyle' => 'to_not' } }

    it 'detects the `not_to` offense' do
      expect_offense(<<-RUBY)
        it { expect(false).not_to be_true }
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `to_not` over `not_to`.
      RUBY
    end

    it 'detects no offense when using `to_not`' do
      expect_no_offenses(<<-RUBY)
        it { expect(false).to_not be_true }
      RUBY
    end

    include_examples 'autocorrect',
                     'it { expect(0).not_to equal 1 }',
                     'it { expect(0).to_not equal 1 }'
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rubocop-rspec-1.26.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.25.1 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.25.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.24.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.23.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.22.2 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.22.1 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.22.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.21.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.19.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.18.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.17.1 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.17.0 spec/rubocop/cop/rspec/not_to_not_spec.rb
rubocop-rspec-1.16.0 spec/rubocop/cop/rspec/not_to_not_spec.rb