summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-16 22:00:38 -0500
committerJames Turnbull <james@lovedthanlost.net>2008-07-17 13:08:33 +1000
commit7fa7251e30dfefc95dda6ef82181d4346f36880d (patch)
tree38850331af675c3ab7cde7c19e2e226471311f60
parentbdbd992a6f5ff9628682179639923214d09a780c (diff)
downloadpuppet-7fa7251e30dfefc95dda6ef82181d4346f36880d.tar.gz
puppet-7fa7251e30dfefc95dda6ef82181d4346f36880d.tar.xz
puppet-7fa7251e30dfefc95dda6ef82181d4346f36880d.zip
The mongrel-related tests now run without mongrel.
Here were the main changes necessary: * Fixed the class loader so it only loads mongrel if it's available. * Fixed the test runner to skip example groups contained in non-runnable example groups. * Fixed the Mongrel tests to use quoted class names instead of constants, since the constants themselves would be absent. Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/network/http.rb14
-rwxr-xr-xspec/integration/indirector/rest.rb4
-rwxr-xr-xspec/unit/network/http.rb12
-rwxr-xr-xspec/unit/network/http/mongrel.rb6
-rwxr-xr-xspec/unit/network/http/mongrel/rest.rb16
-rwxr-xr-xspec/unit/network/http/webrick.rb1
-rwxr-xr-xspec/unit/network/http/webrick/rest.rb1
-rw-r--r--test/lib/puppettest/runnable_test.rb3
8 files changed, 41 insertions, 16 deletions
diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb
index 062c67c71..c219859b6 100644
--- a/lib/puppet/network/http.rb
+++ b/lib/puppet/network/http.rb
@@ -1,13 +1,15 @@
class Puppet::Network::HTTP
def self.server_class_by_type(kind)
- return Puppet::Network::HTTP::WEBrick if kind.to_sym == :webrick
- if kind.to_sym == :mongrel
+ case kind.to_sym
+ when :webrick:
+ require 'puppet/network/http/webrick'
+ return Puppet::Network::HTTP::WEBrick
+ when :mongrel:
raise ArgumentError, "Mongrel is not installed on this platform" unless Puppet.features.mongrel?
+ require 'puppet/network/http/mongrel'
return Puppet::Network::HTTP::Mongrel
+ else
+ raise ArgumentError, "Unknown HTTP server name [#{kind}]"
end
- raise ArgumentError, "Unknown HTTP server name [#{kind}]"
end
end
-
-require 'puppet/network/http/webrick'
-require 'puppet/network/http/mongrel'
diff --git a/spec/integration/indirector/rest.rb b/spec/integration/indirector/rest.rb
index 7edd0b865..9efcdcbd3 100755
--- a/spec/integration/indirector/rest.rb
+++ b/spec/integration/indirector/rest.rb
@@ -118,7 +118,7 @@ describe Puppet::Indirector::REST do
end
it 'should return the instance of the model class associated with the provided lookup key' do
- Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&:value)
+ Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value }
end
it 'should set a version timestamp on model instances' do
@@ -334,7 +334,7 @@ describe Puppet::Indirector::REST do
end
it 'should return the instance of the model class associated with the provided lookup key' do
- Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&:value)
+ Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value }
end
it 'should set an expiration on model instances' do
diff --git a/spec/unit/network/http.rb b/spec/unit/network/http.rb
index 79a0a88d4..1fa025b0b 100755
--- a/spec/unit/network/http.rb
+++ b/spec/unit/network/http.rb
@@ -12,9 +12,15 @@ describe Puppet::Network::HTTP do
Puppet::Network::HTTP.server_class_by_type(:webrick).should be(Puppet::Network::HTTP::WEBrick)
end
- if Puppet.features.mongrel?
- it "should return the mongrel HTTP server class when asked for a mongrel server" do
- Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel)
+ describe "when asked for a mongrel server" do
+ if Puppet.features.mongrel?
+ it "should return the mongrel server class" do
+ Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel)
+ end
+ else
+ it "should fail" do
+ lambda { Puppet::Network::HTTP.server_class_by_type(:mongrel) }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb
index ccfca2f55..3a9cfb52f 100755
--- a/spec/unit/network/http/mongrel.rb
+++ b/spec/unit/network/http/mongrel.rb
@@ -6,7 +6,7 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/network/http'
-describe Puppet::Network::HTTP::Mongrel, "after initializing" do
+describe "Puppet::Network::HTTP::Mongrel", "after initializing" do
confine "Mongrel is not available" => Puppet.features.mongrel?
it "should not be listening" do
@@ -14,7 +14,7 @@ describe Puppet::Network::HTTP::Mongrel, "after initializing" do
end
end
-describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
+describe "Puppet::Network::HTTP::Mongrel", "when turning on listening" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
@@ -82,7 +82,7 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
end
end
-describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do
+describe "Puppet::Network::HTTP::Mongrel", "when turning off listening" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb
index 3df925133..de5254a7a 100755
--- a/spec/unit/network/http/mongrel/rest.rb
+++ b/spec/unit/network/http/mongrel/rest.rb
@@ -3,10 +3,12 @@
require File.dirname(__FILE__) + '/../../../../spec_helper'
require 'puppet/network/http'
-describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
+describe "Puppet::Network::HTTP::MongrelREST", "when initializing" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
+ require 'puppet/network/http/mongrel/rest'
+
@mock_mongrel = mock('Mongrel server')
@mock_mongrel.stubs(:register)
@mock_model = mock('indirected model')
@@ -33,7 +35,7 @@ describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
end
end
-describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
+describe "Puppet::Network::HTTP::MongrelREST", "when receiving a request" do
confine "Mongrel is not available" => Puppet.features.mongrel?
before do
@@ -131,6 +133,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "and determining the request parameters", :shared => true do
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
before do
@mock_request.stubs(:params).returns({})
end
@@ -198,6 +202,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when finding a model instance" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should fail to find model if key is not specified" do
@mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'GET', Mongrel::Const::REQUEST_PATH => '/foo'})
@mock_response.expects(:start).with(404)
@@ -236,6 +242,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when destroying a model instance" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should fail to destroy model if key is not specified" do
@mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'DELETE', Mongrel::Const::REQUEST_PATH => '/foo'})
@mock_response.expects(:start).with(404)
@@ -281,6 +289,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when saving a model instance" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should fail to save model if data is not specified" do
@mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'PUT', Mongrel::Const::REQUEST_PATH => '/foo'})
@mock_request.stubs(:body).returns('')
@@ -319,6 +329,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
end
describe "when searching for model instances" do |variable|
+ confine "Mongrel is not available" => Puppet.features.mongrel?
+
it "should use a common method for determining the request parameters" do
setup_search_request('QUERY_STRING' => 'foo=baz&bar=xyzzy')
@handler.expects(:params).returns(:foo => :baz, :bar => :xyzzy)
diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb
index 78bd39145..9b024ae31 100755
--- a/spec/unit/network/http/webrick.rb
+++ b/spec/unit/network/http/webrick.rb
@@ -5,6 +5,7 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/network/http'
+require 'puppet/network/http/webrick'
describe Puppet::Network::HTTP::WEBrick, "after initializing" do
it "should not be listening" do
diff --git a/spec/unit/network/http/webrick/rest.rb b/spec/unit/network/http/webrick/rest.rb
index 45e5f0bd2..17d47e54c 100755
--- a/spec/unit/network/http/webrick/rest.rb
+++ b/spec/unit/network/http/webrick/rest.rb
@@ -2,6 +2,7 @@
require File.dirname(__FILE__) + '/../../../../spec_helper'
require 'puppet/network/http'
+require 'puppet/network/http/webrick/rest'
describe Puppet::Network::HTTP::WEBrickREST, "when initializing" do
before do
diff --git a/test/lib/puppettest/runnable_test.rb b/test/lib/puppettest/runnable_test.rb
index e4b0f9033..e3cde5052 100644
--- a/test/lib/puppettest/runnable_test.rb
+++ b/test/lib/puppettest/runnable_test.rb
@@ -15,6 +15,9 @@ module PuppetTest
# Evaluate all of our tests to see if any of them are false
# and thus whether this test is considered not runnable.
def runnable?
+ if superclass.respond_to?(:runnable?) and ! superclass.runnable?
+ return false
+ end
@messages ||= []
return false unless @messages.empty?
return true unless defined? @confines