spec/vmc/cli/domain/unmap_spec.rb in vmc-0.5.0.rc4 vs spec/vmc/cli/domain/unmap_spec.rb in vmc-0.5.0

- old
+ new

@@ -1,73 +1,69 @@ 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) +command VMC::Domain::Unmap do + let(:client) do + fake_client( + :current_organization => organization, + :current_space => space, + :spaces => [space], + :organizations => [organization], + :domains => [domain]) end - let(:organization) { fake(:organization) } + let(:organization) { fake(:organization, :spaces => [space]) } let(:space) { fake(:space) } - let(:domain) { fake(:domain, :name => domain_name) } - let(:domain_name) { "some.domain.com" } + let(:domain) { fake(: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 } } + subject { vmc %W[unmap-domain #{domain.name} --delete] } it "asks for a confirmation" do - mock_ask("Really delete #{domain_name}?", :default => false) { false } + 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 } + 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 } + 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 } } + subject { vmc %W[unmap-domain #{domain.name} --space #{space.name}] } 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 } } + subject { vmc %W[unmap-domain #{domain.name} --organization #{organization.name}] } 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 } } + subject { vmc %W[unmap-domain #{domain.name}] } it "unmaps the domain from the current space" do mock(client.current_space).remove_domain(domain) subject end end -end \ No newline at end of file +end