Sha256: 7a15ebd7832b5f5de0dac6db0f1502f9b1d6df321e9bd6b0971b421d607766fe

Contents?: true

Size: 976 Bytes

Versions: 2

Compression:

Stored size: 976 Bytes

Contents

require "spec_helper"
require "stringio"
require "cloud_runner/digital_ocean/cli/new"

describe "cr-new" do
  let(:client_id) { ENV["SPEC_CR_CLIENT_ID"] || raise }
  let(:api_key) { ENV["SPEC_CR_API_KEY"] || raise }

  def self.it_runs_script(script, expected_exit_code)
    describe "for '#{script}' script" do
      let(:out) { StringIO.new }
      let(:err) { StringIO.new }

      it "runs script and returns exit code" do
        CloudRunner::DigitalOcean::Cli::New.new(
          :client_id => client_id,
          :api_key => api_key,
          :script => "./spec/fixtures/#{script}.sh",
          :host_image => "ubuntu-10-04",
        ).run_script(
          Multiplexer.new(out, $stdout),
          Multiplexer.new(err, $stderr),
        ).should == expected_exit_code

        out.string.should include("Echo to stdout\n")
        err.string.should include("Echo to stderr\n")
      end
    end
  end

  it_runs_script "success", 0
  it_runs_script "fail", 128
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloud_runner-0.0.2 spec/cr_new_spec.rb
cloud_runner-0.0.1 spec/cr_new_spec.rb