Sha256: 79e368b02ff417c2fe4776a17852e27d058eed78ed37ef8cef61d95e4b1fcd64

Contents?: true

Size: 919 Bytes

Versions: 4

Compression:

Stored size: 919 Bytes

Contents

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_violation(<<-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_violation(<<-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_violation(<<-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.15.1 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.15.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.14.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.13.0 spec/rubocop/cop/rspec/any_instance_spec.rb