Permalink
Browse files

move from factory_girl to new cfoundry factories

Change-Id: Ie1fc1121a810400d2906d9bffcc07a2129eb0242
  • Loading branch information...
1 parent 7169330 commit d5beaf9c4503b8aeac4e5068408d3feef34a3f1c @vito vito committed Dec 19, 2012
@@ -5,7 +5,7 @@
let(:global) { { :color => false, :quiet => true } }
let(:inputs) { {} }
let(:given) { {} }
- let(:client) { FactoryGirl.build(:client) }
+ let(:client) { fake_client }
let(:app) {}
let(:new_name) { "some-new-name" }
@@ -49,28 +49,25 @@
end
context 'when there are apps' do
- let(:client) { FactoryGirl.build(:client, :apps => apps) }
+ let(:client) { fake_client(:apps => apps) }
let(:apps) { [basic_app, app_with_orphans, app_without_orphans] }
- let(:service_1) { FactoryGirl.build(:service_instance) }
- let(:service_2) { FactoryGirl.build(:service_instance) }
- let(:basic_app) { FactoryGirl.build(:app, :name => "basic_app") }
+ let(:service_1) { fake :service_instance }
+ let(:service_2) { fake :service_instance }
+ let(:basic_app) { fake(:app, :name => "basic_app") }
let(:app_with_orphans) {
- FactoryGirl.build(:app,
+ fake :app,
:name => "app_with_orphans",
:service_bindings => [
- FactoryGirl.build(:service_binding,
- :service_instance => service_1),
- FactoryGirl.build(:service_binding,
- :service_instance => service_2)
- ])
+ fake(:service_binding, :service_instance => service_1),
+ fake(:service_binding, :service_instance => service_2)
+ ]
}
let(:app_without_orphans) {
- FactoryGirl.build(:app,
+ fake :app,
:name => "app_without_orphans",
:service_bindings => [
- FactoryGirl.build(:service_binding,
- :service_instance => service_1)
- ])
+ fake(:service_binding, :service_instance => service_1)
+ ]
}
context 'and no app is given' do
@@ -125,6 +122,8 @@
stub_ask("Really delete #{deleted_app.name}?", anything) { true }
stub(deleted_app).delete!
+ stub(service_2).invalidate!
+
mock_ask("Delete orphaned service #{service_2.name}?", anything) { true }
any_instance_of(VMC::App::Delete) do |del|
@@ -141,6 +140,8 @@
stub_ask("Really delete #{deleted_app.name}?", anything) { false }
dont_allow(deleted_app).delete!
+ stub(service_2).invalidate!
+
dont_allow_ask("Delete orphaned service #{service_2.name}?")
any_instance_of(VMC::App::Delete) do |del|
@@ -5,19 +5,19 @@
let(:given) { {} }
let(:global) { { :color => false, :quiet => true } }
- let(:frameworks) { FactoryGirl.build_list(:framework, 3) }
+ let(:frameworks) { fake_list(:framework, 3) }
let(:framework) { frameworks.first }
- let(:standalone) { FactoryGirl.build(:framework, :name => "standalone") }
+ let(:standalone) { fake(:framework, :name => "standalone") }
- let(:runtimes) { FactoryGirl.build_list(:runtime, 3) }
+ let(:runtimes) { fake_list(:runtime, 3) }
let(:runtime) { runtimes.first }
- let(:service_instances) { FactoryGirl.build_list(:service_instance, 5) }
+ let(:service_instances) { fake_list(:service_instance, 5) }
let(:client) do
- FactoryGirl.build(
- :client,
- :frameworks => frameworks, :runtimes => runtimes,
+ fake_client(
+ :frameworks => frameworks,
+ :runtimes => runtimes,
:service_instances => service_instances)
end
@@ -225,7 +225,7 @@
describe '#create_app' do
before { dont_allow_ask }
- let(:app) { FactoryGirl.build(:app, :guid => nil) }
+ let(:app) { fake(:app, :guid => nil) }
let(:attributes) do
{ :name => "some-app",
@@ -255,7 +255,7 @@
end
describe '#map_url' do
- let(:app) { FactoryGirl.build(:app) }
+ let(:app) { fake(:app) }
let(:url_choices) { %W(#{app.name}.foo-cloud.com) }
before do
@@ -319,7 +319,7 @@
end
describe '#create_services' do
- let(:app) { FactoryGirl.build(:app) }
+ let(:app) { fake(:app) }
subject { create.create_services(app) }
context 'when forcing' do
@@ -365,7 +365,7 @@
end
describe '#bind_services' do
- let(:app) { FactoryGirl.build(:app) }
+ let(:app) { fake(:app) }
subject { create.bind_services(app) }
@@ -437,7 +437,7 @@
end
describe '#start_app' do
- let(:app) { FactoryGirl.build(:app) }
+ let(:app) { fake(:app) }
subject { create.start_app(app) }
context 'when the start flag is provided' do
@@ -6,7 +6,7 @@
let(:inputs) { {} }
let(:given) { {} }
let(:path) { "somepath" }
- let(:client) { FactoryGirl.build(:client) }
+ let(:client) { fake_client }
let(:push) { VMC::App::Push.new(Mothership.commands[:push]) }
before do
@@ -36,7 +36,7 @@
end
describe '#sync_app' do
- let(:app) { FactoryGirl.build(:app) }
+ let(:app) { fake(:app) }
before do
stub(app).upload
@@ -87,7 +87,7 @@
context 'when memory is given' do
let(:old) { 1024 }
let(:new) { "2G" }
- let(:app) { FactoryGirl.build(:app, :memory => old) }
+ let(:app) { fake(:app, :memory => old) }
let(:inputs) { { :memory => new } }
it 'updates the app memory, converting to megabytes' do
@@ -109,7 +109,7 @@
context 'when instances is given' do
let(:old) { 1 }
let(:new) { 2 }
- let(:app) { FactoryGirl.build(:app, :total_instances => old) }
+ let(:app) { fake(:app, :total_instances => old) }
let(:inputs) { { :instances => new } }
it 'updates the app instances' do
@@ -129,9 +129,9 @@
end
context 'when framework is given' do
- let(:old) { FactoryGirl.build(:framework, :name => "Old Framework") }
- let(:new) { FactoryGirl.build(:framework, :name => "New Framework") }
- let(:app) { FactoryGirl.build(:app, :framework => old) }
+ let(:old) { fake(:framework, :name => "Old Framework") }
+ let(:new) { fake(:framework, :name => "New Framework") }
+ let(:app) { fake(:app, :framework => old) }
let(:inputs) { { :framework => new } }
it 'updates the app framework' do
@@ -151,9 +151,9 @@
end
context 'when runtime is given' do
- let(:old) { FactoryGirl.build(:runtime, :name => "Old Runtime") }
- let(:new) { FactoryGirl.build(:runtime, :name => "New Runtime") }
- let(:app) { FactoryGirl.build(:app, :runtime => old) }
+ let(:old) { fake(:runtime, :name => "Old Runtime") }
+ let(:new) { fake(:runtime, :name => "New Runtime") }
+ let(:app) { fake(:app, :runtime => old) }
let(:inputs) { { :runtime => new } }
it 'updates the app runtime' do
@@ -175,7 +175,7 @@
context 'when command is given' do
let(:old) { "./start" }
let(:new) { "./start foo " }
- let(:app) { FactoryGirl.build(:app, :command => old) }
+ let(:app) { fake(:app, :command => old) }
let(:inputs) { { :command => new } }
it 'updates the app command' do
@@ -222,7 +222,7 @@
%w{d100 D100 D200 fizzbuzz}.each do |plan|
context "when the given plan is #{plan}" do
- let(:app) { FactoryGirl.build(:app, :production => true) }
+ let(:app) { fake(:app, :production => true) }
let(:inputs) { { :plan => plan } }
@@ -247,7 +247,7 @@
context 'when the app is already started' do
- let(:app) { FactoryGirl.build(:app, :state => "STARTED") }
+ let(:app) { fake(:app, :state => "STARTED") }
it 'invokes the restart command' do
stub(push).line
@@ -269,7 +269,7 @@
end
context 'when the app is not already started' do
- let(:app) { FactoryGirl.build(:app, :state => "STOPPED") }
+ let(:app) { fake(:app, :state => "STOPPED") }
it 'does not invoke the restart command' do
stub(push).line
@@ -282,9 +282,9 @@
end
describe '#setup_new_app (integration spec!!)' do
- let(:app) { FactoryGirl.build(:app, :guid => nil) }
- let(:framework) { FactoryGirl.build(:framework) }
- let(:runtime) { FactoryGirl.build(:runtime) }
+ let(:app) { fake(:app, :guid => nil) }
+ let(:framework) { fake(:framework) }
+ let(:runtime) { fake(:runtime) }
let(:url) { "https://www.foobar.com" }
let(:inputs) do
{ :name => "some-app",
@@ -5,7 +5,7 @@
let(:global) { { :color => false, :quiet => true } }
let(:inputs) { {} }
let(:given) { {} }
- let(:client) { FactoryGirl.build(:client) }
+ let(:client) { fake_client }
let(:app) {}
let(:new_name) { "some-new-name" }
@@ -52,8 +52,8 @@
end
context 'when there are apps' do
- let(:client) { FactoryGirl.build(:client, :apps => apps) }
- let(:apps) { FactoryGirl.build_list(:app, 2) }
+ let(:client) { fake_client(:apps => apps) }
+ let(:apps) { fake_list(:app, 2) }
let(:renamed_app) { apps.first }
context 'when the defaults are used' do
@@ -6,11 +6,12 @@
let(:inputs) { {} }
let(:given) { {} }
let(:output) { StringIO.new }
- let!(:org_1) { FactoryGirl.build(:organization, :name => "bb_second", :spaces => FactoryGirl.build_list(:space, 2), :domains => [FactoryGirl.build(:domain)]) }
- let!(:org_2) { FactoryGirl.build(:organization, :name => "aa_first", :spaces => [FactoryGirl.build(:space)], :domains => FactoryGirl.build_list(:domain, 3)) }
- let!(:org_3) { FactoryGirl.build(:organization, :name => "cc_last", :spaces => FactoryGirl.build_list(:space, 2), :domains => FactoryGirl.build_list(:domain, 2)) }
+
+ let(:client) { fake_client(:organizations => organizations) }
+ let!(:org_1) { fake(:organization, :name => "bb_second", :spaces => fake_list(:space, 2), :domains => [fake(:domain)]) }
+ let!(:org_2) { fake(:organization, :name => "aa_first", :spaces => [fake(:space)], :domains => fake_list(:domain, 3)) }
+ let!(:org_3) { fake(:organization, :name => "cc_last", :spaces => fake_list(:space, 2), :domains => fake_list(:domain, 2)) }
let(:organizations) { [org_1, org_2, org_3]}
- let(:client) { FactoryGirl.build(:client, :organizations => organizations) }
before do
any_instance_of(VMC::CLI) do |cli|
@@ -5,8 +5,8 @@
let(:global) { { :color => false, :quiet => true } }
let(:inputs) { {} }
let(:given) { {} }
- let(:organizations) { FactoryGirl.build_list(:organization, 3) }
- let(:client) { FactoryGirl.build(:client, :organizations => organizations) }
+ let(:organizations) { fake_list(:organization, 3) }
+ let(:client) { fake_client(:organizations => organizations) }
let(:new_name) { "some-new-name" }
before do
@@ -5,7 +5,7 @@
let(:global) { { :color => false, :quiet => true } }
let(:inputs) { {} }
let(:given) { {} }
- let(:client) { FactoryGirl.build(:client) }
+ let(:client) { fake_client }
before do
any_instance_of(VMC::CLI) do |cli|
@@ -56,8 +56,8 @@
end
context "when there are routes" do
- let(:client) { FactoryGirl.build(:client, :routes => routes) }
- let(:routes) { FactoryGirl.build_list(:route, 2) }
+ let(:client) { fake_client(:routes => routes) }
+ let(:routes) { fake_list(:route, 2) }
let(:deleted_route) { routes.first }
context 'when the defaults are used' do
@@ -5,7 +5,7 @@
let(:global) { { :color => false, :quiet => true } }
let(:inputs) { {} }
let(:given) { {} }
- let(:client) { FactoryGirl.build(:client) }
+ let(:client) { fake_client }
let(:service) {}
let(:new_name) { "some-new-name" }
@@ -52,8 +52,8 @@
end
context 'when there are services' do
- let(:client) { FactoryGirl.build(:client, :service_instances => services) }
- let(:services) { FactoryGirl.build_list(:service_instance, 2) }
+ let(:client) { fake_client(:service_instances => services) }
+ let(:services) { fake_list(:service_instance, 2) }
let(:renamed_service) { services.first }
context 'when the defaults are used' do
@@ -5,9 +5,9 @@
let(:global) { { :color => false, :quiet => true } }
let(:inputs) { {} }
let(:given) { {} }
- let(:spaces) { FactoryGirl.build_list(:space, 3) }
- let(:organization) { FactoryGirl.build(:organization, :spaces => spaces) }
- let(:client) { FactoryGirl.build(:client, :current_organization => organization, :spaces => spaces) }
+ let(:spaces) { fake_list(:space, 3) }
+ let(:organization) { fake(:organization, :spaces => spaces) }
+ let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
let(:new_name) { "some-new-name" }
before do
@@ -6,12 +6,12 @@
let(:inputs) { {} }
let(:given) { {} }
let(:output) { StringIO.new }
- let!(:space_1) { FactoryGirl.build(:space, :name => "bb_second", :apps => FactoryGirl.build_list(:app, 2), :service_instances => [FactoryGirl.build(:service_instance)]) }
- let!(:space_2) { FactoryGirl.build(:space, :name => "aa_first", :apps => [FactoryGirl.build(:app)], :service_instances => FactoryGirl.build_list(:service_instance, 3), :domains => [FactoryGirl.build(:domain)]) }
- let!(:space_3) { FactoryGirl.build(:space, :name => "cc_last", :apps => FactoryGirl.build_list(:app, 2), :service_instances => FactoryGirl.build_list(:service_instance, 2), :domains => FactoryGirl.build_list(:domain, 2)) }
+ let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
+ let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
+ let!(:space_3) { fake(:space, :name => "cc_last", :apps => fake_list(:app, 2), :service_instances => fake_list(:service_instance, 2), :domains => fake_list(:domain, 2)) }
let(:spaces) { [space_1, space_2, space_3]}
- let(:organization) { FactoryGirl.build(:organization, :spaces => spaces) }
- let(:client) { FactoryGirl.build(:client, :spaces => spaces, :current_organization => organization) }
+ let(:organization) { fake(:organization, :spaces => spaces) }
+ let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
before do
any_instance_of(VMC::CLI) do |cli|
@@ -1,7 +1,7 @@
require 'spec_helper'
describe VMC::Detector do
- let(:client) { FactoryGirl.build(:client, :frameworks => [framework]) }
+ let(:client) { fake_client :frameworks => [framework] }
let(:detector) { VMC::Detector.new client, nil }
describe '#detect_framework' do
@@ -22,7 +22,7 @@
Clouseau::Spring => "spring"
}.each do |clouseau_detective, cf_name|
context "when we detected #{clouseau_detective}" do
- let(:framework) { FactoryGirl.build(:framework, :name => cf_name) }
+ let(:framework) { fake(:framework, :name => cf_name) }
it "maps to CF name #{cf_name}" do
stub(Clouseau).detect(anything) { clouseau_detective }
View
@@ -33,5 +33,4 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec", "~> 2.11"
s.add_development_dependency "webmock", "~> 1.9"
s.add_development_dependency "rr", "~> 1.0"
- s.add_development_dependency "factory_girl", "~> 2.6"
end

0 comments on commit d5beaf9

Please sign in to comment.