Skip to content

Commit

Permalink
fixing up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean OMeara committed Nov 24, 2014
1 parent d9c0798 commit aebb032
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 15 deletions.
6 changes: 3 additions & 3 deletions providers/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def whyrun_supported?
# of these when dropping Chef 10 support.

# support https transport
package "ca-certificates" do
package 'ca-certificates' do
action :upgrade
end

template "/etc/yum.repos.d/#{new_resource.repositoryid}.repo" do
if new_resource.source.nil?
source 'repo.erb'
Expand Down Expand Up @@ -70,7 +70,7 @@ def whyrun_supported?
end
end

action :delete do
action :delete do
file "/etc/yum.repos.d/#{new_resource.repositoryid}.repo" do
action :delete
notifies :run, "execute[yum clean #{new_resource.repositoryid}]", :immediately
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/test_repository_eight_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
)
end

it 'steps into yum_repository and upgrades package[ca-certificates]' do
expect(test_repository_eight_run).to upgrade_package('ca-certificates')
end

it 'steps into yum_repository and creates template[/etc/yum.repos.d/test8.repo]' do
expect(test_repository_eight_run).to create_template('/etc/yum.repos.d/test8.repo')
.with(
Expand Down
28 changes: 16 additions & 12 deletions spec/unit/test_repository_nine_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require 'spec_helper'

describe 'yum_test::test_repository_nine' do
let(:test_repository_eight_run) do
let(:test_repository_nine_run) do
ChefSpec::Runner.new(
:step_into => 'yum_repository'
).converge(described_recipe)
end

let(:test_repository_eight_template) do
test_repository_eight_run.template('/etc/yum.repos.d/test9.repo')
let(:test_repository_nine_template) do
test_repository_nine_run.template('/etc/yum.repos.d/test9.repo')
end

let(:test_repository_eight_content) do
let(:test_repository_nine_content) do
'Hello there, I am a custom template.
baseurl: http://drop.the.baseurl.biz
Have a nice day.
Expand All @@ -20,7 +20,7 @@

context 'creating a yum_repository with minimal parameters' do
it 'creates yum_repository[test9]' do
expect(test_repository_eight_run).to create_yum_repository('test9')
expect(test_repository_nine_run).to create_yum_repository('test9')
.with(
:source => 'custom_template.erb',
:description => 'an test',
Expand All @@ -29,36 +29,40 @@
)
end

it 'steps into yum_repository and upgrades package[ca-certificates]' do
expect(test_repository_nine_run).to upgrade_package('ca-certificates')
end

it 'steps into yum_repository and creates template[/etc/yum.repos.d/test9.repo]' do
expect(test_repository_eight_run).to create_template('/etc/yum.repos.d/test9.repo')
expect(test_repository_nine_run).to create_template('/etc/yum.repos.d/test9.repo')
.with(
:path => '/etc/yum.repos.d/test9.repo',
:source => 'custom_template.erb'
)
end

it 'steps into yum_repository and renders file[/etc/yum.repos.d/test9.repo]' do
expect(test_repository_eight_run).to render_file('/etc/yum.repos.d/test9.repo')
.with_content(test_repository_eight_content)
expect(test_repository_nine_run).to render_file('/etc/yum.repos.d/test9.repo')
.with_content(test_repository_nine_content)
end

it 'steps into yum_repository and runs execute[yum-makecache-test9]' do
expect(test_repository_eight_run).to_not run_execute('yum-makecache-test9')
expect(test_repository_nine_run).to_not run_execute('yum-makecache-test9')
.with(
:command => 'yum -q makecache --disablerepo=* --enablerepo=test9'
)
end

it 'steps into yum_repository and runs ruby_block[yum-cache-reload-test9]' do
expect(test_repository_eight_run).to_not run_ruby_block('yum-cache-reload-test9')
expect(test_repository_nine_run).to_not run_ruby_block('yum-cache-reload-test9')
end

it 'sends a :run to execute[yum-makecache-test9]' do
expect(test_repository_eight_template).to notify('execute[yum-makecache-test9]')
expect(test_repository_nine_template).to notify('execute[yum-makecache-test9]')
end

it 'sends a :create to ruby_block[yum-cache-reload-test9]' do
expect(test_repository_eight_template).to notify('ruby_block[yum-cache-reload-test9]')
expect(test_repository_nine_template).to notify('ruby_block[yum-cache-reload-test9]')
end
end

Expand Down
4 changes: 4 additions & 0 deletions spec/unit/test_repository_one_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
expect(test_repository_one_run).to create_yum_repository('test1')
end

it 'steps into yum_repository and upgrades package[ca-certificates]' do
expect(test_repository_one_run).to upgrade_package('ca-certificates')
end

it 'steps into yum_repository and creates template[/etc/yum.repos.d/test1.repo]' do
expect(test_repository_one_run).to create_template('/etc/yum.repos.d/test1.repo')
end
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/test_repository_seven_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
expect(test_repository_seven_run).to create_yum_repository('test7')
end

it 'steps into yum_repository and upgrades package[ca-certificates]' do
expect(test_repository_seven_run).to upgrade_package('ca-certificates')
end

it 'steps into yum_repository and creates template[/etc/yum.repos.d/test7.repo]' do
expect(test_repository_seven_run).to create_template('/etc/yum.repos.d/test7.repo')
end
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/test_repository_six_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
expect(test_repository_six_run).to create_yum_repository('test6')
end

it 'steps into yum_repository and upgrades package[ca-certificates]' do
expect(test_repository_six_run).to upgrade_package('ca-certificates')
end

it 'steps into yum_repository and creates template[/etc/yum.repos.d/test6.repo]' do
expect(test_repository_six_run).to create_template('/etc/yum.repos.d/test6.repo')
end
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/test_repository_three_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
expect(test_repository_three_run).to add_yum_repository('test3')
end

it 'steps into yum_repository and upgrades package[ca-certificates]' do
expect(test_repository_three_run).to upgrade_package('ca-certificates')
end

it 'steps into yum_repository and creates template[/etc/yum.repos.d/test3.repo]' do
expect(test_repository_three_run).to create_template('/etc/yum.repos.d/test3.repo')
end
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/test_repository_two_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
expect(test_repository_two_run).to create_yum_repository('test2')
end

it 'steps into yum_repository and upgrades package[ca-certificates]' do
expect(test_repository_two_run).to upgrade_package('ca-certificates')
end

it 'steps into yum_repository and creates template[/etc/yum.repos.d/unit-test-2.repo]' do
expect(test_repository_two_run).to create_template('/etc/yum.repos.d/unit-test-2.repo')
end
Expand Down

0 comments on commit aebb032

Please sign in to comment.