Sha256: e9ebc5a7982ad272533246341a0d31ce1c217b32f0f768f57add9ddfc50291b2

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

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

describe Magellan::Cli::Resources::ClientVersion do

  let(:cmd){ Magellan::Cli::Resources::ClientVersion.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, project_id: 1, stage_title_id: 1, version: "1.0.0", url_mapping_yaml: nil, status: "1" }])
      expect($stdout).to receive(:puts)
    end
    it do
      cmd.list
    end
  end

  describe :create do
    describe :success do
      let(:client_version_list_response) { [ { "id" => 1, "version" => "1.1.0" } ] }
      before do
        allow(cmd).to receive(:load_selections).and_return({Magellan::Cli::Resources::Project.parameter_name => {"id" => 1, "name" => "ProjectA"}, Magellan::Cli::Resources::Stage.parameter_name => {"id" => 1, "name" => "StageA"} })
        expect(cmd).to receive(:post_json).with("/admin/client_version/new.json", { "client_version" => { "project_id" => 1, "stage_title_id" => 1, "version" => "1.1.0" } })
        # TODO: stub in details
        # expect(cmd).to receive(:get_json).with(any_args).and_return(client_version_list_response)
        # expect(cmd).to receive(:update_selections).with("client_version" => { "id" => 1, "version" => "1.0.0" })
      end
      it do
        cmd.create("1.1.0")
      end
    end
    describe :error do
      context "stage not selected" do
        before do
          expect(cmd).to receive(:load_selections).and_return({})
        end
        it do
          expect{
            cmd.create("1.1.0")
          }.to raise_error(Magellan::Cli::FileAccess::NotSelected)
        end
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
magellan-cli-0.5.8 spec/magellan/cli/resources/client_version_spec.rb
magellan-cli-0.5.7 spec/magellan/cli/resources/client_version_spec.rb
magellan-cli-0.5.6 spec/magellan/cli/resources/client_version_spec.rb