On 28 January 2011 18:44, Daniel Pittman <[email protected]> wrote:
> From: Daniel Pittman <[email protected]>
>
> We have moved to rspec2 for puppet, and facter should follow suit.
+1 with minor query
> ---
> Rakefile | 14 ++++++++------
> spec/Rakefile | 18 ------------------
> spec/spec_helper.rb | 4 ++--
> spec/unit/operatingsystemrelease.rb | 2 +-
> spec/unit/uptime.rb | 6 +++---
> spec/unit/util/macaddress.rb | 10 +++++-----
> spec/unit/util/uptime.rb | 10 +++++-----
> spec/unit/util/virtual.rb | 2 +-
> spec/unit/util/xendomains.rb | 2 +-
> 9 files changed, 26 insertions(+), 42 deletions(-)
> delete mode 100644 spec/Rakefile
> mode change 100644 => 100755 spec/unit/operatingsystemrelease.rb
> mode change 100644 => 100755 spec/unit/uptime.rb
> mode change 100644 => 100755 spec/unit/util/macaddress.rb
> mode change 100644 => 100755 spec/unit/util/uptime.rb
> mode change 100644 => 100755 spec/unit/util/xendomains.rb
>
> diff --git a/Rakefile b/Rakefile
> index ba939be..9b79613 100644
> --- a/Rakefile
> +++ b/Rakefile
> @@ -4,8 +4,8 @@ $: << File.expand_path('lib')
> $LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks')
>
> require 'rubygems'
> -require 'spec'
> -require 'spec/rake/spectask'
> +require 'rspec'
> +require 'rspec/core/rake_task'
> begin
> require 'rcov'
> rescue LoadError
> @@ -62,12 +62,14 @@ task :default do
> sh %{rake -T}
> end
>
> -Spec::Rake::SpecTask.new(:spec) do |t|
> - t.spec_files = FileList['spec/**/*.rb']
> +RSpec::Core::RakeTask.new do |t|
> + t.pattern ='spec/{unit,integration}/**/*.rb'
> + t.fail_on_error = false
> end
>
> -Spec::Rake::SpecTask.new('spec:rcov') do |t|
> - t.spec_files = FileList['spec/**/*.rb']
> +RSpec::Core::RakeTask.new('spec:rcov') do |t|
> + t.pattern ='spec/{unit,integration}/**/*.rb'
> + t.fail_on_error = false
> if defined?(Rcov)
> t.rcov = true
> t.rcov_opts = ['--exclude',
> 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*']
> diff --git a/spec/Rakefile b/spec/Rakefile
> deleted file mode 100644
> index e2996f6..0000000
> --- a/spec/Rakefile
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -require File.join(File.dirname(__FILE__), "spec_helper.rb")
> -require 'rake'
> -require 'spec/rake/spectask'
> -
> -basedir = File.dirname(__FILE__)
> -puppetlibdir = File.join(basedir, "../lib")
> -puppettestlibdir = File.join(basedir, "../test/lib")
> -speclibdir = File.join(basedir, "lib")
> -
> -libs = [puppetlibdir, puppettestlibdir, speclibdir]
> -desc "Run all specs"
> -Spec::Rake::SpecTask.new('all') do |t|
> - t.spec_files = FileList['integration/**/*.rb', 'unit/**/*.rb']
> - t.libs = libs
> - t.spec_opts = ['--options', 'spec.opts']
> -end
> -
> -task :default => [:all]
> diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
> index c8bd547..d9db445 100644
> --- a/spec/spec_helper.rb
> +++ b/spec/spec_helper.rb
> @@ -7,12 +7,12 @@ $LOAD_PATH.unshift("#{dir}/../lib")
>
> require 'rubygems'
> require 'mocha'
> -require 'spec'
> +require 'rspec'
> require 'facter'
>
> # load any monkey-patches
> Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file }
>
> -Spec::Runner.configure do |config|
> +RSpec.configure do |config|
> config.mock_with :mocha
> end
> diff --git a/spec/unit/operatingsystemrelease.rb
> b/spec/unit/operatingsystemrelease.rb
> old mode 100644
> new mode 100755
> index 31d4ae8..5c821c3
> --- a/spec/unit/operatingsystemrelease.rb
> +++ b/spec/unit/operatingsystemrelease.rb
> @@ -26,7 +26,7 @@ describe "Operating System Release fact" do
> }
>
> test_cases.each do |system, file|
> - context "with operatingsystem reported as #{system.inspect}" do
> + describe "with operatingsystem reported as #{system.inspect}" do
> it "should read the #{file.inspect} file" do
> Facter.fact(:operatingsystem).stubs(:value).returns(system)
>
> diff --git a/spec/unit/uptime.rb b/spec/unit/uptime.rb
> old mode 100644
> new mode 100755
> index 19a55fe..fc592e3
> --- a/spec/unit/uptime.rb
> +++ b/spec/unit/uptime.rb
> @@ -9,7 +9,7 @@ describe "uptime facts:" do
> before { Facter.clear }
> after { Facter.clear }
>
> - context "when uptime information is available" do
> + describe "when uptime information is available" do
> describe "uptime" do
> test_cases = [
> [60 * 60 * 24 * 3, '3 days'],
> @@ -34,7 +34,7 @@ describe "uptime facts:" do
>
> end
>
> - context "when uptime information is available" do
> + describe "when uptime information is available" do
> before do
> Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(60 * 60 *
> 24 + 23)
> Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(60 * 60 *
> 24 + 23)
> @@ -59,7 +59,7 @@ describe "uptime facts:" do
> end
> end
>
> - context "when uptime information is not available" do
> + describe "when uptime information is not available" do
> before do
> Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(nil)
> Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(nil)
> diff --git a/spec/unit/util/macaddress.rb b/spec/unit/util/macaddress.rb
> old mode 100644
> new mode 100755
> index 1ccca18..09794ec
> --- a/spec/unit/util/macaddress.rb
> +++ b/spec/unit/util/macaddress.rb
> @@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
>
> require 'facter/util/macaddress'
>
> -context "Darwin" do
> +describe "Darwin" do
> test_cases = [
> # version, iface, real macaddress, fallback macaddress
> ["9.8.0", 'en0', "00:17:f2:06:e4:2e", "00:17:f2:06:e4:2e"],
> @@ -17,12 +17,12 @@ context "Darwin" do
> ifconfig_file_no_iface = File.join(SPECDIR, "fixtures", "ifconfig",
> "darwin_#{version.tr('.', '_')}")
> ifconfig_file = "#{ifconfig_file_no_iface}_#{default_iface}"
>
> - context "version #{version}" do
> + describe "version #{version}" do
>
> describe Facter::Util::Macaddress::Darwin do
>
> describe ".default_interface" do
> - context "when netstat has a default interface" do
> + describe "when netstat has a default interface" do
>
> before do
>
> Facter::Util::Macaddress::Darwin.stubs(:netstat_command).returns("cat
> \"#{netstat_file}\"")
> @@ -36,7 +36,7 @@ context "Darwin" do
> end
>
> describe ".macaddress" do
> - context "when netstat has a default interface" do
> + describe "when netstat has a default interface" do
> before do
> Facter.stubs(:warn)
>
> Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns('')
> @@ -49,7 +49,7 @@ context "Darwin" do
>
> end
>
> - context "when netstat does not have a default interface"
> do
> + describe "when netstat does not have a default
> interface" do
> before do
>
> Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns("")
>
> Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat
> \"#{ifconfig_file_no_iface}\"")
> diff --git a/spec/unit/util/uptime.rb b/spec/unit/util/uptime.rb
> old mode 100644
> new mode 100755
> index b7e3089..c104856
> --- a/spec/unit/util/uptime.rb
> +++ b/spec/unit/util/uptime.rb
> @@ -7,7 +7,7 @@ require 'facter/util/uptime'
> describe Facter::Util::Uptime do
>
> describe ".get_uptime_seconds_unix" do
> - context "when /proc/uptime is available" do
> + describe "when /proc/uptime is available" do
I thought context within describe is still supported
http://relishapp.com/rspec/rspec-core/v/2-4/file/upgrade
I don't feel strongly about this though. Lets get the update commited
and we can always improve specific test naming/structure.
> before do
> uptime_file = File.join(SPECDIR, "fixtures", "uptime",
> "ubuntu_proc_uptime")
> Facter::Util::Uptime.stubs(:uptime_file).returns("\"#{uptime_file}\"")
> @@ -19,7 +19,7 @@ describe Facter::Util::Uptime do
>
> end
>
> - context "when /proc/uptime is not available" do
> + describe "when /proc/uptime is not available" do
> before :each do
> @nonexistent_file = '/non/existent/file'
> File.exists?(@nonexistent_file).should == false
> @@ -33,7 +33,7 @@ describe Facter::Util::Uptime do
> Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
> end
>
> - context "nor is 'sysctl kern.boottime'" do
> + describe "nor is 'sysctl kern.boottime'" do
> before :each do
> Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat
> \"#{@nonexistent_file}\"")
> end
> @@ -45,7 +45,7 @@ describe Facter::Util::Uptime do
> Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
> end
>
> - context "nor is 'kstat -p unix:::boot_time'" do
> + describe "nor is 'kstat -p unix:::boot_time'" do
> before :each do
> Facter::Util::Uptime.stubs(:uptime_kstat_cmd).returns("cat
> \"#{@nonexistent_file}\"")
> end
> @@ -57,7 +57,7 @@ describe Facter::Util::Uptime do
> Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
> end
>
> - context "nor is 'who -b'" do
> + describe "nor is 'who -b'" do
> before :each do
> Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat
> \"#{@nonexistent_file}\"")
> end
> diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb
> index 72186f7..66dc98c 100644
> --- a/spec/unit/util/virtual.rb
> +++ b/spec/unit/util/virtual.rb
> @@ -67,7 +67,7 @@ describe Facter::Util::Virtual do
> ]
>
> test_cases.each do |status_file, expected, description|
> - context "with /proc/self/status from #{description}" do
> + describe "with /proc/self/status from #{description}" do
> it "should detect vserver as #{expected.inspect}" do
> status = File.read(status_file)
>
> FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
> diff --git a/spec/unit/util/xendomains.rb b/spec/unit/util/xendomains.rb
> old mode 100644
> new mode 100755
> index a0fa345..bd9c5d5
> --- a/spec/unit/util/xendomains.rb
> +++ b/spec/unit/util/xendomains.rb
> @@ -13,7 +13,7 @@ describe Facter::Util::Xendomains do
> Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
> end
>
> - context "when xm list isn't executable" do
> + describe "when xm list isn't executable" do
> it "should be nil" do
> Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm
> list').returns(nil)
> Facter::Util::Xendomains.get_domains.should == nil
> --
> 1.7.3.5
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.