diff options
| author | Pieter van de Bruggen <pieter@puppetlabs.com> | 2011-05-18 15:36:36 -0700 |
|---|---|---|
| committer | Pieter van de Bruggen <pieter@puppetlabs.com> | 2011-05-18 15:36:36 -0700 |
| commit | b87a1dea704ed981f2f0af728afac2c63e87b5a8 (patch) | |
| tree | db7e191629d5de3cadf388fb35ca71c5fe32a283 /spec/unit | |
| parent | b63fd841a188f9b21aed40c7b2f046a144fd37c9 (diff) | |
| parent | 7941336d6b91945c02bc6e79f72720f6048f4e64 (diff) | |
Merge branch 'next'
Diffstat (limited to 'spec/unit')
20 files changed, 57 insertions, 67 deletions
diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb index df8cd3eaf..464827e3c 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/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/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/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/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/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/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' |
