Sha256: d157c9e13f012438a1b6628e32e36bf3c3e75ccb973d461835348fd509eaaf53

Contents?: true

Size: 1.64 KB

Versions: 20

Compression:

Stored size: 1.64 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe Magellan::Cli::Resources::Team do

  let(:cmd){ Magellan::Cli::Resources::Team.new }

  let(:cli){ double(:cli, :check_login_auth! => nil) }
  before{ allow(cmd).to receive(:cli).and_return(cli) }

  describe :list do
    before do
      expect(cmd).to receive(:get_json).and_return([{id: 1, organization_id: 1, name: "team1" }])
      expect($stdout).to receive(:puts)
    end
    it do
      cmd.list
    end
  end

  describe :create do
    describe :success do
      let(:team_list_response) { [{"id" => 1, "name" => "team1"}] }
      before do
        allow(cmd).to receive(:load_selections).and_return({ Magellan::Cli::Resources::Organization.parameter_name => {"id" => 1, "name" => "org1"}})
        expect(cmd).to receive(:post_json).with("/admin/magellan~auth~team/new.json", { "magellan_auth_team" => { "organization_id" => 1, "name" => "team1", "role" => role } })
        # TODO: stub in details...
        allow(cmd).to receive(:get_json).with(any_args).and_return(team_list_response)
        allow(cmd).to receive(:get_json).with(any_args).and_return(team_list_response)
      end
      context "role=reader" do
        let(:role){ "reader" }
        it do
          cmd.create("team1", role)
        end
      end
      context "role=admin" do
        let(:role){ "admin" }
        it do
          cmd.create("team1", role)
        end
      end
    end
    describe :error do
      context "role=owner" do
        let(:role){ "owner" }
        it do
          expect{
            cmd.create("team1", role)
          }.to raise_error(RuntimeError, /ROLE should be/)
        end
      end
    end
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
magellan-cli-0.5.9 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.8 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.7 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.6 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.5 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.4 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.3 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.2 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.1 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.5.0 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.4.4 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.4.3 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.4.2 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.4.1 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.4.0 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.3.4 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.3.3 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.3.2 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.3.1 spec/magellan/cli/resources/team_spec.rb
magellan-cli-0.3.0 spec/magellan/cli/resources/team_spec.rb