diff options
| author | Luke Kanies <luke@madstop.com> | 2008-04-11 15:04:54 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-04-11 15:04:54 -0500 |
| commit | d9846fc3f06f61fcb4b8806740f77747a7f6939e (patch) | |
| tree | c730c26f4f42a02a2c6c2c4a78fe97601c1b19b9 | |
| parent | cb617f20ed6e0af362937760f33f5ddc34e626ee (diff) | |
Fixishing some pending tests, including filling in
the connection information.
| -rw-r--r-- | lib/puppet/indirector/rest.rb | 4 | ||||
| -rw-r--r-- | spec/integration/indirector/rest.rb | 10 | ||||
| -rwxr-xr-x | spec/unit/indirector/rest.rb | 20 |
3 files changed, 19 insertions, 15 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index 26f7736f3..d33150fc2 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -5,7 +5,7 @@ require 'uri' class Puppet::Indirector::REST < Puppet::Indirector::Terminus def rest_connection_details - { :host => '127.0.0.1', :port => 34343 } + { :host => Puppet[:server], :port => Puppet[:masterport].to_i } end def network_fetch(path) @@ -47,7 +47,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus private def network(&block) - Net::HTTP.start(rest_connection_details[:host], rest_connection_details[:port]) {|conn| yield(conn) } + Net::HTTP.start(rest_connection_details[:host], rest_connection_details[:port]) {|conn| yield(conn) } end def exception?(yaml_string) diff --git a/spec/integration/indirector/rest.rb b/spec/integration/indirector/rest.rb index 8e3c92d5c..cafcce713 100644 --- a/spec/integration/indirector/rest.rb +++ b/spec/integration/indirector/rest.rb @@ -38,7 +38,10 @@ describe Puppet::Indirector::REST do # the autoloader was clearly not written test-first. We subvert the integration test to get around its bullshit. Puppet::Indirector::Terminus.stubs(:terminus_class).returns(Puppet::TestIndirectedFoo::Rest) - Puppet::TestIndirectedFoo.terminus_class = :rest + Puppet::TestIndirectedFoo.indirection.stubs(:terminus_class).returns :rest + + # Stub the connection information. + Puppet::TestIndirectedFoo.indirection.terminus(:rest).stubs(:rest_connection_details).returns(:host => "localhost", :port => 34343) end describe "when finding a model instance over REST" do @@ -252,7 +255,10 @@ describe Puppet::Indirector::REST do # the autoloader was clearly not written test-first. We subvert the integration test to get around its bullshit. Puppet::Indirector::Terminus.stubs(:terminus_class).returns(Puppet::TestIndirectedFoo::Rest) - Puppet::TestIndirectedFoo.terminus_class = :rest + Puppet::TestIndirectedFoo.indirection.stubs(:terminus_class).returns :rest + + # Stub the connection information. + Puppet::TestIndirectedFoo.indirection.terminus(:rest).stubs(:rest_connection_details).returns(:host => "localhost", :port => 34343) end describe "when finding a model instance over REST" do diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb index e46e32f1c..1a1064491 100755 --- a/spec/unit/indirector/rest.rb +++ b/spec/unit/indirector/rest.rb @@ -21,16 +21,18 @@ describe Puppet::Indirector::REST do end describe "when locating the REST connection" do - it 'should look somewhere meaningful for connection details' do - pending("Luke enlightening us on where to find the appropriate connection details") + before do + Puppet.settings.stubs(:value).returns("whatever") end - - it "should return a host" do - @searcher.rest_connection_details[:host].should == '127.0.0.1' + + it "should return the :server setting as the host" do + Puppet.settings.expects(:value).with(:server).returns "myserver" + @searcher.rest_connection_details[:host].should == "myserver" end - it "should return a port" do - @searcher.rest_connection_details[:port].should == 34343 + it "should return the :masterport (as an Integer) as the port" do + Puppet.settings.expects(:value).with(:masterport).returns "1234" + @searcher.rest_connection_details[:port].should == 1234 end end @@ -330,10 +332,6 @@ describe Puppet::Indirector::REST do @request = stub 'request', :instance => @instance end - it "should re-enable caching in the terminus" do - pending("Luke taking a look at (a) why that doesn't seem to work with this save, or (b) rewriting it, like he seems to indicate in his blog is going to happen") - end - it "should save the model instance over the network" do @searcher.expects(:network_put).returns(@result) @searcher.save(@request) |
