Sha256: b88aefdb09519031024247b53092733ba334ac79493599b3efc0387d54ac6453

Contents?: true

Size: 997 Bytes

Versions: 3

Compression:

Stored size: 997 Bytes

Contents

#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/application/facts'

describe Puppet::Application::Facts do
  before :each do
    subject.command_line.stubs(:subcommand_name).returns 'facts'
  end

  it "should fail if no key is given to find" do
    subject.command_line.stubs(:args).returns %w{find}
    expect {
      expect { subject.run }.to exit_with 1
    }.to have_printed /Error: puppet facts find takes 1 argument, but you gave 0/
    @logs.first.to_s.should =~ /puppet facts find takes 1 argument, but you gave 0/
  end

  it "should return facts if a key is given to find" do
    Puppet::Node::Facts.indirection.reset_terminus_class
    Puppet::Node::Facts.indirection.expects(:find).returns(Puppet::Node::Facts.new('whatever', {}))
    subject.command_line.stubs(:args).returns %w{find whatever --render-as yaml}

    expect {
      expect {
        subject.run
      }.to exit_with 0
    }.to have_printed(/object:Puppet::Node::Facts/)

    @logs.should be_empty
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-3.2.4 spec/unit/application/facts_spec.rb
puppet-3.2.3 spec/unit/application/facts_spec.rb
puppet-3.2.3.rc1 spec/unit/application/facts_spec.rb