diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2011-05-19 21:18:55 -0700 |
|---|---|---|
| committer | Matt Robinson <matt@puppetlabs.com> | 2011-05-19 21:18:55 -0700 |
| commit | eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef (patch) | |
| tree | 704477b4d8c2b255707e65135b3bb0d10253e06c /spec/unit | |
| parent | be2f20899d76621db4cf574d074f0ae89777272e (diff) | |
| parent | 99bf07e76bab47760b9eb3dc42f08582c568388f (diff) | |
| download | puppet-eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef.tar.gz puppet-eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef.tar.xz puppet-eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef.zip | |
Merge branch '2.7.next' into 2.7.x
* 2.7.next: (42 commits)
(#6395) Add extpuppet help, eval, and interfaces
Adding a sleep state post starting master
maint: fix spec_helper inclusions again.
(#7523) Refactor the grammar to reduce duplication
(#7114) Fix specs for ssh authorized key parsed provider
(#7114) Target returns correct value
(#7114) Add integration tests for authorized_key
(#7114) Improve unit tests for ssh_authorized_key
(#7114) Improve value validation for authorized_key
(#7300) Fix instances method of mount provider
(#7259) Remove ActiveRecord requirement from indirector face spec
(#7259) Do not try to load all Terminus classes when configuring the Indirector
(#3836) External nodes should only capture stdout
Revert "(#7220) Add the ability to "inherit" options."
maint: sync 'authconfig' to 'rest_authconfig' setting
adding test for ticket 7139
(#7139) Accept '/' as a valid path in filesets
(#7300) Add specs for the mount provider
case seems needless here as there is only two opts, also the rest of the file seems to use if so this should make things more consistant
(#6845) Mount writes incorrect vfstab entries
...
Diffstat (limited to 'spec/unit')
31 files changed, 501 insertions, 222 deletions
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb index 2e946e6bb..c4f8e7176 100755 --- a/spec/unit/application/agent_spec.rb +++ b/spec/unit/application/agent_spec.rb @@ -411,7 +411,7 @@ describe Puppet::Application::Agent do it "should exit if no authorization file" do Puppet.stubs(:err) - FileTest.stubs(:exists?).with(Puppet[:authconfig]).returns(false) + FileTest.stubs(:exists?).with(Puppet[:rest_authconfig]).returns(false) expect { @puppetd.setup_listen }.to exit_with 14 end diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb index 542bdd838..42a62da22 100755 --- a/spec/unit/application/device_spec.rb +++ b/spec/unit/application/device_spec.rb @@ -1,6 +1,5 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../spec_helper' +#!/usr/bin/env rspec +require 'spec_helper' require 'puppet/application/device' require 'puppet/util/network_device/config' diff --git a/spec/unit/indirector/exec_spec.rb b/spec/unit/indirector/exec_spec.rb index 1050ed4cc..87778cdeb 100755 --- a/spec/unit/indirector/exec_spec.rb +++ b/spec/unit/indirector/exec_spec.rb @@ -32,22 +32,22 @@ describe Puppet::Indirector::Exec do end it "should execute the command with the object name as the only argument" do - @searcher.expects(:execute).with(%w{/echo foo}) + @searcher.expects(:execute).with(%w{/echo foo}, :combine => false) @searcher.find(@request) end it "should return the output of the script" do - @searcher.expects(:execute).with(%w{/echo foo}).returns("whatever") + @searcher.expects(:execute).with(%w{/echo foo}, :combine => false).returns("whatever") @searcher.find(@request).should == "whatever" end it "should return nil when the command produces no output" do - @searcher.expects(:execute).with(%w{/echo foo}).returns(nil) + @searcher.expects(:execute).with(%w{/echo foo}, :combine => false).returns(nil) @searcher.find(@request).should be_nil end it "should raise an exception if there's an execution failure" do - @searcher.expects(:execute).with(%w{/echo foo}).raises(Puppet::ExecutionFailure.new("message")) + @searcher.expects(:execute).with(%w{/echo foo}, :combine => false).raises(Puppet::ExecutionFailure.new("message")) lambda {@searcher.find(@request)}.should raise_exception(Puppet::Error, 'Failed to find foo via exec: message') end diff --git a/spec/unit/indirector/facts/network_device_spec.rb b/spec/unit/indirector/facts/network_device_spec.rb index 302a810e8..93cd35d77 100644..100755 --- a/spec/unit/indirector/facts/network_device_spec.rb +++ b/spec/unit/indirector/facts/network_device_spec.rb @@ -1,9 +1,5 @@ -#!/usr/bin/env ruby -# -# Created by Luke Kanies on 2007-9-23. -# Copyright (c) 2007. All rights reserved. - -require File.dirname(__FILE__) + '/../../../spec_helper' +#!/usr/bin/env rspec +require 'spec_helper' require 'puppet/indirector/facts/network_device' diff --git a/spec/unit/indirector/node/exec_spec.rb b/spec/unit/indirector/node/exec_spec.rb index f14990cd5..1dbfcd13a 100755 --- a/spec/unit/indirector/node/exec_spec.rb +++ b/spec/unit/indirector/node/exec_spec.rb @@ -31,7 +31,7 @@ describe Puppet::Node::Exec do @result = {} # Use a local variable so the reference is usable in the execute definition. result = @result - @searcher.meta_def(:execute) do |command| + @searcher.meta_def(:execute) do |command, arguments| return YAML.dump(result) end diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb index 9ad754ad8..fcce9f6f4 100755 --- a/spec/unit/parser/compiler_spec.rb +++ b/spec/unit/parser/compiler_spec.rb @@ -32,6 +32,14 @@ class CompilerTestResource def evaluate end + + def file + "/fake/file/goes/here" + end + + def line + "42" + end end describe Puppet::Parser::Compiler do @@ -420,52 +428,6 @@ describe Puppet::Parser::Compiler do @compiler.catalog.should be_edge(@scope.resource, resource) end - it "should add an edge to any specified stage for class resources" do - other_stage = resource(:stage, "other") - @compiler.add_resource(@scope, other_stage) - resource = resource(:class, "foo") - resource[:stage] = 'other' - - @compiler.add_resource(@scope, resource) - - @compiler.catalog.edge?(other_stage, resource).should be_true - end - - it "should fail if a non-class resource attempts to set a stage" do - other_stage = resource(:stage, "other") - @compiler.add_resource(@scope, other_stage) - resource = resource(:file, "foo") - resource[:stage] = 'other' - - lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError) - end - - it "should fail if an unknown stage is specified" do - resource = resource(:class, "foo") - resource[:stage] = 'other' - - lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError) - end - - it "should add edges from the class resources to the parent's stage if no stage is specified" do - main = @compiler.catalog.resource(:stage, :main) - foo_stage = resource(:stage, :foo_stage) - @compiler.add_resource(@scope, foo_stage) - resource = resource(:class, "foo") - @scope.stubs(:resource).returns(:stage => :foo_stage) - @compiler.add_resource(@scope, resource) - - @compiler.catalog.should be_edge(foo_stage, resource) - end - - it "should add edges from top-level class resources to the main stage if no stage is specified" do - main = @compiler.catalog.resource(:stage, :main) - resource = resource(:class, "foo") - @compiler.add_resource(@scope, resource) - - @compiler.catalog.should be_edge(main, resource) - end - it "should not add non-class resources that don't specify a stage to the 'main' stage" do main = @compiler.catalog.resource(:stage, :main) resource = resource(:file, "foo") diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb index 6cdb0553a..48f7304b4 100755 --- a/spec/unit/parser/lexer_spec.rb +++ b/spec/unit/parser/lexer_spec.rb @@ -230,22 +230,6 @@ describe Puppet::Parser::Lexer::TOKENS do end end -describe Puppet::Parser::Lexer::TOKENS[:CLASSNAME] do - before { @token = Puppet::Parser::Lexer::TOKENS[:CLASSNAME] } - - it "should match against lower-case alpha-numeric terms separated by double colons" do - @token.regex.should =~ "one::two" - end - - it "should match against many lower-case alpha-numeric terms separated by double colons" do - @token.regex.should =~ "one::two::three::four::five" - end - - it "should match against lower-case alpha-numeric terms prefixed by double colons" do - @token.regex.should =~ "::one" - end -end - describe Puppet::Parser::Lexer::TOKENS[:CLASSREF] do before { @token = Puppet::Parser::Lexer::TOKENS[:CLASSREF] } @@ -295,6 +279,22 @@ describe Puppet::Parser::Lexer::TOKENS[:NAME] do Puppet::Parser::Lexer::KEYWORDS.expects(:lookup).returns(keyword) @token.convert(stub('lexer'), "false").should == [Puppet::Parser::Lexer::TOKENS[:BOOLEAN], false] end + + it "should match against lower-case alpha-numeric terms separated by double colons" do + @token.regex.should =~ "one::two" + end + + it "should match against many lower-case alpha-numeric terms separated by double colons" do + @token.regex.should =~ "one::two::three::four::five" + end + + it "should match against lower-case alpha-numeric terms prefixed by double colons" do + @token.regex.should =~ "::one" + end + + it "should match against nested terms starting with numbers" do + @token.regex.should =~ "::1one::2two::3three" + end end describe Puppet::Parser::Lexer::TOKENS[:NUMBER] do @@ -445,6 +445,9 @@ describe Puppet::Parser::Lexer,"when lexing strings" do %q["foo$bar$"] => [[:DQPRE,"foo"],[:VARIABLE,"bar"],[:DQPOST,"$"]], %q["foo$$bar"] => [[:DQPRE,"foo$"],[:VARIABLE,"bar"],[:DQPOST,""]], %q[""] => [[:STRING,""]], + %q["123 456 789 0"] => [[:STRING,"123 456 789 0"]], + %q["${123} 456 $0"] => [[:DQPRE,""],[:VARIABLE,"123"],[:DQMID," 456 "],[:VARIABLE,"0"],[:DQPOST,""]], + %q["$foo::::bar"] => [[:DQPRE,""],[:VARIABLE,"foo"],[:DQPOST,"::::bar"]] }.each { |src,expected_result| it "should handle #{src} correctly" do tokens_scanned_from(src).should be_like(*expected_result) @@ -660,10 +663,17 @@ describe "Puppet::Parser::Lexer in the old tests" do end it "should correctly lex variables" do - ["$variable", "$::variable", "$qualified::variable", "$further::qualified::variable"].each do |string| + ["$variable", "$::variable", "$qualified::variable", "$further::qualified::variable", "$hyphenated-variable", "$-variable-with-leading-dash"].each do |string| tokens_scanned_from(string).should be_like([:VARIABLE,string.sub(/^\$/,'')]) end end + + it "should not include whitespace in a variable" do + tokens_scanned_from("$foo bar").should_not be_like([:VARIABLE, "foo bar"]) + end + it "should not include excess colons in a variable" do + tokens_scanned_from("$foo::::bar").should_not be_like([:VARIABLE, "foo::::bar"]) + end end describe "Puppet::Parser::Lexer in the old tests when lexing example files" do diff --git a/spec/unit/parser/resource_spec.rb b/spec/unit/parser/resource_spec.rb index 064f27514..365c4e9c5 100755 --- a/spec/unit/parser/resource_spec.rb +++ b/spec/unit/parser/resource_spec.rb @@ -131,9 +131,19 @@ describe Puppet::Parser::Resource do end describe "when evaluating" do + before do + @node = Puppet::Node.new "test-node" + @compiler = Puppet::Parser::Compiler.new @node + @catalog = Puppet::Resource::Catalog.new + source = stub('source') + source.stubs(:module_name) + @scope = Puppet::Parser::Scope.new(:compiler => @compiler, :source => source) + @catalog.add_resource(Puppet::Parser::Resource.new("stage", :main, :scope => @scope)) + end + it "should evaluate the associated AST definition" do definition = newdefine "mydefine" - res = Puppet::Parser::Resource.new("mydefine", "whatever", :scope => @scope, :source => @source) + res = Puppet::Parser::Resource.new("mydefine", "whatever", :scope => @scope, :source => @source, :catalog => @catalog) definition.expects(:evaluate_code).with(res) res.evaluate @@ -141,17 +151,65 @@ describe Puppet::Parser::Resource do it "should evaluate the associated AST class" do @class = newclass "myclass" - res = Puppet::Parser::Resource.new("class", "myclass", :scope => @scope, :source => @source) + res = Puppet::Parser::Resource.new("class", "myclass", :scope => @scope, :source => @source, :catalog => @catalog) @class.expects(:evaluate_code).with(res) res.evaluate end it "should evaluate the associated AST node" do nodedef = newnode("mynode") - res = Puppet::Parser::Resource.new("node", "mynode", :scope => @scope, :source => @source) + res = Puppet::Parser::Resource.new("node", "mynode", :scope => @scope, :source => @source, :catalog => @catalog) nodedef.expects(:evaluate_code).with(res) res.evaluate end + + it "should add an edge to any specified stage for class resources" do + @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "foo", '') + + other_stage = Puppet::Parser::Resource.new(:stage, "other", :scope => @scope, :catalog => @catalog) + @compiler.add_resource(@scope, other_stage) + resource = Puppet::Parser::Resource.new(:class, "foo", :scope => @scope, :catalog => @catalog) + resource[:stage] = 'other' + @compiler.add_resource(@scope, resource) + + resource.evaluate + + @compiler.catalog.edge?(other_stage, resource).should be_true + end + + it "should fail if an unknown stage is specified" do + @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "foo", '') + + resource = Puppet::Parser::Resource.new(:class, "foo", :scope => @scope, :catalog => @catalog) + resource[:stage] = 'other' + + lambda { resource.evaluate }.should raise_error(ArgumentError, /Could not find stage other specified by/) + end + + it "should add edges from the class resources to the parent's stage if no stage is specified" do + main = @compiler.catalog.resource(:stage, :main) + foo_stage = Puppet::Parser::Resource.new(:stage, :foo_stage, :scope => @scope, :catalog => @catalog) + @compiler.add_resource(@scope, foo_stage) + @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "foo", '') + resource = Puppet::Parser::Resource.new(:class, "foo", :scope => @scope, :catalog => @catalog) + resource[:stage] = 'foo_stage' + @compiler.add_resource(@scope, resource) + + resource.evaluate + + @compiler.catalog.should be_edge(foo_stage, resource) + end + + it "should add edges from top-level class resources to the main stage if no stage is specified" do + main = @compiler.catalog.resource(:stage, :main) + @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "foo", '') + resource = Puppet::Parser::Resource.new(:class, "foo", :scope => @scope, :catalog => @catalog) + @compiler.add_resource(@scope, resource) + + resource.evaluate + + @compiler.catalog.should be_edge(main, resource) + end end describe "when finishing" do diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb index bf4d1e29e..5308856ed 100755 --- a/spec/unit/parser/scope_spec.rb +++ b/spec/unit/parser/scope_spec.rb @@ -121,7 +121,11 @@ describe Puppet::Parser::Scope do def create_class_scope(name) klass = newclass(name) - Puppet::Parser::Resource.new("class", name, :scope => @scope, :source => mock('source')).evaluate + + catalog = Puppet::Resource::Catalog.new + catalog.add_resource(Puppet::Parser::Resource.new("stage", :main, :scope => Puppet::Parser::Scope.new)) + + Puppet::Parser::Resource.new("class", name, :scope => @scope, :source => mock('source'), :catalog => catalog).evaluate @scope.class_scope(klass) end diff --git a/spec/unit/provider/cisco_spec.rb b/spec/unit/provider/cisco_spec.rb index 08320731c..0696221c4 100644..100755 --- a/spec/unit/provider/cisco_spec.rb +++ b/spec/unit/provider/cisco_spec.rb @@ -1,6 +1,5 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../spec_helper' +#!/usr/bin/env rspec +require 'spec_helper' require 'puppet/provider/cisco' @@ -13,4 +12,4 @@ describe Puppet::Provider::Cisco do Puppet::Util::NetworkDevice::Cisco::Device.expects(:new).returns :device Puppet::Provider::Cisco.device(:url).should == :device end -end
\ No newline at end of file +end diff --git a/spec/unit/provider/interface/cisco_spec.rb b/spec/unit/provider/interface/cisco_spec.rb index c18f87cf8..3d400ea4b 100755 --- a/spec/unit/provider/interface/cisco_spec.rb +++ b/spec/unit/provider/interface/cisco_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../spec_helper' +require 'spec_helper' require 'puppet/provider/interface/cisco' diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb index c38a3cfcb..7831dae3a 100755 --- a/spec/unit/provider/mount/parsed_spec.rb +++ b/spec/unit/provider/mount/parsed_spec.rb @@ -193,6 +193,47 @@ FSTAB my_fixtures('*.fstab').each do |fstab| platform = File.basename(fstab, '.fstab') + + describe "when calling instances on #{platform}" do + before :each do + if Facter[:operatingsystem] == "Solaris" then + platform == 'solaris' or + pending "We need to stub the operatingsystem fact at load time, but can't" + else + platform != 'solaris' or + pending "We need to stub the operatingsystem fact at load time, but can't" + end + + # Stub the mount output to our fixture. + begin + mount = my_fixture(platform + '.mount') + @provider.stubs(:mountcmd).returns File.read(mount) + rescue + pending "is #{platform}.mount missing at this point?" + end + + # Note: we have to stub default_target before creating resources + # because it is used by Puppet::Type::Mount.new to populate the + # :target property. + @provider.stubs(:default_target).returns fstab + @retrieve = @provider.instances.collect { |prov| {:name => prov.get(:name), :ensure => prov.get(:ensure)}} + end + + # Following mountpoint are present in all fstabs/mountoutputs + it "should include unmounted resources" do + @retrieve.should include(:name => '/', :ensure => :mounted) + end + + it "should include mounted resources" do + @retrieve.should include(:name => '/boot', :ensure => :unmounted) + end + + it "should include ghost resources" do + @retrieve.should include(:name => '/ghost', :ensure => :ghost) + end + + end + describe "when prefetching on #{platform}" do before :each do if Facter[:operatingsystem] == "Solaris" then diff --git a/spec/unit/provider/nameservice/directoryservice_spec.rb b/spec/unit/provider/nameservice/directoryservice_spec.rb index 47f2ad0cd..7a83d7f20 100755 --- a/spec/unit/provider/nameservice/directoryservice_spec.rb +++ b/spec/unit/provider/nameservice/directoryservice_spec.rb @@ -35,3 +35,63 @@ require 'spec_helper' end end end + +describe 'DirectoryService.single_report' do + it 'should fail on OS X < 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.3") + + lambda { + Puppet::Provider::NameService::DirectoryService.single_report('resource_name') + }.should raise_error(RuntimeError, "Puppet does not support OS X versions < 10.4") + end + + it 'should use url data on 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.4") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + Puppet::Provider::NameService::DirectoryService.stubs(:list_all_present).returns( + ['root', 'user1', 'user2', 'resource_name'] + ) + Puppet::Provider::NameService::DirectoryService.stubs(:generate_attribute_hash) + Puppet::Provider::NameService::DirectoryService.stubs(:execute) + Puppet::Provider::NameService::DirectoryService.expects(:parse_dscl_url_data) + + Puppet::Provider::NameService::DirectoryService.single_report('resource_name') + end + + it 'should use plist data on > 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.5") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + Puppet::Provider::NameService::DirectoryService.stubs(:list_all_present).returns( + ['root', 'user1', 'user2', 'resource_name'] + ) + Puppet::Provider::NameService::DirectoryService.stubs(:generate_attribute_hash) + Puppet::Provider::NameService::DirectoryService.stubs(:execute) + Puppet::Provider::NameService::DirectoryService.expects(:parse_dscl_plist_data) + + Puppet::Provider::NameService::DirectoryService.single_report('resource_name') + end +end + +describe 'DirectoryService.get_exec_preamble' do + it 'should fail on OS X < 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.3") + + lambda { + Puppet::Provider::NameService::DirectoryService.get_exec_preamble('-list') + }.should raise_error(RuntimeError, "Puppet does not support OS X versions < 10.4") + end + + it 'should use url data on 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.4") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + + Puppet::Provider::NameService::DirectoryService.get_exec_preamble('-list').should include("-url") + end + + it 'should use plist data on > 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.5") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + + Puppet::Provider::NameService::DirectoryService.get_exec_preamble('-list').should include("-plist") + end +end diff --git a/spec/unit/provider/network_device_spec.rb b/spec/unit/provider/network_device_spec.rb index e2a87cf4e..aae6ad68a 100755 --- a/spec/unit/provider/network_device_spec.rb +++ b/spec/unit/provider/network_device_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' require 'puppet/provider/network_device' require 'ostruct' diff --git a/spec/unit/provider/package/pkgutil_spec.rb b/spec/unit/provider/package/pkgutil_spec.rb index 5549b3f6d..dcae21250 100755 --- a/spec/unit/provider/package/pkgutil_spec.rb +++ b/spec/unit/provider/package/pkgutil_spec.rb @@ -1,6 +1,5 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../../spec_helper' +#!/usr/bin/env rspec +require 'spec_helper' provider = Puppet::Type.type(:package).provider(:pkgutil) diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb index 69d29c674..bd5e55a9e 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb @@ -9,23 +9,19 @@ describe provider_class do include PuppetSpec::Files before :each do - @sshauthkey_class = Puppet::Type.type(:ssh_authorized_key) - @provider = @sshauthkey_class.provider(:parsed) @keyfile = tmpfile('authorized_keys') - @provider.any_instance.stubs(:target).returns @keyfile + @provider_class = provider_class + @provider_class.initvars + @provider_class.any_instance.stubs(:target).returns @keyfile @user = 'random_bob' Puppet::Util.stubs(:uid).with(@user).returns 12345 end - after :each do - @provider.initvars - end - def mkkey(args) args[:target] = @keyfile args[:user] = @user resource = Puppet::Type.type(:ssh_authorized_key).new(args) - key = @provider.new(resource) + key = @provider_class.new(resource) args.each do |p,v| key.send(p.to_s + "=", v) end @@ -33,26 +29,26 @@ describe provider_class do end def genkey(key) - @provider.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) + @provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) File.stubs(:chown) File.stubs(:chmod) Puppet::Util::SUIDManager.stubs(:asuser).yields key.flush - @provider.target_object(@keyfile).read + @provider_class.target_object(@keyfile).read end it_should_behave_like "all parsedfile providers", provider_class it "should be able to generate a basic authorized_keys file" do - key = mkkey(:name => "Just Testing", + key = mkkey(:name => "Just_Testing", :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", :type => "ssh-dss", :ensure => :present, :options => [:absent] ) - genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just Testing\n" + genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just_Testing\n" end it "should be able to generate a authorized_keys file with options" do @@ -71,25 +67,25 @@ describe provider_class do options = %w{from="host1.reductlivelabs.com,host.reductivelabs.com" command="/usr/local/bin/run" ssh-pty} optionstr = options.join(", ") - @provider.parse_options(optionstr).should == options + @provider_class.parse_options(optionstr).should == options end it "should use '' as name for entries that lack a comment" do line = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAut8aOSxenjOqF527dlsdHWV4MNoAsX14l9M297+SQXaQ5Z3BedIxZaoQthkDALlV/25A1COELrg9J2MqJNQc8Xe9XQOIkBQWWinUlD/BXwoOTWEy8C8zSZPHZ3getMMNhGTBO+q/O+qiJx3y5cA4MTbw2zSxukfWC87qWwcZ64UUlegIM056vPsdZWFclS9hsROVEa57YUMrehQ1EGxT4Z5j6zIopufGFiAPjZigq/vqgcAqhAKP6yu4/gwO6S9tatBeEjZ8fafvj1pmvvIplZeMr96gHE7xS3pEEQqnB3nd4RY7AF6j9kFixnsytAUO7STPh/M3pLiVQBN89TvWPQ==" - @provider.parse(line)[0][:name].should == "" + @provider_class.parse(line)[0][:name].should == "" end end describe provider_class do before :each do - @resource = stub("resource", :name => "foo") - @resource.stubs(:[]).returns "foo" - @resource.class.stubs(:key_attributes).returns( [:name] ) + @resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :user => "random_bob") @provider = provider_class.new(@resource) provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) Puppet::Util::SUIDManager.stubs(:asuser).yields + + provider_class.initvars end describe "when flushing" do @@ -103,9 +99,9 @@ describe provider_class do describe "and both a user and a target have been specified" do before :each do Puppet::Util.stubs(:uid).with("random_bob").returns 12345 - @resource.stubs(:should).with(:user).returns "random_bob" + @resource[:user] = "random_bob" target = "/tmp/.ssh_dir/place_to_put_authorized_keys" - @resource.stubs(:should).with(:target).returns target + @resource[:target] = target end it "should create the directory" do @@ -134,8 +130,7 @@ describe provider_class do describe "and a user has been specified with no target" do before :each do - @resource.stubs(:should).with(:user).returns "nobody" - @resource.stubs(:should).with(:target).returns nil + @resource[:user] = "nobody" # # I'd like to use random_bob here and something like # @@ -186,26 +181,20 @@ describe provider_class do end describe "and a target has been specified with no user" do - before :each do - @resource.stubs(:should).with(:user).returns nil - @resource.stubs(:should).with(:target).returns("/tmp/.ssh_dir/place_to_put_authorized_keys") - end - it "should raise an error" do + @resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :target => "/tmp/.ssh_dir/place_to_put_authorized_keys") + @provider = provider_class.new(@resource) + proc { @provider.flush }.should raise_error end end describe "and a invalid user has been specified with no target" do - before :each do - @resource.stubs(:should).with(:user).returns "thisusershouldnotexist" - @resource.stubs(:should).with(:target).returns nil - end - it "should catch an exception and raise a Puppet error" do + @resource[:user] = "thisusershouldnotexist" + lambda { @provider.flush }.should raise_error(Puppet::Error) end end - end end diff --git a/spec/unit/provider/vlan/cisco_spec.rb b/spec/unit/provider/vlan/cisco_spec.rb index a67290eb4..4753cea21 100755 --- a/spec/unit/provider/vlan/cisco_spec.rb +++ b/spec/unit/provider/vlan/cisco_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../spec_helper' +require 'spec_helper' require 'puppet/provider/vlan/cisco' diff --git a/spec/unit/rails/host_spec.rb b/spec/unit/rails/host_spec.rb index df0b2fa1d..98541c0a8 100755 --- a/spec/unit/rails/host_spec.rb +++ b/spec/unit/rails/host_spec.rb @@ -1,6 +1,8 @@ #!/usr/bin/env rspec require 'spec_helper' +require 'puppet/node/environment' + describe "Puppet::Rails::Host", :if => Puppet.features.rails? do def column(name, type) ActiveRecord::ConnectionAdapters::Column.new(name, nil, type, false) @@ -42,6 +44,12 @@ describe "Puppet::Rails::Host", :if => Puppet.features.rails? do Puppet::Rails::Host.from_puppet(@node) end + it "should stringify the environment" do + host = Puppet::Rails::Host.new + host.environment = Puppet::Node::Environment.new("production") + host.environment.class.should == String + end + it "should copy the ipaddress from the Puppet instance" do Puppet::Rails::Host.expects(:find_by_name).with("foo").returns @host diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 4c58cc47a..3a01d09c1 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -168,6 +168,25 @@ describe Puppet::Type.type(:file) do reqs[0].target.must == file end + it "should autorequire its nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "/foo/bar/baz") + dir = Puppet::Type::File.new(:path => "/foo") + root = Puppet::Type::File.new(:path => "/") + @catalog.add_resource file + @catalog.add_resource dir + @catalog.add_resource root + reqs = file.autorequire + reqs.length.must == 1 + reqs[0].source.must == dir + reqs[0].target.must == file + end + + it "should not autorequire anything when there is no nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "/foo/bar/baz") + @catalog.add_resource file + file.autorequire.should be_empty + end + it "should not autorequire its parent dir if its parent dir is itself" do file = Puppet::Type::File.new(:path => "/") @catalog.add_resource file @@ -241,6 +260,25 @@ describe Puppet::Type.type(:file) do reqs[0].target.must == file end + it "should autorequire its nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "X:/foo/bar/baz") + dir = Puppet::Type::File.new(:path => "X:/foo") + root = Puppet::Type::File.new(:path => "X:/") + @catalog.add_resource file + @catalog.add_resource dir + @catalog.add_resource root + reqs = file.autorequire + reqs.length.must == 1 + reqs[0].source.must == dir + reqs[0].target.must == file + end + + it "should not autorequire anything when there is no nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "X:/foo/bar/baz") + @catalog.add_resource file + file.autorequire.should be_empty + end + it "should not autorequire its parent dir if its parent dir is itself" do file = Puppet::Type::File.new(:path => "X:/") @catalog.add_resource file @@ -302,6 +340,25 @@ describe Puppet::Type.type(:file) do reqs[0].target.must == file end + it "should autorequire its nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux") + dir = Puppet::Type::File.new(:path => "//server/foo/bar") + root = Puppet::Type::File.new(:path => "//server/foo") + @catalog.add_resource file + @catalog.add_resource dir + @catalog.add_resource root + reqs = file.autorequire + reqs.length.must == 1 + reqs[0].source.must == dir + reqs[0].target.must == file + end + + it "should not autorequire anything when there is no nearest ancestor directory" do + file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux") + @catalog.add_resource file + file.autorequire.should be_empty + end + it "should not autorequire its parent dir if its parent dir is itself" do file = Puppet::Type::File.new(:path => "//server/foo") @catalog.add_resource file diff --git a/spec/unit/type/interface_spec.rb b/spec/unit/type/interface_spec.rb index 12ba225d9..74e3257f6 100755 --- a/spec/unit/type/interface_spec.rb +++ b/spec/unit/type/interface_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' describe Puppet::Type.type(:interface) do diff --git a/spec/unit/type/ssh_authorized_key_spec.rb b/spec/unit/type/ssh_authorized_key_spec.rb index a5f167165..71b8a9ab0 100755 --- a/spec/unit/type/ssh_authorized_key_spec.rb +++ b/spec/unit/type/ssh_authorized_key_spec.rb @@ -16,115 +16,223 @@ describe ssh_authorized_key do @catalog = Puppet::Resource::Catalog.new end - it "should have a name parameter" do - @class.attrtype(:name).should == :param - end - it "should have :name be its namevar" do @class.key_attributes.should == [:name] end - it "should have a :provider parameter" do - @class.attrtype(:provider).should == :param - end + describe "when validating attributes" do - it "should have an ensure property" do - @class.attrtype(:ensure).should == :property - end + [:name, :provider].each do |param| + it "should have a #{param} parameter" do + @class.attrtype(param).should == :param + end + end - it "should support :present as a value for :ensure" do - proc { @class.new(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error - end + [:type, :key, :user, :target, :options, :ensure].each do |property| + it "should have a #{property} property" do + @class.attrtype(property).should == :property + end + end - it "should support :absent as a value for :ensure" do - proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error end - it "should have an type property" do - @class.attrtype(:type).should == :property - end - it "should support ssh-dss as an type value" do - proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error - end - it "should support ssh-rsa as an type value" do - proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error - end - it "should support :dsa as an type value" do - proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error - end - it "should support :rsa as an type value" do - proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error - end + describe "when validating values" do - it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa in the ssh_authorized_key_type" do - proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error) - end + describe "for name" do - it "should have an key property" do - @class.attrtype(:key).should == :property - end + it "should support valid names" do + proc { @class.new(:name => "username", :ensure => :present, :user => "nobody") }.should_not raise_error + proc { @class.new(:name => "username@hostname", :ensure => :present, :user => "nobody") }.should_not raise_error + end - it "should have an user property" do - @class.attrtype(:user).should == :property - end + it "should not support whitespaces" do + proc { @class.new(:name => "my test", :ensure => :present, :user => "nobody") }.should raise_error(Puppet::Error,/Resourcename must not contain whitespace/) + proc { @class.new(:name => "my\ttest", :ensure => :present, :user => "nobody") }.should raise_error(Puppet::Error,/Resourcename must not contain whitespace/) + end - it "should have an options property" do - @class.attrtype(:options).should == :property - end + end - it "'s options property should return well formed string of arrays from is_to_s" do - resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + describe "for ensure" do - resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c" - end + it "should support :present" do + proc { @class.new(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error + end - it "'s options property should return well formed string of arrays from is_to_s" do - resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + it "should support :absent" do + proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error + end - resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c" - end + it "should not support other values" do + proc { @class.new(:name => "whev", :ensure => :foo, :user => "nobody") }.should raise_error(Puppet::Error, /Invalid value/) + end + + end + + describe "for type" do + + + it "should support ssh-dss" do + proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error + end + + it "should support ssh-rsa" do + proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error + end + + it "should support :dsa" do + proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error + end + + it "should support :rsa" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error + end + + it "should alias :rsa to :ssh-rsa" do + key = @class.new(:name => "whev", :type => :rsa, :user => "nobody") + key.should(:type).should == :'ssh-rsa' + end + + it "should alias :dsa to :ssh-dss" do + key = @class.new(:name => "whev", :type => :dsa, :user => "nobody") + key.should(:type).should == :'ssh-dss' + end + + it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa" do + proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error,/Invalid value/) + end + + end + + describe "for key" do + + it "should support a valid key like a 1024 bit rsa key" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCPfzW2ry7XvMc6E5Kj2e5fF/YofhKEvsNMUogR3PGL/HCIcBlsEjKisrY0aYgD8Ikp7ZidpXLbz5dBsmPy8hJiBWs5px9ZQrB/EOQAwXljvj69EyhEoGawmxQMtYw+OAIKHLJYRuk1QiHAMHLp5piqem8ZCV2mLb9AsJ6f7zUVw==')}.should_not raise_error + end + + it "should support a valid key like a 4096 bit rsa key" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAAAB3NzaC1yc2EAAAADAQABAAACAQDEY4pZFyzSfRc9wVWI3DfkgT/EL033UZm/7x1M+d+lBD00qcpkZ6CPT7lD3Z+vylQlJ5S8Wcw6C5Smt6okZWY2WXA9RCjNJMIHQbJAzwuQwgnwU/1VMy9YPp0tNVslg0sUUgpXb13WW4mYhwxyGmIVLJnUrjrQmIFhtfHsJAH8ZVqCWaxKgzUoC/YIu1u1ScH93lEdoBPLlwm6J0aiM7KWXRb7Oq1nEDZtug1zpX5lhgkQWrs0BwceqpUbY+n9sqeHU5e7DCyX/yEIzoPRW2fe2Gx1Iq6JKM/5NNlFfaW8rGxh3Z3S1NpzPHTRjw8js3IeGiV+OPFoaTtM1LsWgPDSBlzIdyTbSQR7gKh0qWYCNV/7qILEfa0yIFB5wIo4667iSPZw2pNgESVtenm8uXyoJdk8iWQ4mecdoposV/znknNb2GPgH+n/2vme4btZ0Sl1A6rev22GQjVgbWOn8zaDglJ2vgCN1UAwmq41RXprPxENGeLnWQppTnibhsngu0VFllZR5kvSIMlekLRSOFLFt92vfd+tk9hZIiKm9exxcbVCGGQPsf6dZ27rTOmg0xM2Sm4J6RRKuz79HQgA4Eg18+bqRP7j/itb89DmtXEtoZFAsEJw8IgIfeGGDtHTkfAlAC92mtK8byeaxGq57XCTKbO/r5gcOMElZHy1AcB8kw==')}.should_not raise_error + end + + it "should support a valid key like a 1024 bit dsa key" do + proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody", :key => 'AAAAB3NzaC1kc3MAAACBAI80iR78QCgpO4WabVqHHdEDigOjUEHwIjYHIubR/7u7DYrXY+e+TUmZ0CVGkiwB/0yLHK5dix3Y/bpj8ZiWCIhFeunnXccOdE4rq5sT2V3l1p6WP33RpyVYbLmeuHHl5VQ1CecMlca24nHhKpfh6TO/FIwkMjghHBfJIhXK+0w/AAAAFQDYzLupuMY5uz+GVrcP+Kgd8YqMmwAAAIB3SVN71whLWjFPNTqGyyIlMy50624UfNOaH4REwO+Of3wm/cE6eP8n75vzTwQGBpJX3BPaBGW1S1Zp/DpTOxhCSAwZzAwyf4WgW7YyAOdxN3EwTDJZeyiyjWMAOjW9/AOWt9gtKg0kqaylbMHD4kfiIhBzo31ZY81twUzAfN7angAAAIBfva8sTSDUGKsWWIXkdbVdvM4X14K4gFdy0ZJVzaVOtZ6alysW6UQypnsl6jfnbKvsZ0tFgvcX/CPyqNY/gMR9lyh/TCZ4XQcbqeqYPuceGehz+jL5vArfqsW2fJYFzgCcklmr/VxtP5h6J/T0c9YcDgc/xIfWdZAlznOnphI/FA==')}.should_not raise_error + end + + it "should not support whitespaces" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAA FA==')}.should raise_error(Puppet::Error,/Key must not contain whitespace/) + end + + end + + describe "for options" do + + it "should support flags as options" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'cert-authority')}.should_not raise_error + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'no-port-forwarding')}.should_not raise_error + end + + it "should support key-value pairs as options" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'command="command"')}.should_not raise_error + end + + it "should support environments as options" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'environment="NAME=value"')}.should_not raise_error + end + + it "should support multiple options as an array" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ['cert-authority','environment="NAME=value"'])}.should_not raise_error + end + + it "should not support a comma separated lists" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'cert-authority,no-port-forwarding')}.should raise_error(Puppet::Error, /must be provided as an array/) + end + + it "should use :absent as a default value" do + @class.new(:name => "whev", :type => :rsa, :user => "nobody").should(:options).should == [:absent] + end + + it "property should return well formed string of arrays from is_to_s" do + resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c" + end + + it "property should return well formed string of arrays from is_to_s" do + resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c" + end + + end + + describe "for user" do + + it "should support present users" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "root") }.should_not raise_error + end + + it "should support absent users" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "ihopeimabsent") }.should_not raise_error + end + + end + + describe "for target" do + + it "should support absolute paths" do + proc { @class.new(:name => "whev", :type => :rsa, :target => "/tmp/here") }.should_not raise_error + end + + it "should use the user's path if not explicitly specified" do + @class.new(:name => "whev", :user => 'root').should(:target).should == File.expand_path("~root/.ssh/authorized_keys") + end + + it "should not consider the user's path if explicitly specified" do + @class.new(:name => "whev", :user => 'root', :target => '/tmp/here').should(:target).should == '/tmp/here' + end + + it "should inform about an absent user" do + Puppet::Log.level = :debug + @class.new(:name => "whev", :user => 'idontexist').should(:target) + @logs.map(&:message).should include("The required user is not yet present on the system") + end + + end - it "should have a target property" do - @class.attrtype(:target).should == :property end describe "when neither user nor target is specified" do + it "should raise an error" do proc do - - @class.create( - + @class.new( :name => "Test", :key => "AAA", :type => "ssh-rsa", - :ensure => :present) - end.should raise_error(Puppet::Error) + end.should raise_error(Puppet::Error,/user.*or.*target.*mandatory/) end + end describe "when both target and user are specified" do - it "should use target" do - - resource = @class.create( + it "should use target" do + resource = @class.new( :name => "Test", :user => "root", - - :target => "/tmp/blah") + :target => "/tmp/blah" + ) resource.should(:target).should == "/tmp/blah" end + end describe "when user is specified" do - it "should determine target" do + it "should determine target" do resource = @class.create( - :name => "Test", - - :user => "root") + :user => "root" + ) target = File.expand_path("~root/.ssh/authorized_keys") resource.should(:target).should == target end @@ -135,17 +243,19 @@ describe ssh_authorized_key do target = File.expand_path("~root/.ssh/authorized_keys") resource.property(:target).safe_insync?(target).should == true end + end describe "when calling validate" do - it "should not crash on a non-existant user" do + it "should not crash on a non-existant user" do resource = @class.create( - :name => "Test", - - :user => "ihopesuchuserdoesnotexist") + :user => "ihopesuchuserdoesnotexist" + ) proc { resource.validate }.should_not raise_error end + end + end diff --git a/spec/unit/type/vlan_spec.rb b/spec/unit/type/vlan_spec.rb index 3bee14bbd..7d7a0b178 100755 --- a/spec/unit/type/vlan_spec.rb +++ b/spec/unit/type/vlan_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../spec_helper' +require 'spec_helper' describe Puppet::Type.type(:vlan) do diff --git a/spec/unit/util/network_device/cisco/device_spec.rb b/spec/unit/util/network_device/cisco/device_spec.rb index 8971205d3..1c5a1a6c5 100755 --- a/spec/unit/util/network_device/cisco/device_spec.rb +++ b/spec/unit/util/network_device/cisco/device_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../../spec_helper' +require 'spec_helper' require 'puppet/util/network_device/cisco/device' diff --git a/spec/unit/util/network_device/cisco/facts_spec.rb b/spec/unit/util/network_device/cisco/facts_spec.rb index bb29ac292..66842fdf0 100644..100755 --- a/spec/unit/util/network_device/cisco/facts_spec.rb +++ b/spec/unit/util/network_device/cisco/facts_spec.rb @@ -1,6 +1,5 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../../../spec_helper' +#!/usr/bin/env rspec +require 'spec_helper' require 'puppet/util/network_device' require 'puppet/util/network_device/cisco/facts' diff --git a/spec/unit/util/network_device/cisco/interface_spec.rb b/spec/unit/util/network_device/cisco/interface_spec.rb index 24217750c..b0561c6fd 100755 --- a/spec/unit/util/network_device/cisco/interface_spec.rb +++ b/spec/unit/util/network_device/cisco/interface_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../../spec_helper' +require 'spec_helper' require 'puppet/util/network_device' require 'puppet/util/network_device/cisco/interface' diff --git a/spec/unit/util/network_device/config_spec.rb b/spec/unit/util/network_device/config_spec.rb index 52796f30b..d69358a92 100644..100755 --- a/spec/unit/util/network_device/config_spec.rb +++ b/spec/unit/util/network_device/config_spec.rb @@ -1,6 +1,5 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../../spec_helper' +#!/usr/bin/env rspec +require 'spec_helper' require 'puppet/util/network_device/config' @@ -99,4 +98,4 @@ describe Puppet::Util::NetworkDevice::Config do end end -end
\ No newline at end of file +end diff --git a/spec/unit/util/network_device/ipcalc_spec.rb b/spec/unit/util/network_device/ipcalc_spec.rb index 0418c6a84..82c5390a4 100755 --- a/spec/unit/util/network_device/ipcalc_spec.rb +++ b/spec/unit/util/network_device/ipcalc_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../spec_helper' +require 'spec_helper' require 'puppet/util/network_device/ipcalc' diff --git a/spec/unit/util/network_device/transport/base_spec.rb b/spec/unit/util/network_device/transport/base_spec.rb index c186d72e5..f05a62fbb 100755 --- a/spec/unit/util/network_device/transport/base_spec.rb +++ b/spec/unit/util/network_device/transport/base_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../../spec_helper' +require 'spec_helper' require 'puppet/util/network_device/transport/base' diff --git a/spec/unit/util/network_device/transport/ssh_spec.rb b/spec/unit/util/network_device/transport/ssh_spec.rb index 8fc357db3..04a86ba3f 100755 --- a/spec/unit/util/network_device/transport/ssh_spec.rb +++ b/spec/unit/util/network_device/transport/ssh_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../../spec_helper' +require 'spec_helper' require 'puppet/util/network_device/transport/ssh' diff --git a/spec/unit/util/network_device/transport/telnet_spec.rb b/spec/unit/util/network_device/transport/telnet_spec.rb index 7528e0740..cea5ab79a 100755 --- a/spec/unit/util/network_device/transport/telnet_spec.rb +++ b/spec/unit/util/network_device/transport/telnet_spec.rb @@ -1,6 +1,5 @@ #!/usr/bin/env rspec - -require File.dirname(__FILE__) + '/../../../../spec_helper' +require 'spec_helper' require 'puppet/util/network_device/transport/telnet' diff --git a/spec/unit/util/network_device_spec.rb b/spec/unit/util/network_device_spec.rb index 347986ac6..0f7c6036b 100644 --- a/spec/unit/util/network_device_spec.rb +++ b/spec/unit/util/network_device_spec.rb @@ -11,7 +11,7 @@ describe Puppet::Util::NetworkDevice do end after(:each) do - Puppet::Util::NetworkDevice.clear + Puppet::Util::NetworkDevice.teardown end class Puppet::Util::NetworkDevice::Test @@ -47,4 +47,4 @@ describe Puppet::Util::NetworkDevice do Puppet::Util::NetworkDevice.current.should == device end end -end
\ No newline at end of file +end |
