Skip to content
Browse files

ensure selected version of passenger is installed and loaded by apache

  • Loading branch information...
1 parent ce3dc0e commit b5c9ef737f00463cf14bf622af2b83b3f6383671 @jnewland committed Jun 7, 2011
View
23 lib/moonshine/manifest/rails/passenger.rb
@@ -1,21 +1,23 @@
module Moonshine::Manifest::Rails::Passenger
+
+ BLESSED_VERSION = '3.0.7'
+
# Install the passenger gem
def passenger_gem
- blessed_version = '3.0.7'
configure(:passenger => {})
if configuration[:passenger][:version] && configuration[:passenger][:version] < "3.0"
package "passenger",
:ensure => configuration[:passenger][:version],
:provider => :gem
- elsif configuration[:passenger][:version] == :latest
+ elsif configuration[:passenger][:version].nil? || configuration[:passenger][:version] == :latest
package "passenger",
- :ensure => blessed_version,
+ :ensure => BLESSED_VERSION,
:provider => :gem,
:require => [ package('libcurl4-openssl-dev') ]
package 'libcurl4-openssl-dev', :ensure => :installed
- else
+ elsif configuration[:passenger][:version]
package "passenger",
- :ensure => (configuration[:passenger][:version] || blessed_version),
+ :ensure => (configuration[:passenger][:version]),
:provider => :gem,
:require => [ package('libcurl4-openssl-dev') ]
package 'libcurl4-openssl-dev', :ensure => :installed
@@ -92,14 +94,11 @@ def passenger_site
def passenger_configure_gem_path
configure(:passenger => {})
- return configuration[:passenger][:path] if configuration[:passenger][:path]
- version = begin
- configuration[:passenger][:version] || Gem::SourceIndex.from_installed_gems.find_name("passenger").last.version.to_s
- rescue
- `gem install passenger --no-ri --no-rdoc`
- `passenger-config --version`.chomp
+ if configuration[:passenger][:version].nil? || configuration[:passenger][:version] == :latest
+ configure(:passenger => { :path => "#{Gem.dir}/gems/passenger-#{BLESSED_VERSION}" })
+ elsif configuration[:passenger][:version]
+ configure(:passenger => { :path => "#{Gem.dir}/gems/passenger-#{configuration[:passenger][:version]}" })
end
- configure(:passenger => { :path => "#{Gem.dir}/gems/passenger-#{version}" })
end
private
View
65 spec/moonshine/manifest/passenger_spec.rb
@@ -0,0 +1,65 @@
+require 'spec_helper'
+
+describe Moonshine::Manifest::Rails::Passenger do
+ before do
+ @manifest = Moonshine::Manifest::Rails.new
+ end
+
+ context 'without a version configured' do
+ before do
+ @manifest.configure(:passenger => { :version => nil })
+ @manifest.passenger_gem
+ @manifest.passenger_configure_gem_path
+ @manifest.passenger_apache_module
+ end
+
+ it "installs #{Moonshine::Manifest::Rails::Passenger::BLESSED_VERSION} by default" do
+ @manifest.should have_package('passenger').version(Moonshine::Manifest::Rails::Passenger::BLESSED_VERSION)
+ end
+
+ it "loads #{Moonshine::Manifest::Rails::Passenger::BLESSED_VERSION} into apache" do
+ @manifest.should have_file('/etc/apache2/mods-available/passenger.load').with_content(
+ /#{Moonshine::Manifest::Rails::Passenger::BLESSED_VERSION}/
+ )
+ end
+
+ it 'configures and builds the apache module' do
+ @manifest.should have_package('apache2-threaded-dev')
+ @manifest.should have_file('/etc/apache2/mods-available/passenger.conf').with_content(
+ /PassengerUseGlobalQueue On/
+ )
+ @manifest.should exec_command('/usr/sbin/a2enmod passenger')
+ @manifest.should exec_command('sudo /usr/bin/ruby -S rake clean apache2')
+ end
+
+ it "allows setting booleans configurations to false" do
+ @manifest.configure(:passenger => { :use_global_queue => false })
+ @manifest.passenger_configure_gem_path
+ @manifest.passenger_apache_module
+
+ @manifest.should have_file('/etc/apache2/mods-available/passenger.conf').with_content(
+ /PassengerUseGlobalQueue Off/
+ )
+ end
+ end
+
+ context 'with a version configured' do
+ before do
+ @manifest.configure(:passenger => { :version => '2.2.2' })
+ @manifest.passenger_gem
+ @manifest.passenger_configure_gem_path
+ @manifest.passenger_apache_module
+ end
+
+ it 'installs the configured version' do
+ @manifest.should have_package('passenger').version('2.2.2')
+ end
+
+ it "loads the configured version into apache" do
+ @manifest.should have_file('/etc/apache2/mods-available/passenger.load').with_content(
+ /2.2.2/
+ )
+ end
+ end
+
+end
View
40 spec/moonshine/manifest/rails_spec.rb
@@ -148,46 +148,6 @@ def search(gem_pattern, platform_only = false)
end
describe "passenger support" do
- it "installs 3.0.7 by default " do
- @manifest.configure(:passenger => { :version => nil })
-
- @manifest.passenger_configure_gem_path
- @manifest.passenger_gem
-
- @manifest.should have_package('passenger').version('3.0.7')
- end
-
- it "can be pinned to a specific version" do
- @manifest.configure(:passenger => { :version => '2.2.2' })
- @manifest.passenger_configure_gem_path
- @manifest.passenger_gem
-
- @manifest.should have_package('passenger').version('2.2.2')
- end
-
- it "installs passenger apache module" do
- @manifest.passenger_configure_gem_path
- @manifest.passenger_apache_module
-
- @manifest.should have_package('apache2-threaded-dev')
- @manifest.should have_file('/etc/apache2/mods-available/passenger.load')
- @manifest.should have_file('/etc/apache2/mods-available/passenger.conf').with_content(
- /PassengerUseGlobalQueue On/
- )
- @manifest.should exec_command('/usr/sbin/a2enmod passenger')
- @manifest.should exec_command('sudo /usr/bin/ruby -S rake clean apache2')
- end
-
- it "allows setting booleans configurations to false" do
- @manifest.configure(:passenger => { :use_global_queue => false })
- @manifest.passenger_configure_gem_path
- @manifest.passenger_apache_module
-
- @manifest.should have_file('/etc/apache2/mods-available/passenger.conf').with_content(
- /PassengerUseGlobalQueue Off/
- )
- end
-
describe "passenger_site" do
it "enables passenger vhost, disables default vhost, and configures mod_rewrite" do

0 comments on commit b5c9ef7

Please sign in to comment.
Something went wrong with that request. Please try again.