Skip to content

Commit

Permalink
Merge pull request #334 from multiplay/fixtests_only
Browse files Browse the repository at this point in the history
Fix all rspec tests so they run
  • Loading branch information
James Fryman committed Jun 11, 2014
2 parents 70e772e + 8eb26b7 commit 3691e83
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis/Gemfile
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

group :rake do
gem 'puppetlabs_spec_helper'
gem 'librarian-puppet-maestrodev'
gem 'librarian-puppet'
gem 'open3_backport', :platforms => :ruby_18
gem 'json', :platforms => :ruby_18
end
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -7,7 +7,7 @@ group :rake do
gem 'puppet-lint', '>=0.1.12'
gem 'puppetlabs_spec_helper'
gem 'puppet-blacksmith'
gem 'librarian-puppet-maestrodev'
gem 'librarian-puppet'
gem 'rspec-system-puppet', :require => false
gem 'rspec-system-serverspec', :require => false
end
6 changes: 0 additions & 6 deletions spec/classes/config_spec.rb
Expand Up @@ -230,12 +230,6 @@

describe "proxy.conf template content" do
[
{
:title => 'should set client_max_body_size',
:attr => 'client_max_body_size',
:value => '5m',
:match => 'client_max_body_size 5m;',
},
{
:title => 'should set proxy_buffers',
:attr => 'proxy_buffers',
Expand Down
53 changes: 27 additions & 26 deletions spec/defines/resource_location_spec.rb
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'digest/md5'

describe 'nginx::resource::location' do
let :title do
Expand Down Expand Up @@ -27,7 +28,7 @@

it { should contain_class("nginx::params") }
it { should contain_class("nginx::config") }
it { should contain_concat__fragment("vhost1-500-rspec-test").with_content(/location rspec-test/) }
it { should contain_concat__fragment("f25e14942fb58942ee13b1465a4e1719").with_content(/location rspec-test/) }
it { should_not contain_file('/etc/nginx/fastcgi_params') }
it { should_not contain_concat__fragment("vhost1-800-rspec-test-ssl") }
it { should_not contain_file("/etc/nginx/rspec-test_htpasswd") }
Expand Down Expand Up @@ -134,12 +135,12 @@
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end

it { should contain_concat__fragment("vhost1-500-#{params[:location]}") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it param[:title] do
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
lines = subject.resource('concat::fragment', Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).send(:parameters)[:content].split("\n")
(lines & Array(param[:match])).should == Array(param[:match])
Array(param[:notmatch]).each do |item|
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(item)
end
end
end
Expand All @@ -154,7 +155,7 @@
:proxy_cache_valid => '10m',
} end

it { should contain_concat__fragment("vhost1-500-location").with_content(/proxy_cache_valid 10m;/) }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-location")).with_content(/proxy_cache_valid 10m;/) }
end
end

Expand Down Expand Up @@ -209,12 +210,12 @@
let :default_params do { :location => 'location', :location_alias => 'location_alias_value', :vhost => 'vhost1' } end
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end

it { should contain_concat__fragment("vhost1-500-#{params[:location]}") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it param[:title] do
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
lines = subject.resource('concat::fragment', Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).send(:parameters)[:content].split("\n")
(lines & Array(param[:match])).should == Array(param[:match])
Array(param[:notmatch]).each do |item|
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(item)
end
end
end
Expand Down Expand Up @@ -266,12 +267,12 @@
let :default_params do { :location => 'location', :stub_status => true, :vhost => 'vhost1' } end
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end

it { should contain_concat__fragment("vhost1-500-#{params[:location]}") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it param[:title] do
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
lines = subject.resource('concat::fragment', Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).send(:parameters)[:content].split("\n")
(lines & Array(param[:match])).should == Array(param[:match])
Array(param[:notmatch]).each do |item|
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(item)
end
end
end
Expand Down Expand Up @@ -359,12 +360,12 @@
let :default_params do { :location => 'location', :fastcgi => 'localhost:9000', :vhost => 'vhost1' } end
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end

it { should contain_concat__fragment("vhost1-500-#{params[:location]}") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it param[:title] do
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
lines = subject.resource('concat::fragment', Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).send(:parameters)[:content].split("\n")
(lines & Array(param[:match])).should == Array(param[:match])
Array(param[:notmatch]).each do |item|
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(/#{item}/)
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(/#{item}/)
end
end
end
Expand Down Expand Up @@ -478,12 +479,12 @@
let :default_params do { :location => 'location', :www_root => '/var/www/root', :vhost => 'vhost1' } end
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end

it { should contain_concat__fragment("vhost1-500-#{params[:location]}") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it param[:title] do
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
lines = subject.resource('concat::fragment', Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).send(:parameters)[:content].split("\n")
(lines & Array(param[:match])).should == Array(param[:match])
Array(param[:notmatch]).each do |item|
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(item)
end
end
end
Expand Down Expand Up @@ -519,12 +520,12 @@
let :default_params do { :location => 'location', :location_custom_cfg => {'test1'=>'value1'}, :vhost => 'vhost1' } end
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end

it { should contain_concat__fragment("vhost1-500-#{params[:location]}") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it param[:title] do
lines = subject.resource('concat::fragment', "vhost1-500-#{params[:location]}").send(:parameters)[:content].split("\n")
lines = subject.resource('concat::fragment', Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).send(:parameters)[:content].split("\n")
(lines & Array(param[:match])).should == Array(param[:match])
Array(param[:notmatch]).each do |item|
should contain_concat__fragment("vhost1-500-#{params[:location]}").without_content(item)
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(item)
end
end
end
Expand All @@ -540,25 +541,25 @@

context 'when ssl_only => true' do
let :params do { :ssl_only => true, :vhost => 'vhost1', :www_root => '/', } end
it { should_not contain_concat__fragment("vhost1-500-rspec-test") }
it { should_not contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-rspec-test")) }
end

context 'when ssl_only => false' do
let :params do { :ssl_only => false, :vhost => 'vhost1', :www_root => '/', } end

it { should contain_concat__fragment("vhost1-500-rspec-test") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-rspec-test")) }
end

context 'when ssl => true' do
let :params do { :ssl => true, :vhost => 'vhost1', :www_root => '/', } end

it { should contain_concat__fragment("vhost1-800-rspec-test-ssl") }
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-800-rspec-test-ssl")) }
end

context 'when ssl => false' do
let :params do { :ssl => false, :vhost => 'vhost1', :www_root => '/', } end

it { should_not contain_concat__fragment("vhost1-800-rspec-test-ssl") }
it { should_not contain_concat__fragment(Digest::MD5.hexdigest("vhost1-800-rspec-test-ssl")) }
end

context 'when auth_basic_user_file => true' do
Expand Down Expand Up @@ -613,8 +614,8 @@
:ssl => true,
} end

it { should contain_concat__fragment("www_rspec-vhost_com-500-www.rspec-location.com").with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') }
it { should contain_concat__fragment("www_rspec-vhost_com-800-www.rspec-location.com-ssl").with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') }
it { should contain_concat__fragment(Digest::MD5.hexdigest("www_rspec-vhost_com-500-www.rspec-location.com")).with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') }
it { should contain_concat__fragment(Digest::MD5.hexdigest("www_rspec-vhost_com-800-www.rspec-location.com-ssl")).with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') }
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/resource_vhost_spec.rb
Expand Up @@ -515,13 +515,13 @@
context "SSL cert missing" do
let(:params) {{ :ssl => true, :ssl_key => 'key' }}

it { expect { should contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) }
it { expect { should contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error) }
end

context "SSL key missing" do
let(:params) {{ :ssl => true, :ssl_cert => 'cert' }}

it { expect { should contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) }
it { expect { should contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error) }
end

context 'when use_default_location => true' do
Expand Down
2 changes: 1 addition & 1 deletion templates/conf.d/nginx.conf.erb
Expand Up @@ -6,7 +6,7 @@ error_log <%= @nginx_error_log %>;
<% if scope.lookupvar('nginx::params::nx_pid') != false %>pid <%= scope.lookupvar('nginx::params::nx_pid')%>;<% end -%>

events {
worker_connections <%= @worker_connections -%>;
worker_connections <%= @worker_connections -%>;
<% if @multi_accept == 'on' -%>
multi_accept on;
<% end -%>
Expand Down

0 comments on commit 3691e83

Please sign in to comment.