use new 'without_content' matcher
This commit is contained in:
parent
37c12b8cb4
commit
26d904c946
5 changed files with 64 additions and 35 deletions
|
@ -192,7 +192,7 @@ describe 'nginx::config' do
|
|||
:title => 'should not set proxy_cache_path',
|
||||
:attr => 'proxy_cache_path',
|
||||
:value => false,
|
||||
:notmatch => ' proxy_cache_path /path/to/proxy.cache levels=1 keys_zone=d2:100m max_size=500m inactive=20m;',
|
||||
:notmatch => / proxy_cache_path \/path\/to\/proxy\.cache levels=1 keys_zone=d2:100m max_size=500m inactive=20m;/,
|
||||
},
|
||||
{
|
||||
:title => 'should contain ordered appended directives',
|
||||
|
@ -211,8 +211,9 @@ describe 'nginx::config' do
|
|||
it { should contain_file("/etc/nginx/nginx.conf").with_mode('0644') }
|
||||
it param[:title] do
|
||||
verify_contents(subject, "/etc/nginx/nginx.conf", Array(param[:match]))
|
||||
lines = subject.resource('file', "/etc/nginx/nginx.conf").send(:parameters)[:content].split("\n")
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_file("/etc/nginx/nginx.conf").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -260,8 +261,9 @@ describe 'nginx::config' do
|
|||
it { should contain_file("/etc/nginx/conf.d/proxy.conf").with_mode('0644') }
|
||||
it param[:title] do
|
||||
verify_contents(subject, "/etc/nginx/conf.d/proxy.conf", Array(param[:match]))
|
||||
lines = subject.resource('file', "/etc/nginx/conf.d/proxy.conf").send(:parameters)[:content].split("\n")
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_file("/etc/nginx/conf.d/proxy.conf").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -118,7 +118,9 @@ describe 'nginx::resource::location' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -179,7 +181,9 @@ describe 'nginx::resource::location' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -222,7 +226,9 @@ describe 'nginx::resource::location' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -307,7 +313,9 @@ describe 'nginx::resource::location' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(/#{item}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -392,7 +400,9 @@ describe 'nginx::resource::location' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -425,7 +435,9 @@ describe 'nginx::resource::location' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,7 +67,7 @@ describe 'nginx::resource::mailhost' do
|
|||
:title => 'should not enable IPv6',
|
||||
:attr => 'ipv6_enable',
|
||||
:value => false,
|
||||
:notmatch => ' listen [::]:80 default ipv6only=on;',
|
||||
:notmatch => / listen \[::\]:80 default ipv6only=on;/,
|
||||
},
|
||||
{
|
||||
:title => 'should set the IPv6 listen IP',
|
||||
|
@ -131,7 +131,9 @@ describe 'nginx::resource::mailhost' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "#{title}-header").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("#{title}-header").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -155,7 +157,7 @@ describe 'nginx::resource::mailhost' do
|
|||
:title => 'should not enable SSL',
|
||||
:attr => 'starttls',
|
||||
:value => false,
|
||||
:notmatch => ' ssl_session_timeout 5m;',
|
||||
:notmatch => / ssl_session_timeout 5m;/,
|
||||
},
|
||||
{
|
||||
:title => 'should set ssl_certificate',
|
||||
|
@ -183,7 +185,9 @@ describe 'nginx::resource::mailhost' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "#{title}-header").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("#{title}-header").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -207,7 +211,7 @@ describe 'nginx::resource::mailhost' do
|
|||
:title => 'should not enable IPv6',
|
||||
:attr => 'ipv6_enable',
|
||||
:value => false,
|
||||
:notmatch => ' listen [::]:80 default ipv6only=on;',
|
||||
:notmatch => / listen \[::\]:80 default ipv6only=on;/,
|
||||
},
|
||||
{
|
||||
:title => 'should set the IPv6 listen IP',
|
||||
|
@ -278,7 +282,9 @@ describe 'nginx::resource::mailhost' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "#{title}-ssl").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("#{title}-ssl").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,8 +64,9 @@ describe 'nginx::resource::upstream' do
|
|||
it { should contain_file("/etc/nginx/conf.d/#{title}-upstream.conf").with_mode('0644') }
|
||||
it param[:title] do
|
||||
verify_contents(subject, "/etc/nginx/conf.d/#{title}-upstream.conf", Array(param[:match]))
|
||||
lines = subject.resource('file', "/etc/nginx/conf.d/#{title}-upstream.conf").send(:parameters)[:content].split("\n")
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_file("/etc/nginx/conf.d/#{title}-upstream.conf").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,7 +83,7 @@ describe 'nginx::resource::vhost' do
|
|||
:title => 'should not enable IPv6',
|
||||
:attr => 'ipv6_enable',
|
||||
:value => false,
|
||||
:notmatch => ' listen [::]:80 default ipv6only=on;',
|
||||
:notmatch => / listen \[::\]:80 default ipv6only=on;/,
|
||||
},
|
||||
{
|
||||
:title => 'should set the IPv6 listen IP',
|
||||
|
@ -153,7 +153,7 @@ describe 'nginx::resource::vhost' do
|
|||
:title => 'should not set root',
|
||||
:attr => 'use_default_location',
|
||||
:value => true,
|
||||
:notmatch => ' root /;',
|
||||
:notmatch => / root \/;/,
|
||||
},
|
||||
{
|
||||
:title => 'should set proxy_set_header',
|
||||
|
@ -178,8 +178,8 @@ describe 'nginx::resource::vhost' do
|
|||
:attr => 'rewrite_to_https',
|
||||
:value => false,
|
||||
:notmatch => [
|
||||
' if ($ssl_protocol = "") {',
|
||||
' return 301 https://$host$request_uri;',
|
||||
/if \(\$ssl_protocol = ""\) \{/,
|
||||
/ return 301 https:\/\/\$host\$request_uri;/,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -202,7 +202,9 @@ describe 'nginx::resource::vhost' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "#{title}-header").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("#{title}-header").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -244,9 +246,9 @@ describe 'nginx::resource::vhost' do
|
|||
:attr => 'rewrite_www_to_non_www',
|
||||
:value => false,
|
||||
:notmatch => [
|
||||
' listen *:80;',
|
||||
' server_name www.rspec.example.com;',
|
||||
' rewrite ^ http://rspec.example.com$uri permanent;',
|
||||
/ listen \*:80;/,
|
||||
/ server_name www\.rspec\.example\.com;/,
|
||||
/ rewrite \^ http:\/\/rspec\.example\.com\$uri permanent;/,
|
||||
],
|
||||
},
|
||||
].each do |param|
|
||||
|
@ -257,7 +259,9 @@ describe 'nginx::resource::vhost' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "#{title}-footer").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("#{title}-footer").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -317,7 +321,7 @@ describe 'nginx::resource::vhost' do
|
|||
:title => 'should disable IPv6',
|
||||
:attr => 'ipv6_enable',
|
||||
:value => false,
|
||||
:notmatch => ' listen [::]:80 default ipv6only=on;',
|
||||
:notmatch => / listen \[::\]:80 default ipv6only=on;/,
|
||||
},
|
||||
{
|
||||
:title => 'should set the IPv6 listen IP',
|
||||
|
@ -407,7 +411,7 @@ describe 'nginx::resource::vhost' do
|
|||
:title => 'should not set root',
|
||||
:attr => 'use_default_location',
|
||||
:value => true,
|
||||
:notmatch => ' root /;',
|
||||
:notmatch => / root \/;/,
|
||||
},
|
||||
].each do |param|
|
||||
context "when #{param[:attr]} is #{param[:value]}" do
|
||||
|
@ -421,7 +425,9 @@ describe 'nginx::resource::vhost' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "#{title}-ssl-header").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("#{title}-ssl-header").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -463,9 +469,9 @@ describe 'nginx::resource::vhost' do
|
|||
:attr => 'rewrite_www_to_non_www',
|
||||
:value => false,
|
||||
:notmatch => [
|
||||
' listen *:443 ssl;',
|
||||
' server_name www.rspec.example.com;',
|
||||
' rewrite ^ https://rspec.example.com$uri permanent;',
|
||||
/ listen \*:443 ssl;/,
|
||||
/ server_name www\.rspec\.example\.com;/,
|
||||
/ rewrite \^ https:\/\/rspec\.example\.com\$uri permanent;/,
|
||||
],
|
||||
},
|
||||
].each do |param|
|
||||
|
@ -481,7 +487,9 @@ describe 'nginx::resource::vhost' do
|
|||
it param[:title] do
|
||||
lines = subject.resource('concat::fragment', "#{title}-ssl-footer").send(:parameters)[:content].split("\n")
|
||||
(lines & Array(param[:match])).should == Array(param[:match])
|
||||
(Array(param[:notmatch]).collect { |x| lines.grep x }.flatten).should be_empty
|
||||
Array(param[:notmatch]).each do |item|
|
||||
should contain_concat__fragment("#{title}-ssl-footer").without_content(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue