cf 1.1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/lib/cf/cli/start/login.rb +3 -0
  2. data/lib/cf/version.rb +1 -1
  3. data/spec/cf/cli/app/base_spec.rb +2 -2
  4. data/spec/cf/cli/app/delete_spec.rb +150 -129
  5. data/spec/cf/cli/app/instances_spec.rb +56 -51
  6. data/spec/cf/cli/app/push/create_spec.rb +72 -70
  7. data/spec/cf/cli/app/push_spec.rb +46 -43
  8. data/spec/cf/cli/app/rename_spec.rb +13 -6
  9. data/spec/cf/cli/app/scale_spec.rb +9 -4
  10. data/spec/cf/cli/app/start_spec.rb +28 -23
  11. data/spec/cf/cli/app/stats_spec.rb +9 -10
  12. data/spec/cf/cli/domain/map_spec.rb +13 -10
  13. data/spec/cf/cli/domain/unmap_spec.rb +11 -11
  14. data/spec/cf/cli/organization/delete_spec.rb +10 -4
  15. data/spec/cf/cli/organization/orgs_spec.rb +15 -4
  16. data/spec/cf/cli/organization/rename_spec.rb +7 -5
  17. data/spec/cf/cli/populators/organization_spec.rb +40 -29
  18. data/spec/cf/cli/populators/space_spec.rb +51 -40
  19. data/spec/cf/cli/populators/target_spec.rb +4 -2
  20. data/spec/cf/cli/route/delete_spec.rb +6 -4
  21. data/spec/cf/cli/route/map_spec.rb +54 -35
  22. data/spec/cf/cli/route/unmap_spec.rb +21 -15
  23. data/spec/cf/cli/service/create_spec.rb +17 -12
  24. data/spec/cf/cli/service/rename_spec.rb +8 -6
  25. data/spec/cf/cli/service/services_spec.rb +15 -8
  26. data/spec/cf/cli/space/create_spec.rb +5 -9
  27. data/spec/cf/cli/space/delete_spec.rb +9 -8
  28. data/spec/cf/cli/space/rename_spec.rb +15 -8
  29. data/spec/cf/cli/space/space_spec.rb +10 -10
  30. data/spec/cf/cli/space/spaces_spec.rb +11 -5
  31. data/spec/cf/cli/space/switch_space_spec.rb +7 -7
  32. data/spec/cf/cli/start/info_spec.rb +3 -1
  33. data/spec/cf/cli/start/login_spec.rb +1 -1
  34. data/spec/cf/cli/start/logout_spec.rb +1 -1
  35. data/spec/cf/cli/start/target_spec.rb +7 -6
  36. data/spec/cf/cli/user/create_spec.rb +3 -4
  37. data/spec/cf/cli/user/passwd_spec.rb +2 -4
  38. data/spec/cf/cli/user/register_spec.rb +4 -4
  39. data/spec/cf/cli_spec.rb +1 -3
  40. data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
  41. data/spec/factories/cfoundry/v2/clients_factory.rb +4 -0
  42. data/spec/factories/cfoundry/v2/{domain_factory.rb → domains_factory.rb} +0 -0
  43. data/spec/factories/cfoundry/v2/organizations_factory.rb +12 -0
  44. data/spec/factories/cfoundry/v2/{route_factory.rb → routes_factory.rb} +0 -0
  45. data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
  46. data/spec/factories/cfoundry/v2/service_instances_factory.rb +12 -0
  47. data/spec/factories/cfoundry/v2/service_plans_factory.rb +13 -0
  48. data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
  49. data/spec/factories/cfoundry/v2/spaces_factory.rb +12 -0
  50. data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
  51. data/spec/factories/cfoundry/v2/{user_factory.rb → users_factory.rb} +0 -0
  52. data/spec/features/push_flow_spec.rb +8 -8
  53. data/spec/manifests/manifests_spec.rb +34 -51
  54. data/spec/manifests/plugin_spec.rb +17 -6
  55. data/spec/spec_helper.rb +0 -1
  56. data/spec/support/interact_helper.rb +1 -1
  57. data/spec/tunnel/tunnel_spec.rb +5 -5
  58. metadata +37 -13
@@ -6,13 +6,15 @@ module CF
6
6
  let(:global) { {:color => false, :quiet => true} }
7
7
  let(:inputs) { {} }
8
8
  let(:given) { {} }
9
- let(:organizations) { fake_list(:organization, 3) }
10
- let(:client) { fake_client(:organizations => organizations) }
9
+
11
10
  let(:new_name) { "some-new-name" }
11
+ let(:organizations) { [build(:organization)] }
12
+ let(:client) { build(:client) }
12
13
 
13
14
  before do
14
15
  CF::CLI.any_instance.stub(:client).and_return(client)
15
16
  CF::CLI.any_instance.stub(:precondition).and_return(nil)
17
+ client.stub(:organizations).and_return(organizations)
16
18
  end
17
19
 
18
20
  subject { Mothership.new.invoke(:rename_org, inputs, given, global) }
@@ -66,8 +68,8 @@ module CF
66
68
 
67
69
  context "when the defaults are used" do
68
70
  it "asks for the organization and new name and renames" do
69
- mock_ask("Rename which organization?", anything) { renamed_organization }
70
- mock_ask("New name") { new_name }
71
+ should_ask("Rename which organization?", anything) { renamed_organization }
72
+ should_ask("New name") { new_name }
71
73
  renamed_organization.should_receive(:name=).with(new_name)
72
74
  renamed_organization.should_receive(:update!)
73
75
  subject
@@ -79,7 +81,7 @@ module CF
79
81
 
80
82
  it "asks for the new name and renames" do
81
83
  dont_allow_ask("Rename which organization?", anything)
82
- mock_ask("New name") { new_name }
84
+ should_ask("New name") { new_name }
83
85
  renamed_organization.should_receive(:name=).with(new_name)
84
86
  renamed_organization.should_receive(:update!)
85
87
  subject
@@ -8,14 +8,14 @@ module CF
8
8
  describe "#populate_and_save!" do
9
9
  let(:tokens_file_path) { CF::TOKENS_FILE }
10
10
  let(:user) { build(:user) }
11
+ let(:client) { build(:client) }
11
12
  let(:organizations) do
12
13
  [
13
- double(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]),
14
- double(:organization, :name => "Other Org", :guid => "organization-id-2")
14
+ build(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]),
15
+ build(:organization, :name => "Other Org", :guid => "organization-id-2")
15
16
  ]
16
17
  end
17
18
  let(:organization) { organizations.first }
18
- let(:client) { fake_client :organizations => organizations }
19
19
 
20
20
  let(:input) { {:organization => organization} }
21
21
  let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
@@ -31,7 +31,7 @@ module CF
31
31
  write_token_file({:organization => "organization-id-1"})
32
32
  end
33
33
 
34
- subject do
34
+ def execute_populate_and_save
35
35
  capture_output { populator.populate_and_save! }
36
36
  end
37
37
 
@@ -40,13 +40,13 @@ module CF
40
40
  described_class.any_instance.unstub(:client)
41
41
  populator.client.current_organization.guid.should == "organization-id-2"
42
42
 
43
- subject
43
+ execute_populate_and_save
44
44
 
45
45
  populator.client.current_organization.guid.should == "organization-id-1"
46
46
  end
47
47
 
48
48
  it "returns the organization" do
49
- subject.should == organization
49
+ execute_populate_and_save.should == organization
50
50
  end
51
51
 
52
52
  context "with an organization in the input" do
@@ -54,21 +54,21 @@ module CF
54
54
  before { write_token_file({:organization => "organization-id-2"}) }
55
55
 
56
56
  it "uses that organization" do
57
- subject.should == organization
57
+ execute_populate_and_save.should == organization
58
58
  end
59
59
 
60
60
  it "should not reprompt for organization" do
61
61
  dont_allow_ask("Organization", anything)
62
- subject
62
+ execute_populate_and_save
63
63
  end
64
64
 
65
65
  it "sets the organization in the token file" do
66
- subject
66
+ execute_populate_and_save
67
67
  expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
68
68
  end
69
69
 
70
70
  it "prints out that it is switching to that organization" do
71
- subject
71
+ execute_populate_and_save
72
72
  expect(output).to say("Switching to organization #{organization.name}")
73
73
  end
74
74
 
@@ -80,7 +80,7 @@ module CF
80
80
  end
81
81
 
82
82
  it "removes the space from the token file" do
83
- subject
83
+ execute_populate_and_save
84
84
  refreshed_tokens = YAML.load_file(File.expand_path(tokens_file_path))
85
85
  expect(refreshed_tokens["https://api.some-domain.com"][:space]).to be_nil
86
86
  end
@@ -93,7 +93,7 @@ module CF
93
93
  end
94
94
 
95
95
  it "does not remove the space from the token file" do
96
- subject
96
+ execute_populate_and_save
97
97
  expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "should-not-be-removed"
98
98
  end
99
99
  end
@@ -106,46 +106,57 @@ module CF
106
106
  context "with an organization in the config file" do
107
107
  it "should not reprompt for organization" do
108
108
  dont_allow_ask("Organization", anything)
109
- subject
109
+ execute_populate_and_save
110
110
  end
111
111
 
112
112
  it "sets the organization in the token file" do
113
- subject
113
+ execute_populate_and_save
114
114
  expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
115
115
  end
116
116
 
117
117
  context "but that organization doesn't exist anymore (not valid)" do
118
- before { organization.stub(:users).and_raise(CFoundry::APIError) }
118
+ before do
119
+ client.stub(:organizations).and_return(organizations)
120
+ organization.stub(:users).and_raise(CFoundry::APIError)
121
+ end
119
122
 
120
123
  it "asks the user for an organization" do
121
- mock_ask("Organization", anything) { organization }
122
- subject
124
+ should_ask("Organization", anything) { organization }
125
+ execute_populate_and_save
123
126
  end
124
127
  end
125
128
  end
126
129
 
127
130
  context "without an organization in the config file" do
128
- before { write_token_file({}) }
131
+ context "when the user has organizations" do
132
+ before do
133
+ client.stub(:organizations).and_return(organizations)
134
+ write_token_file({})
135
+ end
129
136
 
130
- it "prompts for the organization" do
131
- mock_ask("Organization", anything) { organization }
132
- subject
137
+ it "prompts for the organization" do
138
+ should_ask("Organization", anything) { organization }
139
+ execute_populate_and_save
133
140
 
134
- expect(output).to say("Switching to organization #{organization.name}")
135
- end
141
+ expect(output).to say("Switching to organization #{organization.name}")
142
+ end
136
143
 
137
- it "sets the organization in the token file" do
138
- mock_ask("Organization", anything) { organization }
144
+ it "sets the organization in the token file" do
145
+ should_ask("Organization", anything) { organization }
139
146
 
140
- subject
141
- expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
147
+ execute_populate_and_save
148
+ expect(tokens_yaml["https://api.some-domain.com"][:organization]).to be == "organization-id-1"
149
+ end
142
150
  end
143
151
 
144
152
  context "when the user has no organizations" do
145
- let(:client) { fake_client :organizations => [] }
153
+ before do
154
+ client.stub(:organizations).and_return([])
155
+ write_token_file({})
156
+ end
146
157
 
147
158
  it "tells the user to create one by raising a UserFriendlyError" do
148
- expect { subject }.to raise_error(CF::UserFriendlyError, /There are no organizations/)
159
+ expect { execute_populate_and_save }.to raise_error(CF::UserFriendlyError, /There are no organizations/)
149
160
  end
150
161
  end
151
162
  end
@@ -2,24 +2,22 @@ require "spec_helper"
2
2
 
3
3
  module CF
4
4
  module Populators
5
-
6
5
  describe Space do
7
6
  stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
8
7
 
9
8
  describe "#populate_and_save!" do
10
- let(:tokens_file_path) { "~/.cf/tokens.yml" }
11
- let(:spaces) {
12
- [double(:space, :name => "Development", :guid => "space-id-1", :developers => [user]),
13
- double(:space, :name => "Staging", :guid => "space-id-2")]
14
- }
15
-
16
- let(:user) { build(:user) }
17
- let(:organization) { double(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => spaces) }
18
- let(:space) { spaces.first }
19
- let(:client) do
20
- fake_client :organizations => [organization]
9
+ let(:spaces) do
10
+ [
11
+ build(:space, :name => "Development", :guid => "space-id-1", :developers => [user]),
12
+ build(:space, :name => "Staging", :guid => "space-id-2")
13
+ ]
21
14
  end
15
+ let(:space) { spaces.first }
16
+ let(:user) { build(:user) }
17
+ let(:client) { build(:client) }
18
+ let(:organization) { build(:organization, :client => client, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => spaces) }
22
19
 
20
+ let(:tokens_file_path) { "~/.cf/tokens.yml" }
23
21
  let(:input_hash) { {:space => space} }
24
22
  let(:inputs) { Mothership::Inputs.new(nil, nil, input_hash) }
25
23
  let(:tokens_yaml) { YAML.load_file(File.expand_path(tokens_file_path)) }
@@ -27,13 +25,10 @@ module CF
27
25
 
28
26
  before do
29
27
  client.stub(:current_user).and_return(user)
30
- client.stub(:space).and_return(space)
31
28
  described_class.any_instance.stub(:client).and_return(client)
32
-
33
- write_token_file({:space => "space-id-1", :organization => "organization-id-1"})
34
29
  end
35
30
 
36
- subject do
31
+ def execute_populate_and_save
37
32
  capture_output { populator.populate_and_save! }
38
33
  end
39
34
 
@@ -42,13 +37,13 @@ module CF
42
37
  described_class.any_instance.unstub(:client)
43
38
  populator.client.current_space.guid.should == "space-id-2"
44
39
 
45
- subject
40
+ execute_populate_and_save
46
41
 
47
42
  populator.client.current_space.guid.should == "space-id-1"
48
43
  end
49
44
 
50
45
  it "returns the space" do
51
- subject.should == space
46
+ execute_populate_and_save.should == space
52
47
  end
53
48
 
54
49
  describe "mothership input arguments" do
@@ -60,7 +55,7 @@ module CF
60
55
  end
61
56
 
62
57
  it "passes through extra arguments to the input call" do
63
- subject
58
+ execute_populate_and_save
64
59
  end
65
60
  end
66
61
 
@@ -69,21 +64,21 @@ module CF
69
64
  before { write_token_file({:space => "space-id-2"}) }
70
65
 
71
66
  it "uses that space" do
72
- subject.should == space
67
+ execute_populate_and_save.should == space
73
68
  end
74
69
 
75
70
  it "should not reprompt for space" do
76
71
  dont_allow_ask("Space", anything)
77
- subject
72
+ execute_populate_and_save
78
73
  end
79
74
 
80
75
  it "sets the space in the token file" do
81
- subject
76
+ execute_populate_and_save
82
77
  expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
83
78
  end
84
79
 
85
80
  it "prints out that it is switching to that space" do
86
- subject
81
+ execute_populate_and_save
87
82
  expect(output).to say("Switching to space #{space.name}")
88
83
  end
89
84
  end
@@ -92,48 +87,64 @@ module CF
92
87
  let(:input_hash) { {} }
93
88
 
94
89
  context "with a space in the config file" do
90
+ before do
91
+ write_token_file({:space => space.guid, :organization => organization.guid})
92
+ client.stub(:space).and_return(space)
93
+ end
94
+
95
95
  it "should not reprompt for space" do
96
96
  dont_allow_ask("Space", anything)
97
- subject
97
+ execute_populate_and_save
98
98
  end
99
99
 
100
100
  it "sets the space in the token file" do
101
- subject
101
+ execute_populate_and_save
102
102
  expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
103
103
  end
104
104
 
105
105
  context "but that space doesn't exist anymore (not valid)" do
106
- before { space.stub(:developers).and_raise(CFoundry::APIError) }
106
+ before do
107
+ space.stub(:developers).and_raise(CFoundry::APIError)
108
+ organization.stub(:spaces).and_return(spaces)
109
+ end
107
110
 
108
111
  it "asks the user for an space" do
109
- mock_ask("Space", anything) { space }
110
- subject
112
+ should_ask("Space", anything) { space }
113
+ execute_populate_and_save
111
114
  end
112
115
  end
113
116
  end
114
117
 
115
118
  context "without a space in the config file" do
116
- before { write_token_file({}) }
119
+ context "when the user has spaces in that organization" do
120
+ before do
121
+ write_token_file({})
122
+ organization.stub(:spaces).and_return(spaces)
123
+ end
117
124
 
118
- it "prompts for the space" do
119
- mock_ask("Space", anything) { space }
120
- subject
125
+ it "prompts for the space" do
126
+ should_ask("Space", anything) { space }
127
+ execute_populate_and_save
121
128
 
122
- expect(output).to say("Switching to space #{space.name}")
123
- end
129
+ expect(output).to say("Switching to space #{space.name}")
130
+ end
124
131
 
125
- it "sets the space in the token file" do
126
- mock_ask("Space", anything) { space }
132
+ it "sets the space in the token file" do
133
+ should_ask("Space", anything) { space }
127
134
 
128
- subject
129
- expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
135
+ execute_populate_and_save
136
+ expect(tokens_yaml["https://api.some-domain.com"][:space]).to be == "space-id-1"
137
+ end
130
138
  end
131
139
 
132
140
  context "when the user has no spaces in that organization" do
133
- let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user]) }
141
+ before do
142
+ write_token_file({})
143
+ organization.stub(:spaces).and_return([])
144
+ end
134
145
 
135
146
  it "tells the user to create one by raising a UserFriendlyError" do
136
- expect { subject }.to raise_error(CF::UserFriendlyError, /There are no spaces/)
147
+ expect { execute_populate_and_save }.to raise_error(CF::UserFriendlyError, /There are no spaces/)
137
148
  end
138
149
  end
139
150
  end
@@ -8,14 +8,16 @@ module CF
8
8
  let(:organization) { double(:organization) }
9
9
  let(:space) { double(:space) }
10
10
 
11
- subject { Target.new(input).populate_and_save! }
11
+ def execute_populate_and_save
12
+ Target.new(input).populate_and_save!
13
+ end
12
14
 
13
15
  it "uses a organization then a space populator" do
14
16
  organization.should_receive(:populate_and_save!).and_return(organization)
15
17
  space.should_receive(:populate_and_save!)
16
18
  Organization.should_receive(:new).with(input).and_return(organization)
17
19
  Space.should_receive(:new).with(input, organization).and_return(space)
18
- subject
20
+ execute_populate_and_save
19
21
  end
20
22
  end
21
23
  end
@@ -6,9 +6,11 @@ describe CF::Route::Delete do
6
6
  route.stub(:delete!)
7
7
  end
8
8
 
9
- let(:route) { fake(:route, :host => host_name, :domain => domain) }
10
- let(:client) { fake_client :routes => [route] }
11
- let(:domain) { fake(:domain, :name => domain_name) }
9
+ let(:client) do
10
+ build(:client).tap { |client| client.stub(:routes => [route]) }
11
+ end
12
+ let(:route) { build(:route, :host => host_name, :domain => domain) }
13
+ let(:domain) { build(:domain, :name => domain_name) }
12
14
  let(:domain_name) { "some-domain.com" }
13
15
  let(:host_name) { "some-host" }
14
16
  let(:url) { "#{host_name}.#{domain_name}" }
@@ -36,7 +38,7 @@ describe CF::Route::Delete do
36
38
  let(:command) { cf %W[delete-route #{url}] }
37
39
 
38
40
  it "prompts the user are they sure?" do
39
- mock_ask("Really delete #{url}?", {:default => false}) { true }
41
+ should_ask("Really delete #{url}?", {:default => false}) { true }
40
42
 
41
43
  command
42
44
  end
@@ -7,11 +7,11 @@ module CF
7
7
  stub_client_and_precondition
8
8
  end
9
9
 
10
- let(:client) { fake_client(:apps => apps, :routes => routes) }
10
+ let(:client) { build(:client) }
11
11
 
12
- let(:app) { fake(:app, :space => space, :name => "app-name") }
13
- let(:space) { fake(:space, :domains => space_domains).as_null_object }
14
- let(:domain) { fake(:domain, :name => "domain-name-1").as_null_object }
12
+ let(:app) { build(:app, :space => space, :name => "app-name") }
13
+ let(:space) { build(:space, :domains => space_domains) }
14
+ let(:domain) { build(:domain, :name => "domain-name-1") }
15
15
 
16
16
  let(:apps) { [app] }
17
17
  let(:routes) { [] }
@@ -25,12 +25,13 @@ module CF
25
25
  context "and the domain is mapped to the space" do
26
26
  let(:space_domains) { [domain] }
27
27
 
28
+ before do
29
+ space.stub(:domain_by_name).with(domain.name).and_return(domain)
30
+ end
31
+
28
32
  context "and the route is mapped to the space" do
29
33
  let(:routes) { [route] }
30
- let(:route) do
31
- fake(:route, :space => space, :host => host_name,
32
- :domain => domain)
33
- end
34
+ let(:route) { build(:route, :space => space, :host => host_name, :domain => domain) }
34
35
 
35
36
  it "binds the route to the app" do
36
37
  app.should_receive(:add_route).with(route)
@@ -39,7 +40,7 @@ module CF
39
40
  end
40
41
 
41
42
  context "and the route is not mapped to the space" do
42
- let(:new_route) { fake(:route) }
43
+ let(:new_route) { build(:route) }
43
44
 
44
45
  before do
45
46
  client.stub(:route).and_return(new_route)
@@ -76,16 +77,47 @@ module CF
76
77
  context "when an app is specified" do
77
78
  subject { cf(%W[map #{app.name} #{host_name} #{domain.name}]) }
78
79
 
79
- context "and the domain is not already mapped to the space" do
80
- let(:space_domains) { [] }
80
+ before do
81
+ client.stub(:apps).and_return(apps)
82
+ client.stub(:routes).and_return(routes)
83
+ end
81
84
 
82
- it "indicates that the domain is invalid" do
83
- subject
84
- expect(error_output).to say("Unknown domain")
85
+ context "when a host is specified" do
86
+ context "and the domain is not already mapped to the space" do
87
+ before do
88
+ space.stub(:domain_by_name).with(domain.name).and_return(nil)
89
+ end
90
+
91
+ it "indicates that the domain is invalid" do
92
+ subject
93
+ expect(error_output).to say("Unknown domain")
94
+ end
85
95
  end
96
+
97
+ include_examples "mapping the route to the app"
86
98
  end
87
99
 
88
- include_examples "mapping the route to the app"
100
+ context "when a host is not specified" do
101
+ let(:new_route) { build(:route) }
102
+ let(:host_name) { "" }
103
+
104
+ before do
105
+ client.stub(:route).and_return(new_route)
106
+ client.stub(:app_by_name).with(app.name).and_return(app)
107
+ client.stub(:routes_by_host).with(host_name, {:depth => 0}).and_return([new_route])
108
+ app.stub(:add_route)
109
+ space.stub(:domain_by_name).with(domain.name).and_return(domain)
110
+ new_route.stub(:create!)
111
+ end
112
+
113
+ it "creates a route with an empty string as its host" do
114
+ new_route.should_receive(:create!)
115
+ subject
116
+ expect(new_route.host).to eq ""
117
+ end
118
+
119
+ include_examples "mapping the route to the app"
120
+ end
89
121
  end
90
122
 
91
123
  context "when an app is not specified" do
@@ -94,36 +126,23 @@ module CF
94
126
 
95
127
  subject { cf %W[map --host #{host_name} #{domain.name}] }
96
128
 
97
- before { stub_ask("Which application?", anything) { app } }
129
+ before do
130
+ client.stub(:apps).and_return(apps)
131
+ stub_ask("Which application?", anything) { app }
132
+ space.stub(:domain_by_name).with(domain.name).and_return(domain)
133
+ client.stub(:routes_by_host).with(host_name, {:depth => 0}).and_return(routes)
134
+ end
98
135
 
99
136
  it "asks for an app" do
100
137
  client.stub(:route).and_return(new_route)
101
138
  app.stub(:add_route)
102
139
  new_route.stub(:create!)
103
- mock_ask("Which application?", anything) { app }
140
+ should_ask("Which application?", anything) { app }
104
141
  subject
105
142
  end
106
143
 
107
144
  include_examples "mapping the route to the app"
108
145
  end
109
-
110
- context "when a host is not specified" do
111
- let(:new_route) { build(:route) }
112
-
113
- subject { cf %W[map #{app.name} #{domain.name}] }
114
-
115
- before do
116
- client.stub(:route).and_return(new_route)
117
- app.stub(:add_route)
118
- new_route.stub(:create!)
119
- end
120
-
121
- it "creates a route with an empty string as its host" do
122
- new_route.should_receive(:create!)
123
- subject
124
- expect(new_route.host).to eq ""
125
- end
126
- end
127
146
  end
128
147
  end
129
148
  end