require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))

describe Chef::Knife::NodeShow do
  before(:each) do
    @knife = Chef::Knife::NodeShow.new
    @knife.config = {
      :attribute => nil,
      :run_list => nil
    }
    @knife.name_args = [ "adam" ]
    @knife.stub!(:json_pretty_print).and_return(true)
    @node = Chef::Node.new() 
    Chef::Node.stub!(:load).and_return(@node)
  end

  describe "run" do
    it "should load the node" do
      Chef::Node.should_receive(:load).with("adam").and_return(@node)
      @knife.run
    end

    it "should pretty print the node, formatted for display" do
      @knife.should_receive(:format_for_display).with(@node).and_return("poop")
      @knife.should_receive(:json_pretty_print).with("poop")
      @knife.run
    end
  end
end
