vmc 0.5.1.rc4 → 0.5.1.rc5

Sign up to get free protection for your applications and to get access to all the features.
@@ -109,6 +109,8 @@ module VMC
109
109
  err e.message
110
110
  rescue SystemExit
111
111
  raise
112
+ rescue UserFriendlyError => e
113
+ err e.message
112
114
  rescue CFoundry::Forbidden, CFoundry::InvalidAuthToken => e
113
115
  if !$vmc_asked_auth
114
116
  $vmc_asked_auth = true
@@ -14,8 +14,6 @@ module VMC::App
14
14
  if v2?
15
15
  inputs[:production] = !!(input[:plan] =~ /^p/i)
16
16
  inputs[:command] = input[:command] if input.has?(:command) || !has_procfile?
17
-
18
- framework = detector.detect_framework
19
17
  else
20
18
  framework = inputs[:framework] = determine_framework
21
19
  inputs[:runtime] = determine_runtime(framework)
@@ -24,7 +22,13 @@ module VMC::App
24
22
 
25
23
  inputs[:buildpack] = input[:buildpack] if v2?
26
24
 
27
- human_mb = human_mb(detector.suggested_memory(framework) || 64)
25
+ if v2?
26
+ detected = detector.detected
27
+ human_mb = human_mb((detected && detected.memory_suggestion) || 64)
28
+ else
29
+ human_mb = human_mb(detector.suggested_memory(framework) || 64)
30
+ end
31
+
28
32
  inputs[:memory] = megabytes(input[:memory, human_mb])
29
33
 
30
34
  inputs[:stack] = input[:stack] if v2?
@@ -76,12 +76,12 @@ module VMC
76
76
  @all_frameworks ||= @client.frameworks
77
77
  end
78
78
 
79
- private
80
-
81
79
  def detected
82
80
  @detected ||= Clouseau.detect(@path)
83
81
  end
84
82
 
83
+ private
84
+
85
85
  def map_detectors!
86
86
  @framework_detectors = {}
87
87
  @detector_frameworks = {}
@@ -1,5 +1,5 @@
1
1
  module VMC
2
- class UserError < RuntimeError
2
+ class UserFriendlyError < RuntimeError
3
3
  def initialize(msg)
4
4
  @message = msg
5
5
  end
@@ -9,6 +9,8 @@ module VMC
9
9
  end
10
10
  end
11
11
 
12
+ class UserError < UserFriendlyError; end
13
+
12
14
  class NotAuthorized < UserError
13
15
  def initialize
14
16
  @message = "Not authorized."
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.5.1.rc4".freeze
2
+ VERSION = "0.5.1.rc5".freeze
3
3
  end
@@ -39,10 +39,21 @@ if ENV['VMC_V2_TEST_USER'] && ENV['VMC_V2_TEST_PASSWORD'] && ENV['VMC_V2_TEST_TA
39
39
  end
40
40
 
41
41
  run("#{vmc_bin} login #{username} --password #{password}") do |runner|
42
- expect(runner).to say "Organization>"
43
- runner.send_keys "1"
44
- expect(runner).to say "Space>"
45
- runner.send_keys "1"
42
+ expect(runner).to say(
43
+ "Organization>" => proc {
44
+ runner.send_keys "1"
45
+ expect(runner).to say /Switching to organization .*\.\.\. OK/
46
+ },
47
+ "Switching to organization" => proc {}
48
+ )
49
+
50
+ expect(runner).to say(
51
+ "Space>" => proc {
52
+ runner.send_keys "1"
53
+ expect(runner).to say /Switching to space .*\.\.\. OK/
54
+ },
55
+ "Switching to space" => proc {}
56
+ )
46
57
  end
47
58
 
48
59
  puts "registering #{email}"
@@ -35,6 +35,8 @@ if ENV['VMC_V2_TEST_USER'] && ENV['VMC_V2_TEST_PASSWORD'] && ENV['VMC_V2_TEST_TA
35
35
  before do
36
36
  run("#{vmc_bin} login #{username} --password #{password}") do |runner|
37
37
  expect(runner).to say "Authenticating... OK"
38
+ expect(runner).to say "Organization>"
39
+ runner.send_keys("pivotal")
38
40
 
39
41
  expect(runner).to say "Switching to organization"
40
42
  expect(runner).to say "OK"
@@ -7,10 +7,19 @@ require "vmc"
7
7
  require "vmc/test_support"
8
8
  require "webmock"
9
9
  require "ostruct"
10
+ require "fakefs/safe"
10
11
 
11
12
  INTEGRATE_WITH = ENV["INTEGRATE_WITH"] || "default"
12
13
  TRAVIS_BUILD_ID = ENV["TRAVIS_BUILD_ID"]
13
14
 
15
+ OriginalFile = File
16
+
17
+ class FakeFS::File
18
+ def self.fnmatch(*args, &blk)
19
+ OriginalFile.fnmatch(*args, &blk)
20
+ end
21
+ end
22
+
14
23
  def vmc_bin
15
24
  vmc = File.expand_path("#{SPEC_ROOT}/../bin/vmc.dev")
16
25
  if INTEGRATE_WITH != 'default'
@@ -76,8 +76,6 @@ describe VMC::App::Create do
76
76
  FakeFS.activate!
77
77
  Dir.mkdir(path)
78
78
 
79
- # fakefs removes fnmatch :'(
80
- stub(create.send(:detector)).detect_framework
81
79
  File.open("#{path}/Procfile", "w") do |file|
82
80
  file.write("this is a procfile")
83
81
  end
@@ -152,9 +150,6 @@ describe VMC::App::Create do
152
150
  before do
153
151
  FakeFS.activate!
154
152
  Dir.mkdir(path)
155
-
156
- # fakefs removes fnmatch :'(
157
- stub(create.send(:detector)).detect_framework
158
153
  end
159
154
 
160
155
  after do
@@ -192,14 +187,29 @@ describe VMC::App::Create do
192
187
  subject
193
188
  end
194
189
 
190
+ # this is hacky, but will get better once we remove all the v1-specific
191
+ # logic, as we won't have to worry about this anyway as the code will be gone
192
+ #
193
+ # we wanted to spec for this because frameworks/runtimes will be gone on
194
+ # v2, and if we don't fix it now, vmc push will blow up
195
195
  it 'asks for the memory' do
196
196
  given.delete(:memory)
197
197
 
198
198
  memory_choices = %w(64M 128M 256M 512M 1G)
199
199
  stub(create).memory_choices { memory_choices }
200
200
 
201
+ detector = mock
202
+ detected = mock
203
+ dont_allow(detector).detect_framework
204
+
205
+ stub(detected).memory_suggestion { 128 }
206
+
207
+ stub(create).detector { detector }
208
+ stub(detector).detected { detected }
209
+
201
210
  mock_ask('Memory Limit', anything) do |_, options|
202
211
  expect(options[:choices]).to eq memory_choices
212
+ expect(options[:default]).to eq "128M"
203
213
  "1G"
204
214
  end
205
215
 
@@ -36,6 +36,13 @@ describe VMC::CLI do
36
36
  end
37
37
  end
38
38
 
39
+ context "with a UserFriendlyError" do
40
+ let(:action) { proc { raise VMC::UserFriendlyError.new("user friendly") } }
41
+
42
+ it_behaves_like "an error that's obvious to the user",
43
+ :with_message => "user friendly"
44
+ end
45
+
39
46
  context "with a SystemExit" do
40
47
  let(:action) { proc { exit 1 } }
41
48
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1784256881
4
+ hash: -1558593090
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
9
  - 1
10
10
  - rc
11
- - 4
12
- version: 0.5.1.rc4
11
+ - 5
12
+ version: 0.5.1.rc5
13
13
  platform: ruby
14
14
  authors:
15
15
  - Cloud Foundry Team
@@ -18,10 +18,12 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2013-03-14 00:00:00 Z
21
+ date: 2013-03-21 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ name: json_pure
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
25
27
  none: false
26
28
  requirements:
27
29
  - - ~>
@@ -31,12 +33,12 @@ dependencies:
31
33
  - 1
32
34
  - 6
33
35
  version: "1.6"
34
- prerelease: false
35
36
  type: :runtime
36
- name: json_pure
37
- requirement: *id001
37
+ version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ name: multi_json
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
40
42
  none: false
41
43
  requirements:
42
44
  - - ~>
@@ -46,12 +48,12 @@ dependencies:
46
48
  - 1
47
49
  - 3
48
50
  version: "1.3"
49
- prerelease: false
50
51
  type: :runtime
51
- name: multi_json
52
- requirement: *id002
52
+ version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ name: interact
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
55
57
  none: false
56
58
  requirements:
57
59
  - - ~>
@@ -61,24 +63,24 @@ dependencies:
61
63
  - 0
62
64
  - 5
63
65
  version: "0.5"
64
- prerelease: false
65
66
  type: :runtime
66
- name: interact
67
- requirement: *id003
67
+ version_requirements: *id003
68
68
  - !ruby/object:Gem::Dependency
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ name: cfoundry
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
70
72
  none: false
71
73
  requirements:
72
74
  - - ">="
73
75
  - !ruby/object:Gem::Version
74
- hash: 1784256867
76
+ hash: -1558593112
75
77
  segments:
76
78
  - 0
77
79
  - 5
78
80
  - 3
79
81
  - rc
80
- - 5
81
- version: 0.5.3.rc5
82
+ - 6
83
+ version: 0.5.3.rc6
82
84
  - - <
83
85
  - !ruby/object:Gem::Version
84
86
  hash: 7
@@ -86,12 +88,12 @@ dependencies:
86
88
  - 0
87
89
  - 6
88
90
  version: "0.6"
89
- prerelease: false
90
91
  type: :runtime
91
- name: cfoundry
92
- requirement: *id004
92
+ version_requirements: *id004
93
93
  - !ruby/object:Gem::Dependency
94
- version_requirements: &id005 !ruby/object:Gem::Requirement
94
+ name: clouseau
95
+ prerelease: false
96
+ requirement: &id005 !ruby/object:Gem::Requirement
95
97
  none: false
96
98
  requirements:
97
99
  - - ~>
@@ -101,12 +103,12 @@ dependencies:
101
103
  - 0
102
104
  - 0
103
105
  version: "0.0"
104
- prerelease: false
105
106
  type: :runtime
106
- name: clouseau
107
- requirement: *id005
107
+ version_requirements: *id005
108
108
  - !ruby/object:Gem::Dependency
109
- version_requirements: &id006 !ruby/object:Gem::Requirement
109
+ name: mothership
110
+ prerelease: false
111
+ requirement: &id006 !ruby/object:Gem::Requirement
110
112
  none: false
111
113
  requirements:
112
114
  - - ">="
@@ -124,17 +126,17 @@ dependencies:
124
126
  - 1
125
127
  - 0
126
128
  version: "1.0"
127
- prerelease: false
128
129
  type: :runtime
129
- name: mothership
130
- requirement: *id006
130
+ version_requirements: *id006
131
131
  - !ruby/object:Gem::Dependency
132
- version_requirements: &id007 !ruby/object:Gem::Requirement
132
+ name: manifests-vmc-plugin
133
+ prerelease: false
134
+ requirement: &id007 !ruby/object:Gem::Requirement
133
135
  none: false
134
136
  requirements:
135
137
  - - ">="
136
138
  - !ruby/object:Gem::Version
137
- hash: 1784256861
139
+ hash: -1558593136
138
140
  segments:
139
141
  - 0
140
142
  - 6
@@ -149,12 +151,12 @@ dependencies:
149
151
  - 0
150
152
  - 7
151
153
  version: "0.7"
152
- prerelease: false
153
154
  type: :runtime
154
- name: manifests-vmc-plugin
155
- requirement: *id007
155
+ version_requirements: *id007
156
156
  - !ruby/object:Gem::Dependency
157
- version_requirements: &id008 !ruby/object:Gem::Requirement
157
+ name: tunnel-vmc-plugin
158
+ prerelease: false
159
+ requirement: &id008 !ruby/object:Gem::Requirement
158
160
  none: false
159
161
  requirements:
160
162
  - - ~>
@@ -165,12 +167,12 @@ dependencies:
165
167
  - 2
166
168
  - 2
167
169
  version: 0.2.2
168
- prerelease: false
169
170
  type: :runtime
170
- name: tunnel-vmc-plugin
171
- requirement: *id008
171
+ version_requirements: *id008
172
172
  - !ruby/object:Gem::Dependency
173
- version_requirements: &id009 !ruby/object:Gem::Requirement
173
+ name: rake
174
+ prerelease: false
175
+ requirement: &id009 !ruby/object:Gem::Requirement
174
176
  none: false
175
177
  requirements:
176
178
  - - ~>
@@ -180,12 +182,12 @@ dependencies:
180
182
  - 0
181
183
  - 9
182
184
  version: "0.9"
183
- prerelease: false
184
185
  type: :development
185
- name: rake
186
- requirement: *id009
186
+ version_requirements: *id009
187
187
  - !ruby/object:Gem::Dependency
188
- version_requirements: &id010 !ruby/object:Gem::Requirement
188
+ name: rspec
189
+ prerelease: false
190
+ requirement: &id010 !ruby/object:Gem::Requirement
189
191
  none: false
190
192
  requirements:
191
193
  - - ~>
@@ -195,12 +197,12 @@ dependencies:
195
197
  - 2
196
198
  - 11
197
199
  version: "2.11"
198
- prerelease: false
199
200
  type: :development
200
- name: rspec
201
- requirement: *id010
201
+ version_requirements: *id010
202
202
  - !ruby/object:Gem::Dependency
203
- version_requirements: &id011 !ruby/object:Gem::Requirement
203
+ name: webmock
204
+ prerelease: false
205
+ requirement: &id011 !ruby/object:Gem::Requirement
204
206
  none: false
205
207
  requirements:
206
208
  - - ~>
@@ -210,12 +212,12 @@ dependencies:
210
212
  - 1
211
213
  - 9
212
214
  version: "1.9"
213
- prerelease: false
214
215
  type: :development
215
- name: webmock
216
- requirement: *id011
216
+ version_requirements: *id011
217
217
  - !ruby/object:Gem::Dependency
218
- version_requirements: &id012 !ruby/object:Gem::Requirement
218
+ name: rr
219
+ prerelease: false
220
+ requirement: &id012 !ruby/object:Gem::Requirement
219
221
  none: false
220
222
  requirements:
221
223
  - - ~>
@@ -225,10 +227,8 @@ dependencies:
225
227
  - 1
226
228
  - 0
227
229
  version: "1.0"
228
- prerelease: false
229
230
  type: :development
230
- name: rr
231
- requirement: *id012
231
+ version_requirements: *id012
232
232
  description:
233
233
  email:
234
234
  - vcap-dev@googlegroups.com