lib/rspec-system-puppet/helpers.rb in rspec-system-puppet-1.0.2 vs lib/rspec-system-puppet/helpers.rb in rspec-system-puppet-1.1.0

- old
+ new

@@ -96,20 +96,20 @@ # # @param opts [Hash] a hash of opts # @option opts [RSpecSystem::Node] :node node to execute DSL on # @option opts [Boolean] :debug true if debugging required # @option opts [Boolean] :trace true if trace required - # @return [Hash] a hash of results + # @return [RSpecSystem::Result] results containing keys :exit_code, :stdout and :stderr # @yield [result] yields result when called as a block - # @yieldparam result [Hash] a hash containing :exit_code, :stdout and :stderr + # @yieldparam result [RSpecSystem::Result] a hash containing :exit_code, :stdout and :stderr # @example # puppet_agent.do |r| - # r[:exit_code].should == 0 + # r.exit_code.should == 0 # end # @example with debugging enabled # puppet_agent(:debug => true).do |r| - # r[:exit_code].should == 0 + # r.exit_code.should == 0 # end def puppet_agent(opts = {}) # Defaults etc. opts = { :node => rspec_system_node_set.default_node, @@ -153,10 +153,13 @@ end # Runs puppet resource commands # # @param opts [Hash] a hash of opts + # @return [RSpecSystem::Result] results containing keys :exit_code, :stdout and :stderr + # @yield [result] yields result when called as a block + # @yieldparam result [RSpecSystem::Result] a hash containing :exit_code, :stdout and :stderr def puppet_resource(opts) if opts.is_a?(String) opts = {:resource => opts} end @@ -189,17 +192,17 @@ # code to execute with option defaults # @option opts [String] :code the Puppet DSL code to execute # @option opts [RSpecSystem::Node] :node node to execute DSL on # @option opts [Boolean] :debug true if debugging required # @option opts [Boolean] :trace true if trace required - # @return [Hash] a hash of results + # @return [RSpecSystem::Result] results containing keys :exit_code, :stdout and :stderr # @yield [result] yields result when called as a block - # @yieldparam result [Hash] a hash containing :exit_code, :stdout and :stderr + # @yieldparam result [RSpecSystem::Result] a hash containing :exit_code, :stdout and :stderr # @example # it "run notice" do # puppet_apply("notice('foo')") do |r| - # r[:stdout].should =~ /foo/ + # r.stdout.should =~ /foo/ # end # end def puppet_apply(opts) if opts.is_a?(String) opts = {:code => opts} @@ -245,13 +248,13 @@ # Run facter on a remote machine # # @param opts [Hash] a hash of opts # @option opts [RSpecSystem::Node] :node node to execute DSL on - # @return [Hash] a hash of results + # @return [RSpecSystem::Result] a hash of results # @yield [result] yields result when called as a block - # @yieldparam result [Hash] a hash containing :facts, :exit_code, :stdout and + # @yieldparam result [RSpecSystem::Result] result containing :facts, :exit_code, :stdout and # :stderr def facter(opts = {}) # Defaults opts = { :node => rspec_system_node_set.default_node, @@ -264,10 +267,10 @@ cmd = "facter -y" result = system_run(:n => node, :c => cmd) begin facts = YAML::load(result[:stdout]) - result[:facts] = facts + result.facts = facts rescue end if block_given? yield(result)