summaryrefslogtreecommitdiffstats
path: root/spec/unit/indirector/resource
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
commit3180b9d9b2c844dade1d361326600f7001ec66dd (patch)
tree98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /spec/unit/indirector/resource
parent543225970225de5697734bfaf0a6eee996802c04 (diff)
downloadpuppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
Diffstat (limited to 'spec/unit/indirector/resource')
-rw-r--r--spec/unit/indirector/resource/ral_spec.rb202
-rwxr-xr-xspec/unit/indirector/resource/rest_spec.rb6
2 files changed, 104 insertions, 104 deletions
diff --git a/spec/unit/indirector/resource/ral_spec.rb b/spec/unit/indirector/resource/ral_spec.rb
index c3dc8d8cf..a5baef367 100644
--- a/spec/unit/indirector/resource/ral_spec.rb
+++ b/spec/unit/indirector/resource/ral_spec.rb
@@ -3,127 +3,127 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
describe "Puppet::Resource::Ral" do
- describe "find" do
- before do
- @request = stub 'request', :key => "user/root"
- end
-
- it "should find an existing instance" do
- my_resource = stub "my user resource"
-
- wrong_instance = stub "wrong user", :name => "bob"
- my_instance = stub "my user", :name => "root", :to_resource => my_resource
-
- require 'puppet/type/user'
- Puppet::Type::User.expects(:instances).returns([ wrong_instance, my_instance, wrong_instance ])
- Puppet::Resource::Ral.new.find(@request).should == my_resource
- end
-
- it "if there is no instance, it should create one" do
- wrong_instance = stub "wrong user", :name => "bob"
-
- require 'puppet/type/user'
- Puppet::Type::User.expects(:instances).returns([ wrong_instance, wrong_instance ])
- result = Puppet::Resource::Ral.new.find(@request)
- result.should be_is_a(Puppet::Resource)
- result.title.should == "root"
- end
+ describe "find" do
+ before do
+ @request = stub 'request', :key => "user/root"
end
- describe "search" do
- before do
- @request = stub 'request', :key => "user/", :options => {}
- end
+ it "should find an existing instance" do
+ my_resource = stub "my user resource"
- it "should convert ral resources into regular resources" do
- my_resource = stub "my user resource"
- my_instance = stub "my user", :name => "root", :to_resource => my_resource
+ wrong_instance = stub "wrong user", :name => "bob"
+ my_instance = stub "my user", :name => "root", :to_resource => my_resource
- require 'puppet/type/user'
- Puppet::Type::User.expects(:instances).returns([ my_instance ])
- Puppet::Resource::Ral.new.search(@request).should == [my_resource]
- end
+ require 'puppet/type/user'
+ Puppet::Type::User.expects(:instances).returns([ wrong_instance, my_instance, wrong_instance ])
+ Puppet::Resource::Ral.new.find(@request).should == my_resource
+ end
+
+ it "if there is no instance, it should create one" do
+ wrong_instance = stub "wrong user", :name => "bob"
+
+ require 'puppet/type/user'
+ Puppet::Type::User.expects(:instances).returns([ wrong_instance, wrong_instance ])
+ result = Puppet::Resource::Ral.new.find(@request)
+ result.should be_is_a(Puppet::Resource)
+ result.title.should == "root"
+ end
+ end
+
+ describe "search" do
+ before do
+ @request = stub 'request', :key => "user/", :options => {}
+ end
+
+ it "should convert ral resources into regular resources" do
+ my_resource = stub "my user resource"
+ my_instance = stub "my user", :name => "root", :to_resource => my_resource
- it "should filter results by name if there's a name in the key" do
- my_resource = stub "my user resource"
- my_resource.stubs(:to_resource).returns(my_resource)
- my_resource.stubs(:[]).with(:name).returns("root")
+ require 'puppet/type/user'
+ Puppet::Type::User.expects(:instances).returns([ my_instance ])
+ Puppet::Resource::Ral.new.search(@request).should == [my_resource]
+ end
+
+ it "should filter results by name if there's a name in the key" do
+ my_resource = stub "my user resource"
+ my_resource.stubs(:to_resource).returns(my_resource)
+ my_resource.stubs(:[]).with(:name).returns("root")
- wrong_resource = stub "wrong resource"
- wrong_resource.stubs(:to_resource).returns(wrong_resource)
- wrong_resource.stubs(:[]).with(:name).returns("bad")
+ wrong_resource = stub "wrong resource"
+ wrong_resource.stubs(:to_resource).returns(wrong_resource)
+ wrong_resource.stubs(:[]).with(:name).returns("bad")
- my_instance = stub "my user", :to_resource => my_resource
- wrong_instance = stub "wrong user", :to_resource => wrong_resource
+ my_instance = stub "my user", :to_resource => my_resource
+ wrong_instance = stub "wrong user", :to_resource => wrong_resource
- @request = stub 'request', :key => "user/root", :options => {}
+ @request = stub 'request', :key => "user/root", :options => {}
- require 'puppet/type/user'
- Puppet::Type::User.expects(:instances).returns([ my_instance, wrong_instance ])
- Puppet::Resource::Ral.new.search(@request).should == [my_resource]
- end
+ require 'puppet/type/user'
+ Puppet::Type::User.expects(:instances).returns([ my_instance, wrong_instance ])
+ Puppet::Resource::Ral.new.search(@request).should == [my_resource]
+ end
- it "should filter results by query parameters" do
- wrong_resource = stub "my user resource"
- wrong_resource.stubs(:to_resource).returns(wrong_resource)
- wrong_resource.stubs(:[]).with(:name).returns("root")
+ it "should filter results by query parameters" do
+ wrong_resource = stub "my user resource"
+ wrong_resource.stubs(:to_resource).returns(wrong_resource)
+ wrong_resource.stubs(:[]).with(:name).returns("root")
- my_resource = stub "wrong resource"
- my_resource.stubs(:to_resource).returns(my_resource)
- my_resource.stubs(:[]).with(:name).returns("bob")
+ my_resource = stub "wrong resource"
+ my_resource.stubs(:to_resource).returns(my_resource)
+ my_resource.stubs(:[]).with(:name).returns("bob")
- my_instance = stub "my user", :to_resource => my_resource
- wrong_instance = stub "wrong user", :to_resource => wrong_resource
+ my_instance = stub "my user", :to_resource => my_resource
+ wrong_instance = stub "wrong user", :to_resource => wrong_resource
- @request = stub 'request', :key => "user/", :options => {:name => "bob"}
+ @request = stub 'request', :key => "user/", :options => {:name => "bob"}
- require 'puppet/type/user'
- Puppet::Type::User.expects(:instances).returns([ my_instance, wrong_instance ])
- Puppet::Resource::Ral.new.search(@request).should == [my_resource]
- end
+ require 'puppet/type/user'
+ Puppet::Type::User.expects(:instances).returns([ my_instance, wrong_instance ])
+ Puppet::Resource::Ral.new.search(@request).should == [my_resource]
+ end
- it "should return sorted results" do
- a_resource = stub "alice resource"
- a_resource.stubs(:to_resource).returns(a_resource)
- a_resource.stubs(:title).returns("alice")
+ it "should return sorted results" do
+ a_resource = stub "alice resource"
+ a_resource.stubs(:to_resource).returns(a_resource)
+ a_resource.stubs(:title).returns("alice")
- b_resource = stub "bob resource"
- b_resource.stubs(:to_resource).returns(b_resource)
- b_resource.stubs(:title).returns("bob")
+ b_resource = stub "bob resource"
+ b_resource.stubs(:to_resource).returns(b_resource)
+ b_resource.stubs(:title).returns("bob")
- a_instance = stub "alice user", :to_resource => a_resource
- b_instance = stub "bob user", :to_resource => b_resource
+ a_instance = stub "alice user", :to_resource => a_resource
+ b_instance = stub "bob user", :to_resource => b_resource
- @request = stub 'request', :key => "user/", :options => {}
+ @request = stub 'request', :key => "user/", :options => {}
+
+ require 'puppet/type/user'
+ Puppet::Type::User.expects(:instances).returns([ b_instance, a_instance ])
+ Puppet::Resource::Ral.new.search(@request).should == [a_resource, b_resource]
+ end
+ end
+
+ describe "save" do
+ before do
+ @rebuilt_res = stub 'rebuilt instance'
+ @ral_res = stub 'ral resource', :to_resource => @rebuilt_res
+ @instance = stub 'instance', :to_ral => @ral_res
+ @request = stub 'request', :key => "user/", :instance => @instance
+ @catalog = stub 'catalog'
+
+ Puppet::Resource::Catalog.stubs(:new).returns(@catalog)
+ @catalog.stubs(:apply)
+ @catalog.stubs(:add_resource)
+ end
- require 'puppet/type/user'
- Puppet::Type::User.expects(:instances).returns([ b_instance, a_instance ])
- Puppet::Resource::Ral.new.search(@request).should == [a_resource, b_resource]
- end
+ it "should apply a new catalog with a ral object in it" do
+ Puppet::Resource::Catalog.expects(:new).returns(@catalog)
+ @catalog.expects(:add_resource).with(@ral_res)
+ @catalog.expects(:apply)
+ Puppet::Resource::Ral.new.save(@request)
end
- describe "save" do
- before do
- @rebuilt_res = stub 'rebuilt instance'
- @ral_res = stub 'ral resource', :to_resource => @rebuilt_res
- @instance = stub 'instance', :to_ral => @ral_res
- @request = stub 'request', :key => "user/", :instance => @instance
- @catalog = stub 'catalog'
-
- Puppet::Resource::Catalog.stubs(:new).returns(@catalog)
- @catalog.stubs(:apply)
- @catalog.stubs(:add_resource)
- end
-
- it "should apply a new catalog with a ral object in it" do
- Puppet::Resource::Catalog.expects(:new).returns(@catalog)
- @catalog.expects(:add_resource).with(@ral_res)
- @catalog.expects(:apply)
- Puppet::Resource::Ral.new.save(@request)
- end
-
- it "should return a regular resource that used to be the ral resource" do
- Puppet::Resource::Ral.new.save(@request).should == @rebuilt_res
- end
+ it "should return a regular resource that used to be the ral resource" do
+ Puppet::Resource::Ral.new.save(@request).should == @rebuilt_res
end
+ end
end
diff --git a/spec/unit/indirector/resource/rest_spec.rb b/spec/unit/indirector/resource/rest_spec.rb
index d5f2a9d46..351aee33b 100755
--- a/spec/unit/indirector/resource/rest_spec.rb
+++ b/spec/unit/indirector/resource/rest_spec.rb
@@ -5,7 +5,7 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f
require 'puppet/indirector/resource/rest'
describe Puppet::Resource::Rest do
- it "should be a sublcass of Puppet::Indirector::REST" do
- Puppet::Resource::Rest.superclass.should equal(Puppet::Indirector::REST)
- end
+ it "should be a sublcass of Puppet::Indirector::REST" do
+ Puppet::Resource::Rest.superclass.should equal(Puppet::Indirector::REST)
+ end
end