Skip to content

Commit

Permalink
Merge pull request voxpupuli#443 from rabbitt/whitespace-cleanup
Browse files Browse the repository at this point in the history
cleanup whitespace and key/value alignment in config files
  • Loading branch information
jfryman committed Sep 20, 2014
2 parents 1e13d94 + 2914afb commit 8127044
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 196 deletions.
24 changes: 20 additions & 4 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@
:title => 'should set proxy_cache_path',
:attr => 'proxy_cache_path',
:value => '/path/to/proxy.cache',
:match => ' proxy_cache_path /path/to/proxy.cache levels=1 keys_zone=d2:100m max_size=500m inactive=20m;',
:match => %r'\s+proxy_cache_path\s+/path/to/proxy.cache levels=1 keys_zone=d2:100m max_size=500m inactive=20m;',
},
{
: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 => %r'\s+proxy_cache_path\s+/path/to/proxy\.cache levels=1 keys_zone=d2:100m max_size=500m inactive=20m;',
},
{
:title => 'should contain ordered appended directives from hash',
Expand Down Expand Up @@ -252,7 +252,15 @@

it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_mode('0644') }
it param[:title] do
verify_contents(subject, "/etc/nginx/nginx.conf", Array(param[:match]))
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 = subject.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
Expand Down Expand Up @@ -308,7 +316,15 @@

it { is_expected.to 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]))
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) }
else
lines = subject.resource('file', '/etc/nginx/conf.d/proxy.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)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/defines/resource_geo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
'10.0.0.0/8' => 'intra',
},
:match => [
' 10.0.0.0/8 intra;',
' 172.16.0.0/12 intra;',
' 10.0.0.0/8 intra;',
' 172.16.0.0/12 intra;',
' 192.168.0.0/16 intra;',
],
},
Expand All @@ -99,7 +99,7 @@
:title => 'should set delete',
:attr => 'delete',
:value => '192.168.0.0/16',
:match => ' delete 192.168.0.0/16;'
:match => ' delete 192.168.0.0/16;'
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
Expand Down
42 changes: 19 additions & 23 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
{
:location => 'location',
:www_root => '/var/www/root',
:vhost => 'vhost1'
:vhost => 'vhost1',
}
end

Expand All @@ -283,7 +283,7 @@
:title => 'should set www_root',
:attr => 'www_root',
:value => '/',
:match => ' root /;'
:match => ' root /;'
},
{
:title => 'should set try_file(s)',
Expand All @@ -295,7 +295,7 @@
:title => 'should set index_file(s)',
:attr => 'index_files',
:value => ['name1','name2'],
:match => ' index name1 name2;',
:match => ' index name1 name2;',
},
{
:title => 'should contain rewrite rules',
Expand Down Expand Up @@ -428,31 +428,31 @@
:title => 'should set www_root',
:attr => 'www_root',
:value => '/',
:match => ' root /;'
:match => %r'\s+root\s+/;'
},
{
:title => 'should set fastcgi_split_path',
:attr => 'fastcgi_split_path',
:value => 'value',
:match => ' fastcgi_split_path_info value;'
:match => %r'\s+fastcgi_split_path_info\s+value;'
},
{
:title => 'should set try_file(s)',
:attr => 'try_files',
:value => ['name1','name2'],
:match => ' try_files name1 name2;',
:match => %r'\s+try_files\s+name1 name2;',
},
{
:title => 'should set fastcgi_params',
:attr => 'fastcgi_params',
:value => 'value',
:match => /^[ ]+include\s+value;/
:match => %r'\s+include\s+value;'
},
{
:title => 'should set fastcgi_pass',
:attr => 'fastcgi',
:value => 'value',
:match => ' fastcgi_pass value;'
:match => %r'\s+fastcgi_pass\s+value;'
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
Expand Down Expand Up @@ -502,10 +502,6 @@
with_content(%r|fastcgi_param\s+CUSTOM_PARAM\s+value;|).
with_content(%r|fastcgi_param\s+CUSTOM_PARAM2\s+value2;|)
end
it "should add comment # Enable custom fastcgi_params" do
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).
with_content(%r|# Enable custom fastcgi_params\s+|)
end
end

context "when fastcgi_param is not set" do
Expand All @@ -528,7 +524,7 @@
:title => 'should set proxy_cache',
:attr => 'proxy_cache',
:value => 'value',
:match => /^[ ]+proxy_cache\s+value;/,
:match => /^\s+proxy_cache\s+value;/,
},
{
:title => 'should not set proxy_cache_valid',
Expand All @@ -540,7 +536,7 @@
:title => 'should set proxy_cache_valid',
:attr => 'proxy_cache_valid',
:value => 'value',
:match => /^[ ]+proxy_cache_valid\s+value;/,
:match => /^\s+proxy_cache_valid\s+value;/,
},
{
:title => 'should not set proxy_cache',
Expand All @@ -552,46 +548,46 @@
:title => 'should set proxy_pass',
:attr => 'proxy',
:value => 'value',
:match => /^[ ]+proxy_pass\s+value;/,
:match => /^\s+proxy_pass\s+value;/,
},
{
:title => 'should set proxy_read_timeout',
:attr => 'proxy_read_timeout',
:value => 'value',
:match => ' proxy_read_timeout value;',
:match => %r'\s+proxy_read_timeout\s+value;',
},
{
:title => 'should set proxy_connect_timeout',
:attr => 'proxy_connect_timeout',
:value => 'value',
:match => ' proxy_connect_timeout value;',
:match => %r'\s+proxy_connect_timeout\s+value;',
},
{
:title => 'should set proxy_read_timeout',
:attr => 'proxy_read_timeout',
:value => 'value',
:match => ' proxy_read_timeout value;',
:match => %r'\s+proxy_read_timeout\s+value;',
},
{
:title => 'should set proxy headers',
:attr => 'proxy_set_header',
:value => [ 'X-TestHeader1 value1', 'X-TestHeader2 value2' ],
:match => [
/^[ ]+proxy_set_header\s+X-TestHeader1 value1;/,
/^[ ]+proxy_set_header\s+X-TestHeader2 value2;/,
/^\s+proxy_set_header\s+X-TestHeader1 value1;/,
/^\s+proxy_set_header\s+X-TestHeader2 value2;/,
]
},
{
:title => 'should set proxy_method',
:attr => 'proxy_method',
:value => 'value',
:match => ' proxy_method value;',
:match => %r'\s+proxy_method\s+value;',
},
{
:title => 'should set proxy_set_body',
:attr => 'proxy_set_body',
:value => 'value',
:match => ' proxy_set_body value;',
:match => %r'\s+proxy_set_body\s+value;',
},
{
:title => 'should contain rewrite rules',
Expand Down Expand Up @@ -646,7 +642,7 @@
:proxy_cache_valid => '10m',
} end

it { is_expected.to contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-location")).with_content(/proxy_cache_valid 10m;/) }
it { is_expected.to contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-location")).with_content(/proxy_cache_valid\s+10m;/) }
end
end

Expand Down
Loading

0 comments on commit 8127044

Please sign in to comment.