Skip to content

Commit

Permalink
Update ChefSpec tests to work under Chef 12.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hartmantis committed Nov 19, 2015
1 parent 40f5310 commit eba43fd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
Expand Up @@ -5,8 +5,9 @@

describe Chef::Provider::FantasticalApp::MacOsX::AppStore do
let(:name) { 'default' }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, nil) }
let(:provider) { described_class.new(new_resource, nil) }
let(:run_context) { ChefSpec::SoloRunner.new.converge.run_context }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, run_context) }
let(:provider) { described_class.new(new_resource, run_context) }

describe '#install!' do
before(:each) do
Expand Down
10 changes: 6 additions & 4 deletions spec/libraries/provider_fantastical_app_mac_os_x_direct_spec.rb
Expand Up @@ -5,8 +5,9 @@

describe Chef::Provider::FantasticalApp::MacOsX::Direct do
let(:name) { 'default' }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, nil) }
let(:provider) { described_class.new(new_resource, nil) }
let(:run_context) { ChefSpec::SoloRunner.new.converge.run_context }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, run_context) }
let(:provider) { described_class.new(new_resource, run_context) }

describe 'URL' do
it 'returns the correct URL' do
Expand Down Expand Up @@ -76,8 +77,9 @@
end

it 'returns a cache path' do
expected = "#{Chef::Config[:file_cache_path]}/Fantastical.zip"
expect(provider.send(:download_path)).to eq(expected)
expect(provider.send(:download_path)).to eq(
"#{Chef::Config[:file_cache_path]}/Fantastical.zip"
)
end
end

Expand Down
5 changes: 3 additions & 2 deletions spec/libraries/provider_fantastical_app_mac_os_x_spec.rb
Expand Up @@ -5,8 +5,9 @@

describe Chef::Provider::FantasticalApp::MacOsX do
let(:name) { 'default' }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, nil) }
let(:provider) { described_class.new(new_resource, nil) }
let(:run_context) { ChefSpec::SoloRunner.new.converge.run_context }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, run_context) }
let(:provider) { described_class.new(new_resource, run_context) }

describe '#start!' do
before(:each) do
Expand Down
5 changes: 3 additions & 2 deletions spec/libraries/provider_fantastical_app_spec.rb
Expand Up @@ -5,8 +5,9 @@

describe Chef::Provider::FantasticalApp do
let(:name) { 'default' }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, nil) }
let(:provider) { described_class.new(new_resource, nil) }
let(:run_context) { ChefSpec::SoloRunner.new.converge.run_context }
let(:new_resource) { Chef::Resource::FantasticalApp.new(name, run_context) }
let(:provider) { described_class.new(new_resource, run_context) }

describe '#whyrun_supported?' do
it 'returns true' do
Expand Down
3 changes: 2 additions & 1 deletion spec/libraries/provider_mapping_spec.rb
Expand Up @@ -6,7 +6,8 @@
describe :provider_mapping do
let(:platform) { nil }
let(:app_provider) do
Chef::Platform.platforms[platform][:default][:fantastical_app]
Chef::Platform.platforms[platform] && \
Chef::Platform.platforms[platform][:default][:fantastical_app]
end

context 'Mac OS X' do
Expand Down
17 changes: 8 additions & 9 deletions spec/libraries/resource_fantastical_app_spec.rb
Expand Up @@ -5,34 +5,33 @@

describe Chef::Resource::FantasticalApp do
let(:name) { 'default' }
let(:resource) { described_class.new(name, nil) }
let(:run_context) { ChefSpec::SoloRunner.new.converge.run_context }
let(:resource) { described_class.new(name, run_context) }

describe '#initialize' do
it 'sets the correct resource name' do
exp = :fantastical_app
expect(resource.instance_variable_get(:@resource_name)).to eq(exp)
expect(resource.resource_name).to eq(:fantastical_app)
end

it 'sets the correct supported actions' do
expected = [:nothing, :install, :enable, :start]
expect(resource.instance_variable_get(:@allowed_actions)).to eq(expected)
expect(resource.allowed_actions).to eq(expected)
end

it 'sets the correct default action' do
expected = [:install, :enable, :start]
expect(resource.instance_variable_get(:@action)).to eq(expected)
expect(resource.action).to eq([:install, :enable, :start])
end

it 'sets the installed status to nil' do
expect(resource.instance_variable_get(:@installed)).to eq(nil)
expect(resource.installed?).to eq(nil)
end

it 'sets the enabled status to nil' do
expect(resource.instance_variable_get(:@enabled)).to eq(nil)
expect(resource.enabled?).to eq(nil)
end

it 'sets the running status to nil' do
expect(resource.instance_variable_get(:@running)).to eq(nil)
expect(resource.running?).to eq(nil)
end
end

Expand Down

0 comments on commit eba43fd

Please sign in to comment.