spec/cf/cli/space/create_spec.rb in cf-0.6.1.rc3 vs spec/cf/cli/space/create_spec.rb in cf-0.6.1.rc4
- old
+ new
@@ -1,9 +1,9 @@
require 'spec_helper'
require "cf/cli/space/create"
-command CF::Space::Create do
+describe CF::Space::Create do
describe 'metadata' do
let(:command) { Mothership.commands[:create_space] }
describe 'command' do
subject { command }
@@ -23,25 +23,33 @@
end
end
end
describe "running the command" do
- let(:client) do
- fake_client(:current_organization => organization)
- end
-
- let(:organization) { fake(:organization) }
-
let(:new_space) { fake :space, :name => new_name }
let(:new_name) { "some-new-name" }
+ let(:spaces) { [new_space] }
+ let(:organization) { fake(:organization, :spaces => spaces) }
+
+ let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
+
+
+
before do
stub(client).space { new_space }
stub(new_space).create!
stub(new_space).add_manager
stub(new_space).add_developer
stub(new_space).add_auditor
+ any_instance_of described_class do |cli|
+ stub(cli).client { client }
+
+ stub(cli).check_logged_in
+ stub(cli).check_target
+ stub(cli).check_organization
+ end
end
context "when --target is given" do
subject { cf %W[create-space #{new_space.name} --target] }
@@ -57,9 +65,18 @@
it "tells the user how they can switch to the new space" do
subject
expect(output).to say("Space created! Use switch-space #{new_space.name} to target it.")
end
+
+ it_should_behave_like "a_command_that_populates_organization" do
+ before do
+ any_instance_of described_class do |cli|
+ stub.proxy(cli).check_organization
+ end
+ end
+ end
+
end
context "when we don't specify an organization" do
subject { cf %W[create-space #{new_space.name}] }