Sha256: 5512b8c4a5d333e84a667491e42b0e870aa9bfa3c5e0156cc90320f1851f979f

Contents?: true

Size: 1.56 KB

Versions: 9

Compression:

Stored size: 1.56 KB

Contents

require "spec_helper"
require "shelly/cli/organization"

describe Shelly::CLI::Organization do
  before do
    FileUtils.stub(:chmod)
    @organization = Shelly::CLI::Organization.new
    Shelly::CLI::Organization.stub(:new).and_return(@organization)
    @client = mock
    Shelly::Client.stub(:new).and_return(@client)
    $stdout.stub(:puts)
    $stdout.stub(:print)
    @client.stub(:authorize!)
    FileUtils.mkdir_p("/projects/foo")
    Dir.chdir("/projects/foo")
  end

  describe "#list" do
    before do
      @client.stub(:token).and_return("abc")
      @client.stub(:organizations).and_return([
        {"name" => "aaa", "app_code_names" => ["app1"]},
        {"name" => "ccc", "app_code_names" => ["app2", "app3"]}
      ])
      @client.stub(:app).with("app1").and_return("state" => "running")
      @client.stub(:app).with("app2").and_return("state" => "turned_off")
      @client.stub(:app).with("app3").and_return("state" => "no_code")
    end

    it "should ensure user has logged in" do
      hooks(@organization, :list).should include(:logged_in?)
    end

    it "should print out all organizations with apps" do
      $stdout.should_receive(:puts).with(green("You have access to the following organizations and clouds:"))
      $stdout.should_receive(:puts).with(green("aaa"))
      $stdout.should_receive(:puts).with(/app1 \s+ |  running/)
      $stdout.should_receive(:puts).with(green("ccc"))
      $stdout.should_receive(:puts).with(/app2 \s+ |  turned off/)
      $stdout.should_receive(:puts).with(/app3 \s+ |  no code/)
      invoke(@organization, :list)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shelly-0.3.8 spec/shelly/cli/organization_spec.rb
shelly-0.3.7 spec/shelly/cli/organization_spec.rb
shelly-0.3.6 spec/shelly/cli/organization_spec.rb
shelly-0.3.5 spec/shelly/cli/organization_spec.rb
shelly-0.3.5.pre spec/shelly/cli/organization_spec.rb
shelly-0.3.4 spec/shelly/cli/organization_spec.rb
shelly-0.3.3 spec/shelly/cli/organization_spec.rb
shelly-0.3.2 spec/shelly/cli/organization_spec.rb
shelly-0.3.1 spec/shelly/cli/organization_spec.rb