Sha256: 7524ddea7b3b30f4b1b7365cec66fb2efac5e04d087fb2d2bf0dbbe1c51bfa24

Contents?: true

Size: 1.6 KB

Versions: 6

Compression:

Stored size: 1.6 KB

Contents

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

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

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

  describe :list do
    before do
      expect(cmd).to receive(:load_selections).and_return({"project" => {"id" => 1, "name" => "ProjectA"}})
      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({"project" => {"id" => 1, "name" => "ProjectA"}, "stage" => {"id" => 1, "name" => "StageA"} })
        expect(cmd).to receive(:post_json).with("/admin/client_version/new.json", { "client_version" => { "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

6 entries across 6 versions & 1 rubygems

Version Path
magellan-cli-0.2.18 spec/magellan/cli/resources/client_version_spec.rb
magellan-cli-0.2.17 spec/magellan/cli/resources/client_version_spec.rb
magellan-cli-0.2.16 spec/magellan/cli/resources/client_version_spec.rb
magellan-cli-0.2.15 spec/magellan/cli/resources/client_version_spec.rb
magellan-cli-0.2.14 spec/magellan/cli/resources/client_version_spec.rb
magellan-cli-0.2.13 spec/magellan/cli/resources/client_version_spec.rb