Sha256: cab9d5cae4a3f7dbeddbc11ed8cc2f159cb338f7c594ba2860f2a1f77d1e80c2

Contents?: true

Size: 1.24 KB

Versions: 24

Compression:

Stored size: 1.24 KB

Contents

RSpec.describe RuboCop::Cop::RSpec::VoidExpect do
  subject(:cop) { described_class.new }

  it 'registers offenses to void `expect`' do
    expect_offense(<<-RUBY)
      it 'something' do
        something = 1
        expect(something)
        ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
      end
    RUBY
  end

  it 'registers offenses to void `expect` when block has one expression' do
    expect_offense(<<-RUBY)
      it 'something' do
        expect(something)
        ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
      end
    RUBY
  end

  it 'registers offenses to void `expect` with block' do
    expect_offense(<<-RUBY)
      it 'something' do
        expect{something}
        ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
      end
    RUBY
  end

  it 'accepts non-void `expect`' do
    expect_no_offenses(<<-RUBY)
      it 'something' do
        expect(something).to be 1
      end
    RUBY
  end

  it 'accepts non-void `expect` with block' do
    expect_no_offenses(<<-RUBY)
      it 'something' do
        expect{something}.to raise_error(StandardError)
      end
    RUBY
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rubocop-rspec-1.32.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.31.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.30.1 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.30.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.29.1 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.29.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.28.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.27.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.26.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.25.1 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.25.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.24.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.23.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.22.2 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.22.1 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.22.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.21.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/cop/rspec/void_expect_spec.rb
rubocop-rspec-1.19.0 spec/rubocop/cop/rspec/void_expect_spec.rb