diff options
author | Markus Roberts <Markus@reality.com> | 2010-06-28 16:32:11 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-06-28 16:32:11 -0700 |
commit | 9ceb4540a567b0a9de85af5397df4a292303a9c3 (patch) | |
tree | 30d1e1601888381baaaa14bfc5ee7246fd5c78e8 /spec/unit/run_spec.rb | |
parent | 85638cf427fe9b35d3e3b0fa4ce919c5806c60d3 (diff) | |
download | puppet-9ceb4540a567b0a9de85af5397df4a292303a9c3.tar.gz puppet-9ceb4540a567b0a9de85af5397df4a292303a9c3.tar.xz puppet-9ceb4540a567b0a9de85af5397df4a292303a9c3.zip |
[#3994-part 2] rename integration tests to *_spec.rb
Some spec files like active_record.rb had names that would confuse the
load path and get loaded instead of the intended implentation when the
spec was run from the same directory as the file.
Author: Matt Robinson <matt@puppetlabs.com>
Date: Fri Jun 11 15:29:33 2010 -0700
Diffstat (limited to 'spec/unit/run_spec.rb')
-rwxr-xr-x | spec/unit/run_spec.rb | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/spec/unit/run_spec.rb b/spec/unit/run_spec.rb deleted file mode 100755 index 4c5f6b1af..000000000 --- a/spec/unit/run_spec.rb +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../spec_helper' -require 'puppet/agent' -require 'puppet/run' - -describe Puppet::Run do - before do - @runner = Puppet::Run.new - end - - it "should indirect :run" do - Puppet::Run.indirection.name.should == :run - end - - it "should use a configurer agent as its agent" do - agent = mock 'agent' - Puppet::Agent.expects(:new).with(Puppet::Configurer).returns agent - - @runner.agent.should equal(agent) - end - - it "should accept options at initialization" do - lambda { Puppet::Run.new :background => true }.should_not raise_error - end - - it "should default to running in the foreground" do - Puppet::Run.new.should_not be_background - end - - it "should default to its options being an empty hash" do - Puppet::Run.new.options.should == {} - end - - it "should accept :tags for the agent" do - Puppet::Run.new(:tags => "foo").options[:tags].should == "foo" - end - - it "should accept :ignoreschedules for the agent" do - Puppet::Run.new(:ignoreschedules => true).options[:ignoreschedules].should be_true - end - - it "should accept an option to configure it to run in the background" do - Puppet::Run.new(:background => true).should be_background - end - - it "should retain the background option" do - Puppet::Run.new(:background => true).options[:background].should be_nil - end - - it "should not accept arbitrary options" do - lambda { Puppet::Run.new(:foo => true) }.should raise_error(ArgumentError) - end - - describe "when asked to run" do - before do - @agent = stub 'agent', :run => nil, :running? => false - @runner.stubs(:agent).returns @agent - end - - it "should run its agent" do - agent = stub 'agent2', :running? => false - @runner.stubs(:agent).returns agent - - agent.expects(:run) - - @runner.run - end - - it "should pass any of its options on to the agent" do - @runner.stubs(:options).returns(:foo => :bar) - @agent.expects(:run).with(:foo => :bar) - - @runner.run - end - - it "should log its run using the provided options" do - @runner.expects(:log_run) - - @runner.run - end - - it "should set its status to 'already_running' if the agent is already running" do - @agent.expects(:running?).returns true - - @runner.run - - @runner.status.should == "running" - end - - it "should set its status to 'success' if the agent is run" do - @agent.expects(:running?).returns false - - @runner.run - - @runner.status.should == "success" - end - - it "should run the agent in a thread if asked to run it in the background" do - Thread.expects(:new) - - @runner.expects(:background?).returns true - - @agent.expects(:run).never # because our thread didn't yield - - @runner.run - end - - it "should run the agent directly if asked to run it in the foreground" do - Thread.expects(:new).never - - @runner.expects(:background?).returns false - @agent.expects(:run) - - @runner.run - end - end - - describe ".from_pson" do - it "should accept a hash of options, and pass them with symbolified keys to new" do - options = { - "tags" => "whatever", - "background" => true, - } - - Puppet::Run.expects(:new).with({ - :tags => "whatever", - :background => true, - }) - - Puppet::Run.from_pson(options) - end - end -end |