Sha256: 03e7c16a038a9dc58015925991bb21f5762243ed4cbbe391b7c4d24eac1291a4

Contents?: true

Size: 910 Bytes

Versions: 9

Compression:

Stored size: 910 Bytes

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
rubocop-rspec-1.12.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.11.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.10.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.9.1 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.9.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.8.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.7.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.6.0 spec/rubocop/cop/rspec/any_instance_spec.rb
rubocop-rspec-1.5.3 spec/rubocop/cop/rspec/any_instance_spec.rb