cfoundry 2.2.0.rc1 → 2.2.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "2.2.0.rc1".freeze
3
+ VERSION = "2.2.0.rc2".freeze
4
4
  end
@@ -3,12 +3,12 @@ require 'spec_helper'
3
3
  describe CFoundry::BaseClient do
4
4
  describe "#request" do
5
5
  before do
6
- stub(subject).handle_response(anything, anything, anything)
6
+ subject.stub(:handle_response).with(anything, anything, anything)
7
7
  end
8
8
 
9
9
  context "when given multiple segments" do
10
10
  it "encodes the segments and joins them with '/'" do
11
- mock(subject).request_raw("GET", "foo/bar%2Fbaz", {})
11
+ subject.should_receive(:request_raw).with("GET", "foo/bar%2Fbaz", {})
12
12
  subject.request("GET", "foo", "bar/baz")
13
13
  end
14
14
  end
@@ -16,14 +16,14 @@ describe CFoundry::BaseClient do
16
16
  context "when the first segment starts with a '/'" do
17
17
  context "and there's only one segment" do
18
18
  it "requests with the segment unaltered" do
19
- mock(subject).request_raw("GET", "/v2/apps", {})
19
+ subject.should_receive(:request_raw).with("GET", "/v2/apps", {})
20
20
  subject.request("GET", "/v2/apps")
21
21
  end
22
22
  end
23
23
 
24
24
  context "and there's more than one segment" do
25
25
  it "encodes the segments and joins them with '/'" do
26
- mock(subject).request_raw("GET", "%2Ffoo/bar%2Fbaz", {})
26
+ subject.should_receive(:request_raw).with("GET", "%2Ffoo/bar%2Fbaz", {})
27
27
  subject.request("GET", "/foo", "bar/baz")
28
28
  end
29
29
  end
@@ -34,9 +34,9 @@ describe CFoundry::BaseClient do
34
34
  let(:token) { CFoundry::AuthToken.new("bearer something", refresh_token) }
35
35
 
36
36
  before do
37
- stub(subject).request_raw
37
+ subject.stub(:request_raw)
38
38
  subject.token = token
39
- stub(token).expires_soon? { expires_soon? }
39
+ token.stub(:expires_soon?) { expires_soon? }
40
40
  end
41
41
 
42
42
  context "and the token is about to expire" do
@@ -47,12 +47,12 @@ describe CFoundry::BaseClient do
47
47
  let(:refresh_token) { "some-refresh-token" }
48
48
 
49
49
  it "sets the token's auth header to nil to prevent recursion" do
50
- stub(subject).refresh_token!
50
+ subject.stub(:refresh_token!)
51
51
  subject.request("GET", "foo")
52
52
  end
53
53
 
54
54
  it "refreshes the access token" do
55
- mock(subject).refresh_token!
55
+ subject.should_receive(:refresh_token!)
56
56
  subject.request("GET", "foo")
57
57
  end
58
58
  end
@@ -61,8 +61,8 @@ describe CFoundry::BaseClient do
61
61
  let(:refresh_token) { nil }
62
62
 
63
63
  it "moves along" do
64
- mock(subject).request_raw(anything, anything, anything)
65
- dont_allow(subject).refresh_token!
64
+ subject.should_receive(:request_raw).with(anything, anything, anything)
65
+ subject.should_not_receive(:refresh_token!)
66
66
  subject.request("GET", "foo")
67
67
  end
68
68
  end
@@ -72,8 +72,8 @@ describe CFoundry::BaseClient do
72
72
  let(:expires_soon?) { nil }
73
73
 
74
74
  it "moves along" do
75
- mock(subject).request_raw(anything, anything, anything)
76
- dont_allow(subject).refresh_token!
75
+ subject.should_receive(:request_raw).with(anything, anything, anything)
76
+ subject.should_not_receive(:refresh_token!)
77
77
  subject.request("GET", "foo")
78
78
  end
79
79
  end
@@ -86,10 +86,10 @@ describe CFoundry::BaseClient do
86
86
  let(:new_access_token) { Base64.encode64(%Q|{"algo": "h1234"}{"a":"x"}random-bytes|) }
87
87
  let(:auth_token) { CFoundry::AuthToken.new("bearer #{access_token}", refresh_token) }
88
88
 
89
- before { stub(subject).uaa { uaa } }
89
+ before { subject.stub(:uaa) { uaa } }
90
90
 
91
91
  it "refreshes the token with UAA client and assigns it" do
92
- mock(uaa).try_to_refresh_token! {
92
+ uaa.should_receive(:try_to_refresh_token!) {
93
93
  CFoundry::AuthToken.new("bearer #{new_access_token}", auth_token.refresh_token)
94
94
  }
95
95
 
@@ -106,7 +106,7 @@ describe CFoundry::BaseClient do
106
106
  let(:info) { { :authorization_endpoint => "http://uaa.example.com" } }
107
107
 
108
108
  before do
109
- stub(subject).info { info }
109
+ subject.stub(:info) { info }
110
110
  end
111
111
 
112
112
  describe "#uaa" do
@@ -121,7 +121,7 @@ describe CFoundry::BaseClient do
121
121
 
122
122
  it "has the same AuthToken as BaseClient" do
123
123
  token = CFoundry::AuthToken.new(nil)
124
- stub(subject).token { token }
124
+ subject.stub(:token) { token }
125
125
  expect(subject.uaa.token).to eq token
126
126
  end
127
127
 
@@ -157,7 +157,7 @@ describe CFoundry::BaseClient do
157
157
 
158
158
  context "with no uaa endpoint" do
159
159
  before do
160
- stub(subject).info { { :something => "else" } }
160
+ subject.stub(:info) { { :something => "else" } }
161
161
  end
162
162
 
163
163
  describe "#uaa" do
@@ -172,18 +172,18 @@ describe CFoundry::BaseClient do
172
172
  describe "#password_score" do
173
173
  context "with a uaa" do
174
174
  before do
175
- stub(subject).info { { :authorization_endpoint => "http://uaa.example.com" } }
175
+ subject.stub(:info) { { :authorization_endpoint => "http://uaa.example.com" } }
176
176
  end
177
177
 
178
178
  it "delegates to the uaa's password strength method" do
179
- mock(subject.uaa).password_score('password')
179
+ subject.uaa.should_receive(:password_score).with('password')
180
180
  subject.password_score('password')
181
181
  end
182
182
  end
183
183
 
184
184
  context "without a uaa" do
185
185
  before do
186
- stub(subject).info { { :something => "else" } }
186
+ subject.stub(:info) { { :something => "else" } }
187
187
  end
188
188
 
189
189
  it "returns :unknown" do
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe CFoundry::Client do
4
4
  before do
5
- any_instance_of(CFoundry::V2::Client) { |cli| stub(cli).info }
5
+ CFoundry::V2::Client.any_instance.stub(:info)
6
6
  end
7
7
 
8
8
  subject { CFoundry::Client.new('http://example.com') }
@@ -258,8 +258,8 @@ describe CFoundry::RestClient do
258
258
  end
259
259
 
260
260
  it "prints the request and the response" do
261
- mock(rest_client).print_request({:headers => {"Content-Length" => 0}, :url => "https://api.cloudfoundry.com/some-path", :method => "GET", :body => nil})
262
- mock(rest_client).print_response({:status => "200", :headers => {"content-type" => "application/json"}, :body => '{"some": "json"}'})
261
+ rest_client.should_receive(:print_request).with({:headers => {"Content-Length" => 0}, :url => "https://api.cloudfoundry.com/some-path", :method => "GET", :body => nil})
262
+ rest_client.should_receive(:print_response).with({:status => "200", :headers => {"content-type" => "application/json"}, :body => '{"some": "json"}'})
263
263
  subject
264
264
  end
265
265
  end
@@ -20,7 +20,7 @@ EOF
20
20
 
21
21
  shared_examples "UAA wrapper" do
22
22
  it "converts UAA errors to CFoundry equivalents" do
23
- mock(uaa).wrap_uaa_errors { nil }
23
+ uaa.should_receive(:wrap_uaa_errors) { nil }
24
24
  subject
25
25
  end
26
26
  end
@@ -75,21 +75,21 @@ EOF
75
75
  subject { uaa.authorize(username, password) }
76
76
 
77
77
  before do
78
- stub(issuer).owner_password_grant { auth }
79
- stub(uaa).token_issuer { issuer }
78
+ issuer.stub(:owner_password_grant) { auth }
79
+ uaa.stub(:token_issuer) { issuer }
80
80
  end
81
81
 
82
82
  include_examples "UAA wrapper"
83
83
 
84
84
  it 'returns the token on successful authentication' do
85
- mock(issuer).owner_password_grant(username, password) { auth }
85
+ issuer.should_receive(:owner_password_grant).with(username, password) { auth }
86
86
  expect(subject).to eq auth
87
87
  end
88
88
 
89
89
  context 'when authorization fails' do
90
90
  context 'in the expected way' do
91
91
  it 'raises a CFoundry::Denied error' do
92
- mock(issuer).owner_password_grant(anything, anything) { raise CF::UAA::BadResponse.new("401: FooBar") }
92
+ issuer.should_receive(:owner_password_grant) { raise CF::UAA::BadResponse.new("401: FooBar") }
93
93
  expect { subject }.to raise_error(CFoundry::Denied, "401: Authorization failed")
94
94
  end
95
95
  end
@@ -97,28 +97,28 @@ EOF
97
97
 
98
98
  context 'in an unexpected way' do
99
99
  it 'raises a CFoundry::Denied error' do
100
- mock(issuer).owner_password_grant(anything, anything) { raise CF::UAA::BadResponse.new("no_status_code") }
100
+ issuer.should_receive(:owner_password_grant) { raise CF::UAA::BadResponse.new("no_status_code") }
101
101
  expect { subject }.to raise_error(CFoundry::Denied, "400: Authorization failed")
102
102
  end
103
103
  end
104
104
 
105
105
  context "with a CF::UAA::TargetError" do
106
106
  before do
107
- stub(issuer).owner_password_grant { raise CF::UAA::TargetError.new("useless info") }
107
+ issuer.stub(:owner_password_grant) { raise CF::UAA::TargetError.new("useless info") }
108
108
  end
109
109
 
110
110
  it "retries with implicit grant" do
111
- mock(issuer).implicit_grant_with_creds(:username => username, :password => password)
111
+ issuer.should_receive(:implicit_grant_with_creds).with(:username => username, :password => password)
112
112
  expect { subject }.to_not raise_error
113
113
  end
114
114
 
115
115
  it "fails with Denied when given a 401" do
116
- stub(issuer).implicit_grant_with_creds(anything) { raise CF::UAA::BadResponse.new("status 401") }
116
+ issuer.stub(:implicit_grant_with_creds) { raise CF::UAA::BadResponse.new("status 401") }
117
117
  expect { subject }.to raise_error(CFoundry::Denied, "401: Authorization failed")
118
118
  end
119
119
 
120
120
  it "fails with Denied when given any other status code" do
121
- stub(issuer).implicit_grant_with_creds(anything) { raise CF::UAA::BadResponse.new("no status code") }
121
+ issuer.stub(:implicit_grant_with_creds) { raise CF::UAA::BadResponse.new("no status code") }
122
122
  expect { subject }.to raise_error(CFoundry::Denied, "400: Authorization failed")
123
123
  end
124
124
  end
@@ -277,7 +277,7 @@ EOF
277
277
  subject { uaa }
278
278
 
279
279
  it "wraps uaa errors" do
280
- mock(uaa).wrap_uaa_errors
280
+ uaa.should_receive(:wrap_uaa_errors)
281
281
  subject.delete_user(guid)
282
282
  end
283
283
 
@@ -351,7 +351,7 @@ EOF
351
351
 
352
352
  describe "#try_to_refresh_token!" do
353
353
  it "uses the refresh token to get a new access token" do
354
- mock(uaa.send(:token_issuer)).refresh_token_grant(uaa.token.refresh_token) do
354
+ uaa.send(:token_issuer).should_receive(:refresh_token_grant).with(uaa.token.refresh_token) do
355
355
  CF::UAA::TokenInfo.new(
356
356
  :token_type => "bearer",
357
357
  :access_token => "refreshed-token",
@@ -365,7 +365,7 @@ EOF
365
365
 
366
366
  context "when the refresh token has expired" do
367
367
  it "returns the current token" do
368
- stub(uaa.send(:token_issuer)).refresh_token_grant do
368
+ uaa.send(:token_issuer).should_receive(:refresh_token_grant) do
369
369
  raise CF::UAA::TargetError.new
370
370
  end
371
371
 
@@ -16,9 +16,9 @@ module CFoundry
16
16
 
17
17
  def mock_zip(*args, &block)
18
18
  if args.empty?
19
- mock(CFoundry::Zip).pack.with_any_args(&block)
19
+ CFoundry::Zip.should_receive(:pack, &block)
20
20
  else
21
- mock(CFoundry::Zip).pack(*args, &block)
21
+ CFoundry::Zip.should_receive(:pack).with(*args, &block)
22
22
  end
23
23
  end
24
24
 
@@ -33,11 +33,11 @@ module CFoundry
33
33
  let(:model) { TestModelWithUploadHelpers.new(guid, client) }
34
34
 
35
35
  before do
36
- stub(client).base { base }
37
- stub(base).upload_app.with_any_args
36
+ client.stub(:base) { base }
37
+ base.stub(:upload_app)
38
38
 
39
39
  FileUtils.rm_rf tmpdir
40
- stub(Dir).tmpdir do
40
+ Dir.stub(:tmpdir) do
41
41
  FileUtils.mkdir_p tmpdir
42
42
  tmpdir
43
43
  end
@@ -46,13 +46,13 @@ module CFoundry
46
46
  it "zips the app and uploads the zip file" do
47
47
  zip_path = "#{tmpdir}/#{guid}.zip"
48
48
  mock_zip(anything, zip_path) { true }
49
- mock(base).upload_app(guid, zip_path, [])
49
+ base.stub(:upload_app).with(guid, zip_path, [])
50
50
  model.upload(path, check_resources)
51
51
  end
52
52
 
53
53
  it "uploads an app with the right guid" do
54
54
  mock_zip
55
- mock(base).upload_app(guid, anything, anything)
55
+ base.should_receive(:upload_app).with(guid, anything, anything)
56
56
  model.upload(path, check_resources)
57
57
  end
58
58
 
@@ -112,7 +112,7 @@ module CFoundry
112
112
  before { mock_zip { false } }
113
113
 
114
114
  it "passes `false` to #upload_app" do
115
- mock(base).upload_app(guid, false, [])
115
+ base.should_receive(:upload_app).with(guid, false, [])
116
116
  model.upload(path, check_resources)
117
117
  end
118
118
  end
@@ -122,17 +122,17 @@ module CFoundry
122
122
  let(:path) { "#{SPEC_ROOT}/fixtures/apps/with_nested_directories" }
123
123
 
124
124
  it "prunes them before zipping" do
125
- stub(model).make_fingerprints(anything) do
125
+ model.stub(:make_fingerprints).with(anything) do
126
126
  [[], CFoundry::UploadHelpers::RESOURCE_CHECK_LIMIT + 1]
127
127
  end
128
128
 
129
- stub(base).resource_match(anything) do
129
+ base.stub(:resource_match).with(anything) do
130
130
  %w{ xyz foo/bar/baz/fizz }.map do |path|
131
131
  {:fn => "#{tmpdir}/.cf_#{guid}_files/#{path}"}
132
132
  end
133
133
  end
134
134
 
135
- mock(base).upload_app(anything, false, anything)
135
+ base.should_receive(:upload_app).with(anything, false, anything)
136
136
  model.upload(path)
137
137
  end
138
138
  end
@@ -142,17 +142,17 @@ module CFoundry
142
142
  let(:path) { "#{SPEC_ROOT}/fixtures/apps/with_dotfiles" }
143
143
 
144
144
  it "does not prune them" do
145
- stub(model).make_fingerprints(anything) do
145
+ model.stub(:make_fingerprints).with(anything) do
146
146
  [[], CFoundry::UploadHelpers::RESOURCE_CHECK_LIMIT + 1]
147
147
  end
148
148
 
149
- stub(base).resource_match(anything) do
149
+ base.stub(:resource_match).with(anything) do
150
150
  %w{ xyz }.map do |path|
151
151
  {:fn => "#{tmpdir}/.cf_#{guid}_files/#{path}"}
152
152
  end
153
153
  end
154
154
 
155
- mock(base).upload_app(anything, anything, anything) do |_, zip, _|
155
+ base.should_receive(:upload_app).with(anything, anything, anything) do |_, zip, _|
156
156
  expect(zip).to be_a(String)
157
157
  end
158
158
 
@@ -179,4 +179,4 @@ module CFoundry
179
179
  end
180
180
  end
181
181
  end
182
- end
182
+ end
@@ -60,7 +60,7 @@ module CFoundry
60
60
  let(:app) { build(:app) }
61
61
 
62
62
  it "assigns :instances as #total_instances" do
63
- stub(app).summary { {:instances => 4} }
63
+ app.stub(:summary) { {:instances => 4} }
64
64
 
65
65
  app.summarize!
66
66
 
@@ -73,14 +73,14 @@ module CFoundry
73
73
  let(:response) { {:body => '{ "foo": "bar" }'} }
74
74
 
75
75
  before do
76
- stub(client.base).put("v2", "apps", subject.guid, anything) do
76
+ client.base.stub(:put).with("v2", "apps", subject.guid, anything) do
77
77
  response
78
78
  end
79
79
  end
80
80
 
81
81
  context "when asynchronous is true" do
82
82
  it "sends the PUT request with &stage_async=true" do
83
- mock(client.base).put(
83
+ client.base.should_receive(:put).with(
84
84
  "v2", "apps", subject.guid,
85
85
  hash_including(
86
86
  :params => {:stage_async => true},
@@ -111,7 +111,7 @@ module CFoundry
111
111
 
112
112
  context "when asynchronous is false" do
113
113
  it "sends the PUT request with &stage_async=false" do
114
- mock(client.base).put(
114
+ client.base.should_receive(:put).with(
115
115
  "v2", "apps", subject.guid,
116
116
  hash_including(:params => {:stage_async => false})) do
117
117
  response
@@ -144,7 +144,7 @@ module CFoundry
144
144
  let(:response) { {:body => {"foo" => "bar"}.to_json} }
145
145
 
146
146
  before do
147
- stub(client.base).put("v2", "apps", subject.guid, anything) do
147
+ client.base.stub(:put).with("v2", "apps", subject.guid, anything) do
148
148
  response
149
149
  end
150
150
  end
@@ -167,13 +167,13 @@ module CFoundry
167
167
  let(:base_url) { "http://example.com/log" }
168
168
 
169
169
  def mock_log(url = anything)
170
- mock(client).stream_url(url) do |_, blk|
170
+ client.should_receive(:stream_url).with(url) do |_, &blk|
171
171
  blk.call(yield)
172
172
  end.ordered
173
173
  end
174
174
 
175
175
  def stub_log(url = anything)
176
- stub(client).stream_url(url) do |_, blk|
176
+ client.stub(:stream_url).with(url) do |_, blk|
177
177
  blk.call(yield)
178
178
  end.ordered
179
179
  end
@@ -240,14 +240,14 @@ module CFoundry
240
240
 
241
241
  describe "delete!" do
242
242
  it "defaults to recursive" do
243
- mock(client.base).delete("v2", :apps, subject.guid, {:params => {:recursive => true}})
243
+ client.base.should_receive(:delete).with("v2", :apps, subject.guid, {:params => {:recursive => true}})
244
244
 
245
245
  subject.delete!
246
246
  end
247
247
  end
248
248
 
249
249
  it "accepts and ignores an options hash" do
250
- mock(client.base).delete("v2", :apps, subject.guid, {:params => {:recursive => true}})
250
+ client.base.should_receive(:delete).with("v2", :apps, subject.guid, {:params => {:recursive => true}})
251
251
 
252
252
  subject.delete!(:recursive => false)
253
253
  end
@@ -255,8 +255,8 @@ module CFoundry
255
255
  describe "#health" do
256
256
  describe "when staging failed for an app" do
257
257
  it "returns 'STAGING FAILED' as state" do
258
- stub(client.base).instances(subject.guid) { raise CFoundry::StagingError }
259
- stub(subject).state { "STARTED" }
258
+ client.base.stub(:instances).with(subject.guid) { raise CFoundry::StagingError }
259
+ subject.stub(:state) { "STARTED" }
260
260
 
261
261
  expect(subject.health).to eq("STAGING FAILED")
262
262
  end
@@ -135,7 +135,7 @@ describe CFoundry::V2::Base do
135
135
  let(:args) { segments }
136
136
 
137
137
  it "makes a request with the correct url and options" do
138
- mock(rest_client).request(verb, "first-segment/next-segment", {}) { [request, response] }
138
+ rest_client.should_receive(:request).with(verb, "first-segment/next-segment", {}) { [request, response] }
139
139
  subject
140
140
  end
141
141
  end
@@ -144,7 +144,7 @@ describe CFoundry::V2::Base do
144
144
  let(:args) { segments + [options] }
145
145
 
146
146
  it "makes a request with the correct url and options" do
147
- mock(rest_client).request(verb, "first-segment/next-segment", options) { [request, response] }
147
+ rest_client.should_receive(:request).with(verb, "first-segment/next-segment", options) { [request, response] }
148
148
  subject
149
149
  end
150
150
  end
@@ -155,7 +155,7 @@ describe CFoundry::V2::Base do
155
155
  let(:args) { ["first-segment"] }
156
156
 
157
157
  it "makes a request with the correct url and options" do
158
- mock(rest_client).request(verb, "first-segment", {}) { [request, response] }
158
+ rest_client.should_receive(:request).with(verb, "first-segment", {}) { [request, response] }
159
159
  subject
160
160
  end
161
161
  end
@@ -164,7 +164,7 @@ describe CFoundry::V2::Base do
164
164
  let(:args) { ["first-segment", options] }
165
165
 
166
166
  it "makes a request with the correct url and options" do
167
- mock(rest_client).request(verb, "first-segment", options) { [request, response] }
167
+ rest_client.should_receive(:request).with(verb, "first-segment", options) { [request, response] }
168
168
  subject
169
169
  end
170
170
  end
@@ -185,7 +185,7 @@ describe CFoundry::V2::Base do
185
185
  subject { base.get(*args) }
186
186
 
187
187
  it "makes a GET request" do
188
- mock(rest_client).request("GET", "some-path", options) { [request, response] }
188
+ rest_client.should_receive(:request).with("GET", "some-path", options) { [request, response] }
189
189
  subject
190
190
  end
191
191
 
@@ -197,7 +197,7 @@ describe CFoundry::V2::Base do
197
197
  subject { base.post(*args) }
198
198
 
199
199
  it "makes a POST request" do
200
- mock(rest_client).request("POST", "some-path", options) { [request, response] }
200
+ rest_client.should_receive(:request).with("POST", "some-path", options) { [request, response] }
201
201
  subject
202
202
  end
203
203
 
@@ -209,7 +209,7 @@ describe CFoundry::V2::Base do
209
209
  subject { base.put(*args) }
210
210
 
211
211
  it "makes a PUT request" do
212
- mock(rest_client).request("PUT", "some-path", options) { [request, response] }
212
+ rest_client.should_receive(:request).with("PUT", "some-path", options) { [request, response] }
213
213
  subject
214
214
  end
215
215
 
@@ -221,7 +221,7 @@ describe CFoundry::V2::Base do
221
221
  subject { base.delete(*args) }
222
222
 
223
223
  it "makes a DELETE request" do
224
- mock(rest_client).request("DELETE", "some-path", options) { [request, response] }
224
+ rest_client.should_receive(:request).with("DELETE", "some-path", options) { [request, response] }
225
225
  subject
226
226
  end
227
227
 
@@ -278,7 +278,7 @@ describe CFoundry::V2::Base do
278
278
  let(:file_url) { "http://api.cloudfoundry.com/static/path/to/some/file" }
279
279
 
280
280
  before do
281
- stub(base).token { CFoundry::AuthToken.new("bearer foo") }
281
+ base.stub(:token) { CFoundry::AuthToken.new("bearer foo") }
282
282
  end
283
283
 
284
284
  it "follows the redirect returned by the files endpoint" do
@@ -13,12 +13,12 @@ module CFoundry
13
13
  subject { client.register(email, password) }
14
14
 
15
15
  it "creates the user in uaa and ccng" do
16
- stub(client.base).uaa { uaa }
17
- stub(uaa).add_user(email, password) { {"id" => "1234"} }
16
+ client.base.stub(:uaa) { uaa }
17
+ uaa.stub(:add_user).with(email, password) { {"id" => "1234"} }
18
18
 
19
19
  user = build(:user)
20
- stub(client).user { user }
21
- stub(user).create!
20
+ client.stub(:user) { user }
21
+ user.stub(:create!)
22
22
  subject
23
23
  expect(user.guid).to eq "1234"
24
24
  end
@@ -74,4 +74,4 @@ module CFoundry
74
74
  end
75
75
  end
76
76
  end
77
- end
77
+ end
@@ -54,13 +54,13 @@ module CFoundry
54
54
  end
55
55
 
56
56
  it "retrieves the manifest the first time" do
57
- mock(client.base).test_model("test-model-guid-1") {
57
+ client.base.should_receive(:test_model).with("test-model-guid-1") {
58
58
  {:entity => {:foo => "fizz"}}
59
59
  }.ordered
60
60
 
61
61
  expect(model.foo).to eq "fizz"
62
62
 
63
- dont_allow(client.base).model.ordered
63
+ client.base.should_not_receive(:model)
64
64
 
65
65
  expect(model.foo).to eq "fizz"
66
66
  end
@@ -82,7 +82,7 @@ module CFoundry
82
82
  end
83
83
 
84
84
  before do
85
- stub(client.base).test_model("test-model-guid-1") {
85
+ client.base.stub(:test_model).with("test-model-guid-1") {
86
86
  {:entity => {:not_foo => "fizz"}}
87
87
  }
88
88
  end
@@ -100,14 +100,14 @@ module CFoundry
100
100
  end
101
101
 
102
102
  it "uses the 'at' value in the update payload" do
103
- mock(client.base).put("v2", :test_models, model.guid, hash_including(:payload => {:not_foo => 123}))
103
+ client.base.should_receive(:put).with("v2", :test_models, model.guid, hash_including(:payload => {:not_foo => 123}))
104
104
  model.foo = 123
105
105
  model.update!
106
106
  end
107
107
 
108
108
  it "uses the 'at' value in the create payload" do
109
109
  model.foo = 123
110
- mock(client.base).post("v2", :test_models, hash_including(:payload => {:not_foo => 123})) { {:metadata => {}} }
110
+ client.base.should_receive(:post).with("v2", :test_models, hash_including(:payload => {:not_foo => 123})) { {:metadata => {}} }
111
111
  model.create!
112
112
  end
113
113
 
@@ -15,21 +15,21 @@ module CFoundry
15
15
 
16
16
  describe "create" do
17
17
  it "uses #create!" do
18
- mock(model).create!
18
+ model.should_receive(:create!)
19
19
  model.create
20
20
  end
21
21
 
22
22
  context "without errors" do
23
23
  it "returns true" do
24
- mock(model).create!
24
+ model.should_receive(:create!)
25
25
  model.create.should == true
26
26
  end
27
27
  end
28
28
 
29
29
  context "with errors" do
30
30
  before do
31
- stub(model.class).model_name { ActiveModel::Name.new(model, nil, "abstract_model") }
32
- stub(model).create! { raise CFoundry::APIError.new("HELP") }
31
+ model.class.stub(:model_name) { ActiveModel::Name.new(model, nil, "abstract_model") }
32
+ model.stub(:create!) { raise CFoundry::APIError.new("HELP") }
33
33
  end
34
34
 
35
35
  it "does not raise an exception" do
@@ -58,7 +58,7 @@ module CFoundry
58
58
 
59
59
  describe "#create!" do
60
60
  before do
61
- stub(client.base).post {
61
+ client.base.stub(:post) {
62
62
  {:metadata => {
63
63
  :guid => "123",
64
64
  :created_at => "2013-06-10 10:41:15 -0700",
@@ -69,7 +69,7 @@ module CFoundry
69
69
  end
70
70
 
71
71
  it "posts to the model's create url with appropriate arguments" do
72
- mock(client.base).post("v2", :test_models,
72
+ client.base.should_receive(:post).with("v2", :test_models,
73
73
  :content => :json,
74
74
  :accept => :json,
75
75
  :payload => {:foo => "bar"}
@@ -109,7 +109,7 @@ module CFoundry
109
109
 
110
110
  describe "#update!" do
111
111
  before do
112
- stub(client.base).put {
112
+ client.base.stub(:put) {
113
113
  {
114
114
  :metadata => {
115
115
  :guid => guid,
@@ -125,7 +125,7 @@ module CFoundry
125
125
 
126
126
  it "updates using the client with the v2 api, its plural model name, object guid, and diff object" do
127
127
  model.foo = "bar"
128
- mock(client.base).put("v2", :test_models, guid,
128
+ client.base.should_receive(:put).with("v2", :test_models, guid,
129
129
  :content => :json,
130
130
  :accept => :json,
131
131
  :payload => {:foo => "bar"}
@@ -154,26 +154,26 @@ module CFoundry
154
154
 
155
155
  describe "delete" do
156
156
  it "uses #delete!" do
157
- mock(model).delete!({}) { true }
157
+ model.should_receive(:delete!).with({}) { true }
158
158
  model.delete
159
159
  end
160
160
 
161
161
  it "passes options along to delete!" do
162
- mock(model).delete!(:recursive => true) { true }
162
+ model.should_receive(:delete!).with(:recursive => true) { true }
163
163
  model.delete(:recursive => true)
164
164
  end
165
165
 
166
166
  context "without errors" do
167
167
  it "returns true" do
168
- mock(model).delete!({}) { true }
168
+ model.should_receive(:delete!).with({}) { true }
169
169
  model.delete.should == true
170
170
  end
171
171
  end
172
172
 
173
173
  context "with errors" do
174
174
  before do
175
- stub(model.class).model_name { ActiveModel::Name.new(model, nil, "abstract_model") }
176
- stub(model).delete! { raise CFoundry::APIError.new("HELP") }
175
+ model.class.stub(:model_name) { ActiveModel::Name.new(model, nil, "abstract_model") }
176
+ model.stub(:delete!) { raise CFoundry::APIError.new("HELP") }
177
177
  end
178
178
 
179
179
  it "does not raise an exception" do
@@ -201,11 +201,11 @@ module CFoundry
201
201
  end
202
202
 
203
203
  describe "#delete!" do
204
- before { stub(client.base).delete }
204
+ before { client.base.stub(:delete) }
205
205
 
206
206
  context "without options" do
207
207
  it "deletes using the client with the v2 api, its plural model name, object guid, and empty params hash" do
208
- mock(client.base).delete("v2", :test_models, guid, :params => {})
208
+ client.base.should_receive(:delete).with("v2", :test_models, guid, :params => {})
209
209
  model.delete!
210
210
  end
211
211
  end
@@ -213,7 +213,7 @@ module CFoundry
213
213
  context "with options" do
214
214
  it "sends delete with the object guid and options" do
215
215
  options = {:excellent => "billandted"}
216
- mock(client.base).delete("v2", :test_models, guid, :params => options)
216
+ client.base.should_receive(:delete).with("v2", :test_models, guid, :params => options)
217
217
 
218
218
  model.delete!(options)
219
219
  end
@@ -291,7 +291,7 @@ module CFoundry
291
291
 
292
292
  context "on an object that has been deleted" do
293
293
  before do
294
- stub(client.base).delete
294
+ client.base.stub(:delete)
295
295
  model.delete
296
296
  end
297
297
 
@@ -313,7 +313,7 @@ module CFoundry
313
313
 
314
314
  context "when metadata are not defined" do
315
315
  before do
316
- stub(new_object).manifest(nil)
316
+ new_object.stub(:manifest).with(nil)
317
317
  end
318
318
 
319
319
  it "returns nil for timestamps" do
@@ -40,7 +40,7 @@ module CFoundry
40
40
  let(:client) { build(:client) }
41
41
 
42
42
  it "is queryable by name" do
43
- mock(client).quota_definitions({:query=>[:name, "quota-name"]}) {[]}
43
+ client.should_receive(:quota_definitions).with({:query=>[:name, "quota-name"]}) {[]}
44
44
 
45
45
  client.quota_definition_by_name("quota-name")
46
46
  end
@@ -29,7 +29,7 @@ module CFoundry
29
29
 
30
30
  describe "errors" do
31
31
  before do
32
- stub(route).create! { raise CFoundry::RouteHostTaken.new("the host is taken", 210003) }
32
+ route.stub(:create!) { raise CFoundry::RouteHostTaken.new("the host is taken", 210003) }
33
33
  end
34
34
 
35
35
  it "populates errors on host" do
data/spec/spec_helper.rb CHANGED
@@ -17,5 +17,4 @@ require "support/factory_girl"
17
17
  require "support/test_model_builder"
18
18
 
19
19
  RSpec.configure do |c|
20
- c.mock_with :rr
21
20
  end
@@ -8,8 +8,8 @@ shared_examples_for 'client login prompts' do
8
8
  end
9
9
 
10
10
  before do
11
- stub(client.base).uaa { uaa }
12
- stub(uaa).prompts { prompts }
11
+ client.base.stub(:uaa) { uaa }
12
+ uaa.stub(:prompts) { prompts }
13
13
  end
14
14
 
15
15
  subject { client.login_prompts }
@@ -27,8 +27,8 @@ shared_examples_for 'client login' do
27
27
  let(:token_info) { CF::UAA::TokenInfo.new({ :access_token => access_token, :token_type => "bearer" }) }
28
28
 
29
29
  before do
30
- stub(client.base).uaa { uaa }
31
- stub(uaa).authorize(email, password) { token_info }
30
+ client.base.stub(:uaa) { uaa }
31
+ uaa.stub(:authorize).with(email, password) { token_info }
32
32
  end
33
33
 
34
34
  subject { client.login(email, password) }
@@ -43,4 +43,4 @@ shared_examples_for 'client login' do
43
43
  expect(client.token).to be_a(CFoundry::AuthToken)
44
44
  expect(client.token.auth_header).to eq("bearer #{access_token}")
45
45
  end
46
- end
46
+ end
@@ -22,7 +22,7 @@ shared_examples_for "a summarizeable model" do
22
22
 
23
23
  describe "#summarize!" do
24
24
  it "defines basic attributes via #summary" do
25
- stub(subject).summary { summary_attributes }
25
+ subject.stub(:summary) { summary_attributes }
26
26
 
27
27
  subject.summarize!
28
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.rc1
4
+ version: 2.2.0.rc2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -179,7 +179,7 @@ dependencies:
179
179
  requirements:
180
180
  - - ~>
181
181
  - !ruby/object:Gem::Version
182
- version: '2.11'
182
+ version: '2.13'
183
183
  type: :development
184
184
  prerelease: false
185
185
  version_requirements: !ruby/object:Gem::Requirement
@@ -187,23 +187,7 @@ dependencies:
187
187
  requirements:
188
188
  - - ~>
189
189
  - !ruby/object:Gem::Version
190
- version: '2.11'
191
- - !ruby/object:Gem::Dependency
192
- name: rr
193
- requirement: !ruby/object:Gem::Requirement
194
- none: false
195
- requirements:
196
- - - ~>
197
- - !ruby/object:Gem::Version
198
- version: '1.0'
199
- type: :development
200
- prerelease: false
201
- version_requirements: !ruby/object:Gem::Requirement
202
- none: false
203
- requirements:
204
- - - ~>
205
- - !ruby/object:Gem::Version
206
- version: '1.0'
190
+ version: '2.13'
207
191
  - !ruby/object:Gem::Dependency
208
192
  name: shoulda-matchers
209
193
  requirement: !ruby/object:Gem::Requirement
@@ -427,9 +411,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
427
411
  - - ! '>='
428
412
  - !ruby/object:Gem::Version
429
413
  version: '0'
430
- segments:
431
- - 0
432
- hash: 3546131754445164394
433
414
  required_rubygems_version: !ruby/object:Gem::Requirement
434
415
  none: false
435
416
  requirements: