cfoundry 1.5.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cfoundry/test_support.rb +2 -2
- data/lib/cfoundry/v2/app.rb +3 -6
- data/lib/cfoundry/v2/model.rb +1 -0
- data/lib/cfoundry/version.rb +1 -1
- data/spec/cfoundry/client_spec.rb +1 -1
- data/spec/cfoundry/rest_client_spec.rb +1 -1
- data/spec/cfoundry/trace_helpers_spec.rb +6 -6
- data/spec/cfoundry/upload_helpers_spec.rb +125 -137
- data/spec/cfoundry/v2/app_event_spec.rb +63 -59
- data/spec/cfoundry/v2/app_spec.rb +195 -188
- data/spec/cfoundry/v2/client_spec.rb +60 -56
- data/spec/cfoundry/v2/domain_spec.rb +9 -6
- data/spec/cfoundry/v2/model_magic/model_magic/attribute_spec.rb +89 -88
- data/spec/cfoundry/v2/model_magic/model_magic/has_summary_spec.rb +12 -13
- data/spec/cfoundry/v2/model_magic/model_magic/to_many_spec.rb +46 -52
- data/spec/cfoundry/v2/model_magic/model_magic/to_one_spec.rb +96 -87
- data/spec/cfoundry/v2/model_spec.rb +236 -241
- data/spec/cfoundry/v2/organization_spec.rb +20 -22
- data/spec/cfoundry/v2/quota_definition_spec.rb +45 -47
- data/spec/cfoundry/v2/route_spec.rb +28 -25
- data/spec/cfoundry/v2/space_spec.rb +9 -11
- data/spec/cfoundry/validator_spec.rb +69 -67
- data/spec/factories/app_events_factory.rb +7 -0
- data/spec/factories/apps_factory.rb +11 -0
- data/spec/factories/clients_factory.rb +5 -0
- data/spec/factories/domains_factory.rb +7 -0
- data/spec/factories/organizations_factory.rb +11 -0
- data/spec/factories/quota_definitions_factory.rb +8 -0
- data/spec/factories/routes_factory.rb +10 -0
- data/spec/factories/spaces_factory.rb +10 -0
- data/spec/factories/users_factory.rb +10 -0
- data/spec/spec_helper.rb +5 -4
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/shared_examples/model_summary_examples.rb +7 -7
- data/spec/support/test_model_builder.rb +10 -0
- metadata +83 -71
- data/spec/fakes/app_fake.rb +0 -5
- data/spec/fakes/domain_fake.rb +0 -5
- data/spec/fakes/framework_fake.rb +0 -5
- data/spec/fakes/organization_fake.rb +0 -5
- data/spec/fakes/route_fake.rb +0 -5
- data/spec/fakes/runtime_fake.rb +0 -5
- data/spec/fakes/service_fake.rb +0 -5
- data/spec/fakes/service_instance_fake.rb +0 -5
- data/spec/fakes/service_plan_fake.rb +0 -5
- data/spec/fakes/space_fake.rb +0 -5
- data/spec/fakes/user_fake.rb +0 -5
- data/spec/support/fake_helper.rb +0 -248
- data/spec/support/randoms.rb +0 -3
@@ -1,30 +1,28 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module CFoundry
|
4
|
+
module V2
|
5
|
+
describe Organization do
|
6
|
+
let(:client) { build(:client) }
|
7
|
+
let(:organization) { build(:organization, :client => client) }
|
5
8
|
|
6
|
-
|
9
|
+
it_behaves_like "a summarizeable model" do
|
10
|
+
subject { organization }
|
11
|
+
let(:summary_attributes) { {:name => "fizzbuzz"} }
|
12
|
+
end
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
it "has quota_definition" do
|
15
|
+
quota = build(:quota_definition)
|
16
|
+
organization.quota_definition = quota
|
17
|
+
expect(organization.quota_definition).to eq(quota)
|
18
|
+
end
|
12
19
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
quota = fake(:quota_definition)
|
20
|
-
subject.quota_definition = quota
|
21
|
-
expect(subject.quota_definition).to eq(quota)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "has billing_enabled" do
|
25
|
-
[true, false].each do |v|
|
26
|
-
subject.billing_enabled = v
|
27
|
-
expect(subject.billing_enabled).to eq(v)
|
20
|
+
it "has billing_enabled" do
|
21
|
+
[true, false].each do |v|
|
22
|
+
organization.billing_enabled = v
|
23
|
+
expect(organization.billing_enabled).to eq(v)
|
24
|
+
end
|
25
|
+
end
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -1,52 +1,50 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
quota = quota_definitions.last
|
49
|
-
expect(client.quota_definition_by_name("bar")).to eq(bar)
|
3
|
+
module CFoundry
|
4
|
+
module V2
|
5
|
+
describe QuotaDefinition do
|
6
|
+
let(:quota_definition) { build(:quota_definition) }
|
7
|
+
|
8
|
+
it "has guid" do
|
9
|
+
quota_definition.guid = "quota-definition-1"
|
10
|
+
expect(quota_definition.guid).to eq("quota-definition-1")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has name" do
|
14
|
+
quota_definition.name = "name"
|
15
|
+
expect(quota_definition.name).to eq("name")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has non_basic_services_allowed" do
|
19
|
+
[true, false].each do |v|
|
20
|
+
quota_definition.non_basic_services_allowed = v
|
21
|
+
expect(quota_definition.non_basic_services_allowed).to eq(v)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has total_services" do
|
26
|
+
[0, 1].each do |v|
|
27
|
+
quota_definition.total_services = v
|
28
|
+
expect(quota_definition.total_services).to eq(v)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has total_services" do
|
33
|
+
[0, 1].each do |v|
|
34
|
+
quota_definition.total_services = v
|
35
|
+
expect(quota_definition.total_services).to eq(v)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "querying" do
|
40
|
+
let(:client) { build(:client) }
|
41
|
+
|
42
|
+
it "is queryable by name" do
|
43
|
+
mock(client).quota_definitions({:query=>[:name, "quota-name"]}) {[]}
|
44
|
+
|
45
|
+
client.quota_definition_by_name("quota-name")
|
46
|
+
end
|
47
|
+
end
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
@@ -1,38 +1,41 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
|
-
module CFoundry
|
5
|
-
|
6
|
-
|
4
|
+
module CFoundry
|
5
|
+
module V2
|
6
|
+
describe Route do
|
7
|
+
let(:route) { build(:route) }
|
8
|
+
subject { route }
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
describe "validations" do
|
11
|
+
it { should validate_presence_of(:domain) }
|
12
|
+
it { should validate_presence_of(:space) }
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
# http://tools.ietf.org/html/rfc1035
|
15
|
+
it "only allows host names according to RFC1035" do
|
16
|
+
message = "can only include a-z, 0-9 and -"
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
route.should allow_value("a", "starts-with-letter", "includes-9-digits", "ends-with-letter",
|
19
|
+
"ends-with-digit-9", "can--have--consecutive---dashes", "allows-UPPERCASE-chars").for(:host)
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
["-must-start-with-letter", "9must-start-with-letter", "must-not-end-with-dash-", "must-not-include-punctuation-chars-@\#$%^&*()",
|
22
|
+
"must-not-include-special-chars-ä", "must.not.include.dots"].each do |bad_value|
|
23
|
+
route.should_not allow_value(bad_value).for(:host).with_message(message)
|
24
|
+
end
|
23
25
|
|
24
|
-
|
26
|
+
route.should ensure_length_of(:host).is_at_most(63)
|
27
|
+
end
|
25
28
|
end
|
26
|
-
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
describe "errors" do
|
31
|
+
before do
|
32
|
+
stub(route).create! { raise CFoundry::RouteHostTaken.new("the host is taken", 210003) }
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
it "populates errors on host" do
|
36
|
+
route.create
|
37
|
+
route.errors[:host].first.should =~ /the host is taken/i
|
38
|
+
end
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
it_behaves_like 'a summarizeable model'
|
3
|
+
module CFoundry
|
4
|
+
module V2
|
5
|
+
describe Space do
|
6
|
+
it_behaves_like "a summarizeable model" do
|
7
|
+
let(:summary_attributes) { {:name => "fizzbuzz"} }
|
8
|
+
let(:client) { build(:client) }
|
9
|
+
subject { build(:space, :client => client) }
|
10
|
+
end
|
11
|
+
end
|
14
12
|
end
|
15
13
|
end
|
@@ -1,92 +1,94 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module CFoundry
|
4
|
+
describe Validator do
|
5
|
+
let(:validator) { described_class }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
describe "value_matches?" do
|
8
|
+
it "returns true on nil values" do
|
9
|
+
validator.value_matches?(nil, :something).should be_true
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
context "with a type of Class" do
|
13
|
+
it "returns true when value is of type class" do
|
14
|
+
validator.value_matches?(1, Integer).should be_true
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
context "with a Regex" do
|
19
|
+
it "returns true when the regex matches" do
|
20
|
+
validator.value_matches?("value", /lue/).should == true
|
21
|
+
end
|
20
22
|
end
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
context "with type of url" do
|
25
|
+
it "requires http or https urls" do
|
26
|
+
validator.value_matches?("http:whatever", :url).should be_true
|
27
|
+
validator.value_matches?("https:whatever", :url).should be_true
|
28
|
+
validator.value_matches?("htt_no:whatever", :url).should be_false
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
context "with type of https_url" do
|
33
|
+
it "requires http or https urls" do
|
34
|
+
validator.value_matches?("https:whatever", :https_url).should be_true
|
35
|
+
validator.value_matches?("http:whatever", :https_url).should be_false
|
36
|
+
end
|
35
37
|
end
|
36
|
-
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
context "with type boolean" do
|
40
|
+
it "returns true on presence of true or false" do
|
41
|
+
validator.value_matches?(true, :boolean).should be_true
|
42
|
+
validator.value_matches?(false, :boolean).should be_true
|
43
|
+
validator.value_matches?("no boolean", :boolean).should be_false
|
44
|
+
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
context "with an Array" do
|
48
|
+
it "returns true when all elements are of same type" do
|
49
|
+
validator.value_matches?(["https:whatever"], [String]).should be_true
|
50
|
+
validator.value_matches?(["https:whatever"], [Integer]).should be_false
|
51
|
+
end
|
50
52
|
end
|
51
|
-
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
context "with a hash" do
|
55
|
+
it "returns true when specified types match" do
|
56
|
+
validator.value_matches?({:name => "thing"}, {:name => String}).should be_true
|
57
|
+
validator.value_matches?({:name => "thing", :unspecified => 1}, {:name => String}).should be_true
|
58
|
+
validator.value_matches?({:name => 1}, {:name => String}).should be_false
|
59
|
+
end
|
58
60
|
end
|
59
|
-
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
it "returns true when type is nil" do
|
63
|
+
validator.value_matches?("some value", nil).should be_true
|
64
|
+
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
context "with a symbol" do
|
67
|
+
it "returns true when the value is of specified type" do
|
68
|
+
validator.value_matches?("some value", :string).should be_true
|
69
|
+
validator.value_matches?("some value", :integer).should be_false
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
|
-
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
describe "validate_type" do
|
75
|
+
it "passes validation with a nil value" do
|
76
|
+
expect {
|
77
|
+
validator.validate_type(nil, :whatever)
|
78
|
+
}.to_not raise_error
|
79
|
+
end
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
it "passes validation when the value matches" do
|
82
|
+
expect {
|
83
|
+
validator.validate_type("string", :string)
|
84
|
+
}.to_not raise_error
|
85
|
+
end
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
it "raises a validation error when value does not match" do
|
88
|
+
expect {
|
89
|
+
validator.validate_type("string", :integer)
|
90
|
+
}.to raise_error(CFoundry::Mismatch)
|
91
|
+
end
|
90
92
|
end
|
91
93
|
end
|
92
|
-
end
|
94
|
+
end
|