Permalink
Browse files

Migrated test suite from test/unit to rspec

  • Loading branch information...
1 parent ac60ea8 commit 91fa76ef3a5028e38182e8a79d0470aa76b48a05 @technicalpickles technicalpickles committed Feb 28, 2010
View
@@ -4,5 +4,5 @@ rdoc
doc
coverage
.autotest
-test/test.log
-test/generator.log
+spec/test.log
+spec/generator.log
View
@@ -11,14 +11,13 @@ task :rcov do
system "rcov --exclude /Library/Ruby/ --exclude ~/ -Itest `find test/ | grep _test`"
end
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the moonshine plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'test'
- t.pattern = 'test/**/test_*.rb'
- t.verbose = true
+desc 'Default: specs'
+task :default => :spec
+
+require 'spec/rake/spectask'
+desc "Run all specs in spec directory (excluding plugin specs)"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList['spec/**/*_spec.rb']
end
desc 'Generate documentation for the moonshine plugin.'
@@ -0,0 +1,123 @@
+require 'spec_helper'
+
+describe Moonshine::Manifest::Rails::Apache do
+ before do
+ @manifest = Moonshine::Manifest::Rails.new
+ end
+
+ it "provides a default configuration" do
+ @manifest.apache_server
+
+ apache2_conf_content = @manifest.files['/etc/apache2/apache2.conf'].content
+
+ @manifest.configuration[:apache].should be_kind_of(Hash)
+
+ @manifest.configuration[:apache][:keep_alive].should == 'Off'
+ apache2_conf_content.should have_apache_directive('KeepAlive', 'Off')
+
+ @manifest.configuration[:apache][:max_keep_alive_requests].should == 100
+ apache2_conf_content.should have_apache_directive('MaxKeepAliveRequests', 100)
+
+ @manifest.configuration[:apache][:keep_alive_timeout].should == 15
+ apache2_conf_content.should have_apache_directive('KeepAliveTimeout', 15)
+
+ @manifest.configuration[:apache][:max_clients].should == 150
+ apache2_conf_content.should have_apache_directive('MaxClients', 150)
+
+ @manifest.configuration[:apache][:server_limit].should == 16
+ apache2_conf_content.should have_apache_directive('ServerLimit', 16)
+
+ @manifest.configuration[:apache][:timeout].should == 300
+ apache2_conf_content.should have_apache_directive('Timeout', 300)
+ end
+
+ it "allows configuration to be overriden early" do
+ @manifest.configure :apache => {
+ :keep_alive => 'On',
+ :max_keep_alive_requests => 200,
+ :keep_alive_timeout => 30,
+ :max_clients => 300,
+ :server_limit => 32,
+ :timeout => 600
+ }
+ @manifest.apache_server
+
+ apache2_conf_content = @manifest.files['/etc/apache2/apache2.conf'].content
+
+ @manifest.configuration[:apache][:timeout].should == 600
+ apache2_conf_content.should have_apache_directive('Timeout', 600)
+
+ @manifest.configuration[:apache][:keep_alive].should == 'On'
+ apache2_conf_content.should have_apache_directive('KeepAlive', 'On')
+
+ @manifest.configuration[:apache][:max_keep_alive_requests].should == 200
+ apache2_conf_content.should have_apache_directive('MaxKeepAliveRequests', 200)
+
+ @manifest.configuration[:apache][:keep_alive_timeout].should == 30
+ apache2_conf_content.should have_apache_directive('KeepAliveTimeout', 30)
+
+ in_apache_if_module apache2_conf_content, 'mpm_worker_module' do |mpm_worker_module|
+ @manifest.configuration[:apache][:max_clients].should == 300
+ mpm_worker_module.should have_apache_directive('MaxClients', 300)
+
+ @manifest.configuration[:apache][:server_limit].should == 32
+ mpm_worker_module.should have_apache_directive('ServerLimit', 32)
+ end
+
+ end
+
+ it "allows configuration to be overriden late" do
+ @manifest.apache_server
+ @manifest.configure :apache => { :keep_alive => 'On' }
+
+ apache2_conf_content = @manifest.files['/etc/apache2/apache2.conf'].content
+
+ @manifest.configuration[:apache][:keep_alive].should == 'On'
+ apache2_conf_content.should have_apache_directive('KeepAlive', 'On')
+ end
+
+ it "defaults KeepAlive to Off" do
+ @manifest.apache_server
+
+ apache2_conf_content = @manifest.files['/etc/apache2/apache2.conf'].content
+
+ pending "seems to be some weird load-order thing causing this to fail"
+ apache2_conf_content.should have_apache_directive('KeepAlive', 'Off')
+ end
+
+ it "starts apache2" do
+ @manifest.apache_server
+
+ # TODO refactor to something like @manifest.should have_service('apache2').require(package('apache2-mpm-worker'))
+ apache = @manifest.services["apache2"]
+ apache.should_not == nil
+ apache.require.to_s.should == @manifest.package('apache2-mpm-worker').to_s
+ end
+
+ it "supports ssl" do
+ @manifest.configure(:ssl => {
+ :certificate_file => 'cert_file',
+ :certificate_key_file => 'cert_key_file',
+ :certificate_chain_file => 'cert_chain_file'
+ })
+
+ @manifest.apache_server
+
+ @manifest.should exec_command('/usr/sbin/a2enmod ssl')
+ end
+
+ it "enables mod_rewrite" do
+ @manifest.apache_server
+
+ @manifest.should exec_command('/usr/sbin/a2enmod rewrite')
+ end
+
+ it "enables mod_status" do
+ @manifest.apache_server
+
+ @manifest.should exec_command('/usr/sbin/a2enmod status')
+ @manifest.should have_file("/etc/apache2/mods-available/status.conf").with_content(
+ /127.0.0.1/
+ )
+ end
+end
Oops, something went wrong.

0 comments on commit 91fa76e

Please sign in to comment.