cfoundry 2.2.0.rc2 → 2.2.0rc3

Sign up to get free protection for your applications and to get access to all the features.
@@ -115,6 +115,16 @@ module CFoundry::V2
115
115
  end
116
116
  alias :url :uri
117
117
 
118
+ def host
119
+ return nil if routes.empty?
120
+ routes.first.host
121
+ end
122
+
123
+ def domain
124
+ return nil if routes.empty?
125
+ routes.first.domain.name
126
+ end
127
+
118
128
  def uri=(x)
119
129
  self.uris = [x]
120
130
  end
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "2.2.0.rc2".freeze
3
+ VERSION = "2.2.0rc3".freeze
4
4
  end
@@ -262,6 +262,59 @@ module CFoundry
262
262
  end
263
263
  end
264
264
  end
265
+
266
+ describe "#host" do
267
+ let(:route) { build(:route, :host => "my-host") }
268
+ let(:app) { build(:app) }
269
+
270
+ context "when at least one route exists" do
271
+ it "returns the host that the user has specified" do
272
+ app.stub(:routes).and_return([route])
273
+ expect(app.host).to eq("my-host")
274
+ end
275
+ end
276
+
277
+ context "when no routes exists" do
278
+ it "returns the host that the user has specified" do
279
+ app.stub(:routes).and_return([])
280
+ expect(app.host).to be_nil
281
+ end
282
+ end
283
+ end
284
+
285
+ describe "#domain" do
286
+ let(:domain) { build(:domain, :name => "my-domain") }
287
+ let(:route) { build(:route, :domain => domain) }
288
+ let(:app) { build(:app) }
289
+
290
+ context "when at least one route exists" do
291
+ it "returns the domain that the user has specified" do
292
+ app.stub(:routes).and_return([route])
293
+ expect(app.domain).to eq("my-domain")
294
+ end
295
+ end
296
+
297
+ context "when no routes exists" do
298
+ it "returns the domain that the user has specified" do
299
+ app.stub(:routes).and_return([])
300
+ expect(app.domain).to be_nil
301
+ end
302
+ end
303
+ end
304
+
305
+ describe "#uri" do
306
+ context "when there are one or more routes" do
307
+ let(:domain) { build(:domain, :name => "example.com") }
308
+ let(:route) { build(:route, :host => "my-host", :domain => domain) }
309
+ let(:other_route) { build(:route, :host => "other-host", :domain => domain) }
310
+ let(:app) { build(:app) }
311
+
312
+ it "return the first one" do
313
+ app.stub(:routes).and_return([route, other_route])
314
+ expect(app.uri).to eq("#{route.host}.#{route.domain.name}")
315
+ end
316
+ end
317
+ end
265
318
  end
266
319
  end
267
320
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.rc2
5
- prerelease: 6
4
+ version: 2.2.0rc3
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cloud Foundry Team
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-21 00:00:00.000000000 Z
13
+ date: 2013-06-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel