Skip to content

Commit

Permalink
MODULES-1764 Fix missing method for check_is_owned_by for windows
Browse files Browse the repository at this point in the history
Fix tests to use its(:content) instead of deprecated should contain
  • Loading branch information
Travis Fields committed Feb 11, 2015
1 parent fa5c1cf commit 7bc211c
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 156 deletions.
64 changes: 33 additions & 31 deletions spec/acceptance/concat_spec.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
require 'spec_helper_acceptance'

case fact('osfamily')
when 'AIX'
username = 'root'
groupname = 'system'
scriptname = 'concatfragments.sh'
vardir = default['puppetvardir']
when 'Darwin'
username = 'root'
groupname = 'wheel'
scriptname = 'concatfragments.sh'
vardir = default['puppetvardir']
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
scriptname = 'concatfragments.rb'
result = on default, "echo #{default['puppetvardir']}"
vardir = result.raw_output.chomp
when 'Solaris'
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.rb'
vardir = default['puppetvardir']
else
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.sh'
vardir = default['puppetvardir']
when 'AIX'
username = 'root'
groupname = 'system'
scriptname = 'concatfragments.sh'
vardir = default['puppetvardir']
when 'Darwin'
username = 'root'
groupname = 'wheel'
scriptname = 'concatfragments.sh'
vardir = default['puppetvardir']
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
scriptname = 'concatfragments.rb'
result = on default, "echo #{default['puppetvardir']}"
vardir = result.raw_output.chomp
when 'Solaris'
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.rb'
vardir = default['puppetvardir']
else
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.sh'
vardir = default['puppetvardir']
end

describe 'basic concat test' do
basedir = default.tmpdir('concat')
safe_basedir = basedir.gsub(/[\/:]/,'_')
safe_basedir = basedir.gsub(/[\/:]/, '_')

shared_examples 'successfully_applied' do |pp|
it 'applies the manifest twice with no stderr' do
Expand All @@ -46,7 +46,7 @@
should be_mode 755
}
end
describe file("#{vardir}/concat/bin") do
describe file("#{vardir}/concat/bin") do
it { should be_directory }
it { should be_owned_by username }
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
Expand Down Expand Up @@ -128,8 +128,10 @@
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
should be_mode 644
}
it { should contain '1' }
it { should contain '2' }
its(:content) {
should match '1'
should match '2'
}
end
describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do
it { should be_file }
Expand Down Expand Up @@ -177,7 +179,7 @@
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
should be_mode 644
}
it { should contain '1' }
its(:content) { should match '1' }
end
end
context 'works when set to absent with path set' do
Expand Down
24 changes: 15 additions & 9 deletions spec/acceptance/deprecation_warnings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'deprecation warnings' do
basedir = default.tmpdir('concat')

shared_examples 'has_warning'do |pp, w|
shared_examples 'has_warning' do |pp, w|
it 'applies the manifest twice with a stderr regex' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m)
expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m)
Expand Down Expand Up @@ -43,8 +43,10 @@

describe file("#{basedir}/file") do
it { should be_file }
it { should contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain 'bar' }
its(:content) {
should match '# This file is managed by Puppet. DO NOT EDIT.'
should match 'bar'
}
end
end
end
Expand All @@ -66,8 +68,10 @@

describe file("#{basedir}/file") do
it { should be_file }
it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain 'bar' }
its(:content) {
should_not match '# This file is managed by Puppet. DO NOT EDIT.'
should match 'bar'
}
end
end
end
Expand Down Expand Up @@ -100,7 +104,7 @@

describe file("#{basedir}/file") do
it { should be_file }
it { should contain 'file1 contents' }
its(:content) { should match 'file1 contents' }
end

describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact("osfamily") == "windows") do
Expand All @@ -119,8 +123,10 @@

describe file("#{basedir}/file") do
it { should be_file }
it { should contain 'new content' }
it { should_not contain 'file1 contents' }
its(:content) {
should match 'new content'
should_not match 'file1 contents'
}
end
end
end # target file exists
Expand Down Expand Up @@ -157,7 +163,7 @@

describe file("#{basedir}/file") do
it { should be_file }
it { should contain 'new content' }
its(:content) { should match 'new content' }
end
end
end # target file exists
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/empty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

describe file("#{basedir}/file") do
it { should be_file }
it { should_not contain '1\n2' }
its(:content) { should_not match /1\n2/ }
end
end
end
50 changes: 29 additions & 21 deletions spec/acceptance/fragment_source_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require 'spec_helper_acceptance'

case fact('osfamily')
when 'AIX'
username = 'root'
groupname = 'system'
when 'Darwin'
username = 'root'
groupname = 'wheel'
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
else
username = 'root'
groupname = 'root'
when 'AIX'
username = 'root'
groupname = 'system'
when 'Darwin'
username = 'root'
groupname = 'wheel'
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
else
username = 'root'
groupname = 'root'
end

describe 'concat::fragment source' do
Expand Down Expand Up @@ -50,9 +50,11 @@

describe file("#{basedir}/foo") do
it { should be_file }
it { should contain 'file1 contents' }
it { should contain 'string1 contents' }
it { should contain 'file2 contents' }
its(:content) {
should match 'file1 contents'
should match 'string1 contents'
should match 'file2 contents'
}
end
end # should read file fragments from local system

Expand Down Expand Up @@ -106,18 +108,24 @@
end
describe file("#{basedir}/result_file1") do
it { should be_file }
it { should contain 'file1 contents' }
it { should_not contain 'file2 contents' }
its(:content) {
should match 'file1 contents'
should_not match 'file2 contents'
}
end
describe file("#{basedir}/result_file2") do
it { should be_file }
it { should contain 'file2 contents' }
it { should_not contain 'file1 contents' }
its(:content) {
should match 'file2 contents'
should_not match 'file1 contents'
}
end
describe file("#{basedir}/result_file3") do
it { should be_file }
it { should contain 'file1 contents' }
it { should_not contain 'file2 contents' }
its(:content) {
should match 'file1 contents'
should_not match 'file2 contents'
}
end
end

Expand Down
18 changes: 12 additions & 6 deletions spec/acceptance/fragments_are_always_replaced_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@

describe file("#{basedir}/foo") do
it { should be_file }
it { should_not contain 'caller has replace unset run 1' }
it { should contain 'caller has replace unset run 2' }
its(:content) {
should_not match 'caller has replace unset run 1'
should match 'caller has replace unset run 2'
}
end
end # should create fragment files

Expand Down Expand Up @@ -82,8 +84,10 @@

describe file("#{basedir}/foo") do
it { should be_file }
it { should_not contain 'caller has replace true set run 1' }
it { should contain 'caller has replace true set run 2' }
its(:content) {
should_not match 'caller has replace true set run 1'
should match 'caller has replace true set run 2'
}
end
end # should replace its own fragment files when caller has File(replace=>true) set

Expand Down Expand Up @@ -125,8 +129,10 @@

describe file("#{basedir}/foo") do
it { should be_file }
it { should_not contain 'caller has replace false set run 1' }
it { should contain 'caller has replace false set run 2' }
its(:content) {
should_not match 'caller has replace false set run 1'
should match 'caller has replace false set run 2'
}
end
end # should replace its own fragment files even when caller has File(replace=>false) set

Expand Down
8 changes: 4 additions & 4 deletions spec/acceptance/newline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

describe file("#{basedir}/file") do
it { should be_file }
it { should contain '12' }
its(:content) { should match '12' }
end
end

Expand All @@ -54,13 +54,13 @@

it 'applies the manifest twice with no stderr' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, :catch_changes => true)
end

describe file("#{basedir}/file") do
it { should be_file }
it("should contain 1\n2\n", :unless => (fact('osfamily') == 'Solaris')) {
should contain "1\n2\n"
its(:content) {
should match /1\n2\n/
}
end
end
Expand Down

0 comments on commit 7bc211c

Please sign in to comment.