require 'spec_helper'

module Jisota
  describe CommandScript do
    describe "#command" do
      it "initializes with a command" do
        expect(CommandScript.new(:foo).command).to eq(:foo)
      end
    end

    describe "#execute" do
      it "asks ssh_session to execute" do
        script = CommandScript.new(:foo)
        ssh_session = instance_double(SSHSession, command: 0)
        context = ScriptContext.new(ssh_session: ssh_session)
        result = script.execute(context)

        expect(ssh_session).to have_received(:command).with(:foo, anything)
        expect(result).to be true
      end
    end
  end
end
