spec/cf/cli/app/rename_spec.rb in cf-1.1.4 vs spec/cf/cli/app/rename_spec.rb in cf-2.0.0
- old
+ new
@@ -2,11 +2,11 @@
describe CF::App::Rename do
let(:global) { { :color => false, :quiet => true } }
let(:inputs) { {} }
let(:given) { {} }
- let(:client) { fake_client }
+ let(:client) { build(:client) }
let(:app) {}
let(:new_name) { "some-new-name" }
before do
CF::CLI.any_instance.stub(:client).and_return(client)
@@ -36,10 +36,14 @@
end
end
end
context "when there are no apps" do
+ before do
+ client.stub(:apps).and_return([])
+ end
+
context "and an app is given" do
let(:given) { { :app => "some-app" } }
it { expect { subject }.to raise_error(CF::UserError, "Unknown app 'some-app'.") }
end
@@ -47,18 +51,21 @@
it { expect { subject }.to raise_error(CF::UserError, "No applications.") }
end
end
context "when there are apps" do
- let(:client) { fake_client(:apps => apps) }
- let(:apps) { fake_list(:app, 2) }
+ let(:apps) { [build(:app, :client => client), build(:app, :client => client)] }
let(:renamed_app) { apps.first }
+ before do
+ client.stub(:apps).and_return(apps)
+ end
+
context "when the defaults are used" do
it "asks for the app and new name and renames" do
- mock_ask("Rename which application?", anything) { renamed_app }
- mock_ask("New name") { new_name }
+ should_ask("Rename which application?", anything) { renamed_app }
+ should_ask("New name") { new_name }
renamed_app.should_receive(:name=).with(new_name)
renamed_app.should_receive(:update!)
subject
end
end
@@ -66,10 +73,10 @@
context "when no name is provided, but a app is" do
let(:given) { { :app => renamed_app.name } }
it "asks for the new name and renames" do
dont_allow_ask("Rename which application?", anything)
- mock_ask("New name") { new_name }
+ should_ask("New name") { new_name }
renamed_app.should_receive(:name=).with(new_name)
renamed_app.should_receive(:update!)
subject
end
end