Skip to content

Commit

Permalink
Adjusted tests for proxy variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-daniels committed Jun 15, 2015
1 parent 10f7710 commit d61178f
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
:group => 'root',
:mode => '0644'
)}
it { is_expected.to contain_file("/etc/nginx/conf.d/proxy.conf").with(
:ensure => 'file',
:owner => 'root',
:group => 'root',
:mode => '0644'
)}
it { is_expected.to contain_file("/tmp/nginx.d").with(
:ensure => 'absent',
:purge => true,
Expand Down Expand Up @@ -379,31 +373,6 @@
:value => false,
:notmatch => /mail/,
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
let :params do { param[:attr].to_sym => param[:value] } end

it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_mode('0644') }
it param[:title] do
matches = Array(param[:match])

if matches.all? { |m| m.is_a? Regexp }
matches.each { |item| is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(item) }
else
lines = catalogue.resource('file', '/etc/nginx/nginx.conf').send(:parameters)[:content].split("\n")
expect(lines & Array(param[:match])).to eq(Array(param[:match]))
end

Array(param[:notmatch]).each do |item|
is_expected.to contain_file("/etc/nginx/nginx.conf").without_content(item)
end
end
end
end
end

describe "proxy.conf template content" do
[
{
:title => 'should set proxy_buffers',
:attr => 'proxy_buffers',
Expand Down Expand Up @@ -453,19 +422,19 @@
context "when #{param[:attr]} is #{param[:value]}" do
let :params do { param[:attr].to_sym => param[:value] } end

it { is_expected.to contain_file("/etc/nginx/conf.d/proxy.conf").with_mode('0644') }
it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_mode('0644') }
it param[:title] do
matches = Array(param[:match])

if matches.all? { |m| m.is_a? Regexp }
matches.each { |item| is_expected.to contain_file('/etc/nginx/conf.d/proxy.conf').with_content(item) }
matches.each { |item| is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(item) }
else
lines = catalogue.resource('file', '/etc/nginx/conf.d/proxy.conf').send(:parameters)[:content].split("\n")
lines = catalogue.resource('file', '/etc/nginx/nginx.conf').send(:parameters)[:content].split("\n")
expect(lines & Array(param[:match])).to eq(Array(param[:match]))
end

Array(param[:notmatch]).each do |item|
is_expected.to contain_file("/etc/nginx/conf.d/proxy.conf").without_content(item)
is_expected.to contain_file("/etc/nginx/nginx.conf").without_content(item)
end
end
end
Expand Down

0 comments on commit d61178f

Please sign in to comment.