Sha256: b38c5ca4de6c49c4d8a28c6e195535b6f4405385e6a5d6611b3ea106eda273be

Contents?: true

Size: 923 Bytes

Versions: 2

Compression:

Stored size: 923 Bytes

Contents

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

describe Magellan::Cli::Resources::Organization do

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

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

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

  describe :create do
    let(:organization_list_response) { [ { "id" => 1, "name" => "new1" } ] }
    before do
      expect(cmd).to receive(:post_json).with("/admin/magellan~auth~organization/new.json", {"magellan_auth_organization" => { "name" => "new1" }})
      allow(cmd).to receive(:get_json).with(any_args).and_return(organization_list_response)
    end
    it do
      cmd.create("new1")
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
magellan-cli-0.6.1 spec/magellan/cli/resources/organization_spec.rb
magellan-cli-0.6.0 spec/magellan/cli/resources/organization_spec.rb