diff options
author | Rick Bradley <rick@rickbradley.com> | 2008-04-02 00:12:27 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-04-11 13:10:38 -0500 |
commit | 07974401178a8b46314971bc7a9858cff1d9797b (patch) | |
tree | a83a74f716741945828e948df341124b5433af4d /spec | |
parent | e8caf135a4a378d54bf62f8c37064ee3ccc508e9 (diff) | |
download | puppet-07974401178a8b46314971bc7a9858cff1d9797b.tar.gz puppet-07974401178a8b46314971bc7a9858cff1d9797b.tar.xz puppet-07974401178a8b46314971bc7a9858cff1d9797b.zip |
updating search integration specs to include webrick
Diffstat (limited to 'spec')
-rw-r--r-- | spec/integration/indirector/rest.rb | 63 | ||||
-rwxr-xr-x | spec/unit/indirector/rest.rb | 8 |
2 files changed, 63 insertions, 8 deletions
diff --git a/spec/integration/indirector/rest.rb b/spec/integration/indirector/rest.rb index b9e9513c4..418575fb6 100644 --- a/spec/integration/indirector/rest.rb +++ b/spec/integration/indirector/rest.rb @@ -86,15 +86,70 @@ describe Puppet::Indirector::REST do end end - describe "when saving a model instance over REST" do - it "needs more specs" + describe "when searching for model instances over REST" do + describe "when matching model instances can be found" do + before :each do + @model_instances = [ Puppet::TestIndirectedFoo.new(23), Puppet::TestIndirectedFoo.new(24) ] + @mock_model = stub('faked model', :search => @model_instances) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should not fail" do + lambda { Puppet::TestIndirectedFoo.search('bar') }.should_not raise_error + end + + it 'should return all matching results' do + Puppet::TestIndirectedFoo.search('bar').length.should == @model_instances.length + end + + it 'should return model instances' do + Puppet::TestIndirectedFoo.search('bar').each do |result| + result.class.should == Puppet::TestIndirectedFoo + end + 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) + end + + it 'should set a version timestamp on model instances' do + pending("Luke looking at why this version magic might not be working") do + Puppet::TestIndirectedFoo.search('bar').each do |result| + result.version.should_not be_nil + end + end + end + end + + describe "when no matching model instance can be found" do + before :each do + @mock_model = stub('faked model', :find => nil) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should return nil" do + Puppet::TestIndirectedFoo.find('bar').should be_nil + end + end + + describe "when an exception is encountered in looking up a model instance" do + before :each do + @mock_model = stub('faked model') + @mock_model.stubs(:find).raises(RuntimeError) + Puppet::Network::HTTP::WEBrickREST.any_instance.stubs(:model).returns(@mock_model) + end + + it "should raise an exception" do + lambda { Puppet::TestIndirectedFoo.find('bar') }.should raise_error(RuntimeError) + end + end end - describe "when searching for model instances over REST" do + describe "when destroying a model instance over REST" do it "needs more specs" end - describe "when destroying a model instance over REST" do + describe "when saving a model instance over REST" do it "needs more specs" end diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb index 6f4285765..37c0480ed 100755 --- a/spec/unit/indirector/rest.rb +++ b/spec/unit/indirector/rest.rb @@ -103,15 +103,15 @@ describe Puppet::Indirector::REST do @searcher.stubs(:network_fetch).returns(RuntimeError.new("bogus").to_yaml) lambda { @searcher.search('foo') }.should raise_error(RuntimeError) end - end + end - describe "when doing a save" do + describe "when doing a destroy" do it "should deserialize result data into a boolean" it "should generate an error when result data deserializes improperly" it "should generate an error when result data specifies an error" end - - describe "when doing a destroy" do + + describe "when doing a save" do it "should deserialize result data into a boolean" it "should generate an error when result data deserializes improperly" it "should generate an error when result data specifies an error" |