Skip to content

Commit

Permalink
(maint) Use a Beaker::Host instance when mocking hosts
Browse files Browse the repository at this point in the history
The mock hosts being generated for tests where failing when :exec was
called, despite the allow() in the helpers.rb make_host() function.
Using a Beaker::Host resolved this.
  • Loading branch information
jpartlow committed Feb 23, 2017
1 parent 858e63a commit 7154c00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def prep_host(host)
end

def slice_installer_options(host)
host.select { |k,v| [ :pe_installer_conf_file, :pe_installer_conf_setting].include?(k) }
host.host_hash.select { |k,v| [ :pe_installer_conf_file, :pe_installer_conf_setting].include?(k) }
end

context 'when version < 2016.2.0' do
Expand Down Expand Up @@ -1602,12 +1602,12 @@ def test_setup(mock_values)
it { expect(subject.get_console_dispatcher_for_beaker_pe).to be_nil }
it do
expect { subject.get_console_dispatcher_for_beaker_pe(true) }.to(
raise_exception(LoadError, /cannot load.*scooter/)
raise_exception(LoadError, /cannot load.*scooter/)
)
end
it do
expect { subject.get_console_dispatcher_for_beaker_pe! }.to(
raise_exception(LoadError, /cannot load.*scooter/)
raise_exception(LoadError, /cannot load.*scooter/)
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def make_host_opts name, opts
end

def make_host name, host_hash
host_hash = StringifyHash.new.merge(HOST_DEFAULTS.merge(host_hash))
host_hash = Beaker::Options::OptionsHash.new.merge(HOST_DEFAULTS.merge(host_hash))

host = make_opts.merge(host_hash)
host = Beaker::Host.create( name, host_hash, make_opts)

allow(host).to receive( :name ).and_return( name )
allow(host).to receive( :hostname ).and_return( "#{name}.test" )
Expand Down

0 comments on commit 7154c00

Please sign in to comment.