Sha256: 32facabb9c4899e07b1a03b35d59ab6cb6077c1a1a7e517aaeacf4ca803c0662

Contents?: true

Size: 1.95 KB

Versions: 18

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe VMC::Domain::Unmap do
  let(:global) { { :color => false } }
  let(:given) { {} }
  let(:client) { fake_client :current_organization => organization, :current_space => space }
  let!(:cli) { described_class.new }

  before do
    stub(cli).client { client }
    stub_output(cli)
  end

  let(:organization) { fake(:organization) }
  let(:space) { fake(:space) }
  let(:domain) { fake(:domain, :name => domain_name) }
  let(:domain_name) { "some.domain.com" }

  subject { invoke_cli(cli, :unmap_domain, inputs, given, global) }

  context "when the --delete flag is given" do
    let(:inputs) { { :domain => domain, :delete => true } }

    it "asks for a confirmation" do
      mock_ask("Really delete #{domain_name}?", :default => false) { false }
      stub(domain).delete!
      subject
    end

    context "and the user answers 'no' to the confirmation" do
      it "does NOT delete the domain" do
        stub_ask("Really delete #{domain_name}?", anything) { false }
        dont_allow(domain).delete!
        subject
      end
    end

    context "and the user answers 'yes' to the confirmation" do
      it "deletes the domain" do
        stub_ask("Really delete #{domain_name}?", anything) { true }
        mock(domain).delete!
        subject
      end
    end
  end

  context "when a space is given" do
    let(:inputs) { { :domain => domain, :space => space } }

    it "unmaps the domain from the space" do
      mock(space).remove_domain(domain)
      subject
    end
  end

  context "when an organization is given" do
    let(:inputs) { { :domain => domain, :organization => organization } }

    it "unmaps the domain from the organization" do
      mock(organization).remove_domain(domain)
      subject
    end
  end

  context "when only the domain is given" do
    let(:inputs) { { :domain => domain } }

    it "unmaps the domain from the current space" do
      mock(client.current_space).remove_domain(domain)
      subject
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
af-0.5.0.beta.11 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.10 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.9 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.8 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.7 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.6 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.5 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.4 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.3 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.2 spec/vmc/cli/domain/unmap_spec.rb
af-0.5.0.beta.1 spec/vmc/cli/domain/unmap_spec.rb
vmc-0.5.0.rc4 spec/vmc/cli/domain/unmap_spec.rb
vmc-0.5.0.rc3 spec/vmc/cli/domain/unmap_spec.rb
vmc-0.5.0.rc2 spec/vmc/cli/domain/unmap_spec.rb
vmc-0.5.0.rc1 spec/vmc/cli/domain/unmap_spec.rb
vmc-0.5.0.beta.12 spec/vmc/cli/domain/unmap_spec.rb
vmc-0.5.0.beta.11 spec/vmc/cli/domain/unmap_spec.rb
vmc-0.5.0.beta.10 spec/vmc/cli/domain/unmap_spec.rb