Sha256: 28b696d8b1f77fd244a36555c4b73f1dd793c347a78aaa813c85245f3371b00f

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

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

  it 'registers an offense for double question' do
    expect_offense(<<-RUBY)
      expect(foo).to be_something?
                     ^^^^^^^^^^^^^ Omit `?` from `be_something?`.
    RUBY
  end

  it 'registers an offense for double question with `not_to`' do
    expect_offense(<<-RUBY)
      expect(foo).not_to be_something?
                         ^^^^^^^^^^^^^ Omit `?` from `be_something?`.
    RUBY
  end

  it 'registers an offense for double question with `to_not`' do
    expect_offense(<<-RUBY)
      expect(foo).to_not be_something?
                         ^^^^^^^^^^^^^ Omit `?` from `be_something?`.
    RUBY
  end

  it 'registers an offense for double question with `have_something?`' do
    expect_offense(<<-RUBY)
      expect(foo).to have_something?
                     ^^^^^^^^^^^^^^^ Omit `?` from `have_something?`.
    RUBY
  end

  it 'accepts valid predicate matcher' do
    expect_no_offenses(<<-RUBY)
      expect(foo).to be_something
    RUBY
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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