Sha256: 52cb4f3f0ac8213eb11e9aa5aba79a4c0f001da9ea607d52c8326e64497b8a48

Contents?: true

Size: 941 Bytes

Versions: 4

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

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

  it 'registers an offense for `be` without an argument' do
    expect_offense(<<-RUBY)
      it { expect(foo).to be }
                          ^^ Don't use `be` without an argument.
    RUBY
  end

  it 'registers an offense for not_to be' do
    expect_offense(<<-RUBY)
      it { expect(foo).not_to be }
                              ^^ Don't use `be` without an argument.
      it { expect(foo).to_not be }
                              ^^ Don't use `be` without an argument.
    RUBY
  end

  it 'allows `be` with an argument' do
    expect_no_offenses(<<-RUBY)
      it { expect(foo).to be(1) }
      it { expect(foo).not_to be(0) }
    RUBY
  end

  it 'allows specific `be_` matchers' do
    expect_no_offenses(<<-RUBY)
      it { expect(foo).to be_truthy }
      it { expect(foo).not_to be_falsy }
    RUBY
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.35.0 spec/rubocop/cop/rspec/be_spec.rb
rubocop-rspec-1.34.1 spec/rubocop/cop/rspec/be_spec.rb
rubocop-rspec-1.34.0 spec/rubocop/cop/rspec/be_spec.rb
rubocop-rspec-1.33.0 spec/rubocop/cop/rspec/be_spec.rb