Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rubocop: Fix RSpec/AnyInstance #116

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 4
RSpec/AnyInstance:
Exclude:
- 'spec/beaker/hypervisor/docker_spec.rb'

# Offense count: 23
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Expand Down
18 changes: 1 addition & 17 deletions spec/beaker/hypervisor/docker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,32 +129,16 @@ module Beaker

context 'with a working connection' do
before do
# Stub out all of the docker-api gem. we should never really call it
# from these tests
allow_any_instance_of(::Beaker::Docker).to receive(:require).with('docker')
# Stub out all of the docker-api gem. we should never really call it from these tests
allow(::Docker).to receive(:options).and_return(docker_options)
allow(::Docker).to receive(:options=)
allow(::Docker).to receive(:logger=)
allow(::Docker).to receive(:podman?).and_return(false)
allow(::Docker).to receive(:version).and_return(version)
allow(::Docker::Image).to receive(:build).and_return(image)
allow(::Docker::Image).to receive(:create).and_return(image)
allow(::Docker::Container).to receive(:create).and_return(container)
allow_any_instance_of(::Docker::Container).to receive(:start)
end

describe '#initialize' do
it 'requires the docker gem' do
expect_any_instance_of(::Beaker::Docker).to receive(:require).with('docker').once

docker
end

it 'fails when the gem is absent' do
allow_any_instance_of(::Beaker::Docker).to receive(:require).with('docker').and_raise(LoadError)
expect { docker }.to raise_error(LoadError)
end

it 'sets Docker options' do
expect(::Docker).to receive(:options=).with({ write_timeout: 300, read_timeout: 300 }).once

Expand Down