Sha256: fbcbf6f8b73bd7ec5db62fb4eff33149eed8129c71d78c7d85f0f6be99bb4bfb

Contents?: true

Size: 944 Bytes

Versions: 4

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

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

  it 'finds `allow_any_instance_of` instead of an instance double' do
    expect_offense(<<-RUBY)
      before do
        allow_any_instance_of(Object).to receive(:foo)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `allow_any_instance_of`.
      end
    RUBY
  end

  it 'finds `expect_any_instance_of` instead of an instance double' do
    expect_offense(<<-RUBY)
      before do
        expect_any_instance_of(Object).to receive(:foo)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `expect_any_instance_of`.
      end
    RUBY
  end

  it 'finds old `any_instance` syntax instead of an instance double' do
    expect_offense(<<-RUBY)
      before do
        Object.any_instance.should_receive(:foo)
        ^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `any_instance`.
      end
    RUBY
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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