cfoundry 0.5.1.rc2 → 0.5.1.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cc_api_stub.rb +17 -0
- data/lib/cc_api_stub/applications.rb +53 -0
- data/lib/cc_api_stub/domains.rb +16 -0
- data/lib/cc_api_stub/frameworks.rb +22 -0
- data/lib/cc_api_stub/helper.rb +131 -0
- data/lib/cc_api_stub/login.rb +21 -0
- data/lib/cc_api_stub/organization_users.rb +21 -0
- data/lib/cc_api_stub/organizations.rb +70 -0
- data/lib/cc_api_stub/routes.rb +26 -0
- data/lib/cc_api_stub/runtimes.rb +22 -0
- data/lib/cc_api_stub/service_bindings.rb +22 -0
- data/lib/cc_api_stub/service_instances.rb +22 -0
- data/lib/cc_api_stub/services.rb +25 -0
- data/lib/cc_api_stub/spaces.rb +49 -0
- data/lib/cc_api_stub/users.rb +84 -0
- data/lib/cfoundry/baseclient.rb +24 -0
- data/lib/cfoundry/errors.rb +16 -133
- data/lib/cfoundry/v1/app.rb +6 -2
- data/lib/cfoundry/v2/app.rb +16 -4
- data/lib/cfoundry/v2/base.rb +10 -11
- data/lib/cfoundry/v2/client.rb +4 -0
- data/lib/cfoundry/version.rb +1 -1
- data/spec/cc_api_stub/applications_spec.rb +69 -0
- data/spec/cc_api_stub/domains_spec.rb +19 -0
- data/spec/cc_api_stub/frameworks_spec.rb +19 -0
- data/spec/cc_api_stub/login_spec.rb +20 -0
- data/spec/cc_api_stub/organization_users_spec.rb +19 -0
- data/spec/cc_api_stub/organizations_spec.rb +103 -0
- data/spec/cc_api_stub/routes_spec.rb +19 -0
- data/spec/cc_api_stub/runtimes_spec.rb +19 -0
- data/spec/cc_api_stub/service_bindings_spec.rb +13 -0
- data/spec/cc_api_stub/service_instances_spec.rb +19 -0
- data/spec/cc_api_stub/services_spec.rb +12 -0
- data/spec/cc_api_stub/spaces_spec.rb +38 -0
- data/spec/cc_api_stub/users_spec.rb +107 -0
- data/spec/cfoundry/baseclient_spec.rb +42 -2
- data/spec/cfoundry/v2/app_spec.rb +95 -0
- data/spec/fixtures/fake_cc_application.json +24 -0
- data/spec/fixtures/fake_cc_application_summary.json +57 -0
- data/spec/fixtures/fake_cc_created_application.json +11 -0
- data/spec/fixtures/fake_cc_created_domain.json +10 -0
- data/spec/fixtures/fake_cc_created_organization.json +11 -0
- data/spec/fixtures/fake_cc_created_route.json +13 -0
- data/spec/fixtures/fake_cc_created_service_instance.json +11 -0
- data/spec/fixtures/fake_cc_created_space.json +11 -0
- data/spec/fixtures/fake_cc_created_user.json +11 -0
- data/spec/fixtures/fake_cc_empty_search.json +7 -0
- data/spec/fixtures/fake_cc_frameworks.json +20 -0
- data/spec/fixtures/fake_cc_organization.json +144 -0
- data/spec/fixtures/fake_cc_organization_domains.json +34 -0
- data/spec/fixtures/fake_cc_organization_search.json +37 -0
- data/spec/fixtures/fake_cc_organization_summary.json +19 -0
- data/spec/fixtures/fake_cc_organization_users.json +81 -0
- data/spec/fixtures/fake_cc_runtimes.json +20 -0
- data/spec/fixtures/fake_cc_service_binding.json +22 -0
- data/spec/fixtures/fake_cc_service_bindings.json +24 -0
- data/spec/fixtures/fake_cc_service_instance.json +81 -0
- data/spec/fixtures/fake_cc_service_instances.json +0 -0
- data/spec/fixtures/fake_cc_service_types.json +124 -0
- data/spec/fixtures/fake_cc_space.json +45 -0
- data/spec/fixtures/fake_cc_space_summary.json +86 -0
- data/spec/fixtures/fake_cc_stats.json +29 -0
- data/spec/fixtures/fake_cc_user.json +112 -0
- data/spec/fixtures/fake_cc_user_organizations.json +92 -0
- data/spec/fixtures/fake_cc_user_with_managers.json +85 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/fake_helper.rb +0 -36
- data/spec/support/shared_examples/cc_api_stub_request_examples.rb +79 -0
- metadata +254 -144
data/lib/cfoundry/v2/client.rb
CHANGED
data/lib/cfoundry/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Applications do
|
6
|
+
describe ".succeed_to_load" do
|
7
|
+
let(:url) { "http://example.com/v2/apps/234" }
|
8
|
+
subject { CcApiStub::Applications.succeed_to_load }
|
9
|
+
|
10
|
+
it_behaves_like "a stubbed get request"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".succeed_to_create" do
|
14
|
+
let(:url) { "http://example.com/v2/apps" }
|
15
|
+
subject { CcApiStub::Applications.succeed_to_create }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed post request"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".succeed_to_update" do
|
21
|
+
let(:url) { "http://example.com/v2/apps/234" }
|
22
|
+
subject { CcApiStub::Applications.succeed_to_update }
|
23
|
+
|
24
|
+
it_behaves_like "a stubbed put request"
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".succeed_to_map_route" do
|
28
|
+
let(:url) { "http://example.com/v2/apps/234/routes/123" }
|
29
|
+
subject { CcApiStub::Applications.succeed_to_map_route }
|
30
|
+
|
31
|
+
it_behaves_like "a stubbed put request", :code => 201
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".succeed_to_load_stats" do
|
35
|
+
let(:url) { "http://example.com/v2/apps/234/stats" }
|
36
|
+
subject { CcApiStub::Applications.succeed_to_load_stats }
|
37
|
+
|
38
|
+
it_behaves_like "a stubbed get request"
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".summary_fixture" do
|
42
|
+
it "loads a fixture file" do
|
43
|
+
CcApiStub::Applications.summary_fixture.should be_a(Hash)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "succeed_to_load_summary" do
|
48
|
+
let(:url) { "http://example.com/v2/apps/234/summary" }
|
49
|
+
|
50
|
+
context "with default args" do
|
51
|
+
subject { CcApiStub::Applications.succeed_to_load_summary }
|
52
|
+
|
53
|
+
it_behaves_like "a stubbed get request", :including_json => { "state" => "STARTED" }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with user set args" do
|
57
|
+
subject { CcApiStub::Applications.succeed_to_load_summary(:state => "FLAPPING") }
|
58
|
+
|
59
|
+
it_behaves_like "a stubbed get request", :including_json => { "state" => "FLAPPING" }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".succeed_to_load_service_bindings" do
|
64
|
+
let(:url) { "http://example.com/v2/apps/234/service_bindings" }
|
65
|
+
subject { CcApiStub::Applications.succeed_to_load_service_bindings }
|
66
|
+
|
67
|
+
it_behaves_like "a stubbed get request"
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Domains do
|
6
|
+
describe ".succeed_to_create" do
|
7
|
+
let(:url) { "http://example.com/v2/domains/" }
|
8
|
+
subject { CcApiStub::Domains.succeed_to_create }
|
9
|
+
|
10
|
+
it_behaves_like "a stubbed post request"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".succeed_to_delete" do
|
14
|
+
let(:url) { "http://example.com/v2/domains/1234" }
|
15
|
+
subject { CcApiStub::Domains.succeed_to_delete }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed delete request"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Frameworks do
|
6
|
+
let(:url) { "http://example.com/v2/frameworks?inline-relations-depth=1" }
|
7
|
+
|
8
|
+
describe ".succeed_to_load" do
|
9
|
+
subject { CcApiStub::Frameworks.succeed_to_load }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".fail_to_load" do
|
15
|
+
subject { CcApiStub::Frameworks.fail_to_load }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed get request", :code => 500, :ignore_response => true
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Login do
|
6
|
+
describe '.succeeds_to_find_uaa' do
|
7
|
+
let(:host) { 'http://example.com:8181' }
|
8
|
+
let(:url) { host + "/info" }
|
9
|
+
subject { CcApiStub::Login.succeeds_to_find_uaa(host) }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request", :including_json => {'authorization_endpoint' => 'https://uaa.localhost'}
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.succeeds_to_login_as_admin' do
|
15
|
+
let(:url) { "http://uaa.localhost/oauth/authorize" }
|
16
|
+
subject { CcApiStub::Login::succeeds_to_login_as_admin }
|
17
|
+
|
18
|
+
it_behaves_like "a stubbed post request", :code => 302, :ignore_response => true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::OrganizationUsers do
|
6
|
+
let(:url) { "http://example.com/v2/organizations/123/users/94087" }
|
7
|
+
|
8
|
+
describe ".succeed_to_delete" do
|
9
|
+
subject { CcApiStub::OrganizationUsers.succeed_to_delete }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed delete request"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".fail_to_delete" do
|
15
|
+
subject { CcApiStub::OrganizationUsers.fail_to_delete }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed delete request", :code => 500, :ignore_response => true
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CcApiStub::Organizations do
|
4
|
+
let(:client) { CFoundry::V2::Client.new }
|
5
|
+
|
6
|
+
describe '.succeed_to_create' do
|
7
|
+
it 'stubs creation of an organization' do
|
8
|
+
CcApiStub::Organizations.succeed_to_create
|
9
|
+
|
10
|
+
org = client.organization
|
11
|
+
org.create!.should be_true
|
12
|
+
org.guid.should == 'created-organization-id-1'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.summary_fixture' do
|
17
|
+
it 'returns the fake org' do
|
18
|
+
CcApiStub::Organizations.summary_fixture.should be_a(Hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.fail_to_find' do
|
23
|
+
it 'fails to find the org' do
|
24
|
+
guid = 'organization-id-1'
|
25
|
+
CcApiStub::Organizations.fail_to_find(guid)
|
26
|
+
client.organization(guid).exists?.should be_false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.succeed_to_load_summary' do
|
31
|
+
it 'stubs loading the organization summary' do
|
32
|
+
CcApiStub::Organizations.succeed_to_load_summary
|
33
|
+
|
34
|
+
org = client.organization('organization-id-1')
|
35
|
+
org.summarize!
|
36
|
+
org.spaces[0].should be_a(CFoundry::V2::Space)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.succeed_to_search' do
|
41
|
+
it 'stubs searching' do
|
42
|
+
org_name = 'yoda'
|
43
|
+
CcApiStub::Organizations.succeed_to_search(org_name)
|
44
|
+
|
45
|
+
org = client.organization_by_name(org_name)
|
46
|
+
org.guid.should == 'organization-id-1'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.succeed_to_search_none' do
|
51
|
+
it 'stubs searching' do
|
52
|
+
org_name = 'yoda'
|
53
|
+
CcApiStub::Organizations.succeed_to_search_none
|
54
|
+
|
55
|
+
org = client.organization_by_name(org_name)
|
56
|
+
org.should be_nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '.domains_fixture' do
|
61
|
+
it 'returns the fake domain' do
|
62
|
+
CcApiStub::Organizations.domains_fixture.should be_a(Hash)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '.domains_fixture_hash' do
|
67
|
+
it 'returns the fake domain' do
|
68
|
+
fixture = CcApiStub::Organizations.domain_fixture_hash
|
69
|
+
fixture.should be_a(Hash)
|
70
|
+
fixture.should == fixture.symbolize_keys
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '.succeed_to_load_domains' do
|
75
|
+
it 'stubs domain loading' do
|
76
|
+
CcApiStub::Organizations.succeed_to_load_domains
|
77
|
+
org = client.organization('organization-id-1')
|
78
|
+
org.domains[0].should be_a(CFoundry::V2::Domain)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '.users_fixture' do
|
83
|
+
it "returns the fake users" do
|
84
|
+
CcApiStub::Organizations.users_fixture.should be_a(Hash)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '.user_fixture_hash' do
|
89
|
+
it 'returns the fake user' do
|
90
|
+
fixture = CcApiStub::Organizations.user_fixture_hash
|
91
|
+
fixture.should be_a(Hash)
|
92
|
+
fixture.should == fixture.symbolize_keys
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '.succeed_to_load_users' do
|
97
|
+
it 'stubs users loading' do
|
98
|
+
CcApiStub::Organizations.succeed_to_load_users
|
99
|
+
org = client.organization('organization-id-1')
|
100
|
+
org.users[0].should be_a(CFoundry::V2::User)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Routes do
|
6
|
+
let(:url) { "http://example.com/v2/routes/" }
|
7
|
+
|
8
|
+
describe ".succeed_to_load_none" do
|
9
|
+
subject { CcApiStub::Routes.succeed_to_load_none }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request", :including_json => { "resources" => [] }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".succeed_to_create" do
|
15
|
+
subject { CcApiStub::Routes.succeed_to_create }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed post request"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Runtimes do
|
6
|
+
let(:url) { "http://example.com/v2/runtimes?inline-relations-depth=1" }
|
7
|
+
|
8
|
+
describe ".succeed_to_load" do
|
9
|
+
subject { CcApiStub::Runtimes.succeed_to_load }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".fail_to_load" do
|
15
|
+
subject { CcApiStub::Runtimes.fail_to_load }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed get request", :code => 500, :ignore_response => true
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::ServiceBindings do
|
6
|
+
let(:url) { "http://example.com/v2/service_bindings" }
|
7
|
+
|
8
|
+
describe ".succeed_to_create" do
|
9
|
+
subject { CcApiStub::ServiceBindings.succeed_to_create }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed post request"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::ServiceInstances do
|
6
|
+
describe ".succeed_to_create" do
|
7
|
+
let(:url) { "http://example.com/v2/service_instances" }
|
8
|
+
subject { CcApiStub::ServiceInstances.succeed_to_create }
|
9
|
+
|
10
|
+
it_behaves_like "a stubbed post request"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".succeed_to_load" do
|
14
|
+
let(:url) { "http://example.com/v2/service_instances/123" }
|
15
|
+
subject { CcApiStub::ServiceInstances.succeed_to_load }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed get request"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Services do
|
6
|
+
describe ".succeed_to_load" do
|
7
|
+
let(:url) { "http://example.com/v2/services?inline-relations-depth=1" }
|
8
|
+
subject { CcApiStub::Services.succeed_to_load }
|
9
|
+
|
10
|
+
it_behaves_like "a stubbed get request"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Spaces do
|
6
|
+
describe ".succeed_to_load" do
|
7
|
+
let(:url) { "http://example.com/v2/spaces/234" }
|
8
|
+
subject { CcApiStub::Spaces.succeed_to_load }
|
9
|
+
|
10
|
+
it_behaves_like "a stubbed get request"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".succeed_to_create" do
|
14
|
+
let(:url) { "http://example.com/v2/spaces" }
|
15
|
+
subject { CcApiStub::Spaces.succeed_to_create }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed post request"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".summary_fixture" do
|
21
|
+
it "returns a space fixture" do
|
22
|
+
CcApiStub::Spaces.summary_fixture.should be_a(Hash)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".succeed_to_load_summary" do
|
27
|
+
let(:url) { "http://example.com/v2/spaces/234/summary" }
|
28
|
+
subject { CcApiStub::Spaces.succeed_to_load_summary }
|
29
|
+
|
30
|
+
it_behaves_like "a stubbed get request"
|
31
|
+
|
32
|
+
context "when specifying no_services" do
|
33
|
+
subject { CcApiStub::Spaces.succeed_to_load_summary(:no_services => true) }
|
34
|
+
|
35
|
+
it_behaves_like "a stubbed get request", :including_json => {"services" => []}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Users do
|
6
|
+
describe ".succeed_to_load" do
|
7
|
+
let(:url) { "http://example.com/v2/users/2345?inline-relations-depth=2" }
|
8
|
+
let(:options) { {} }
|
9
|
+
subject { CcApiStub::Users.succeed_to_load(options) }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request"
|
12
|
+
|
13
|
+
context "when setting a user id" do
|
14
|
+
let(:options) { { :id => "some-id" } }
|
15
|
+
|
16
|
+
it_behaves_like "a stubbed get request", :including_json => { "metadata" => { "guid" => "some-id" } }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when setting an organization_id" do
|
20
|
+
let(:options) { { :organization_id => "some-id" } }
|
21
|
+
|
22
|
+
it_behaves_like "a stubbed get request", :including_json => Proc.new { |json|
|
23
|
+
json["entity"]["organizations"][0]["metadata"]["guid"].should == "some-id"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when specifying no_spaces" do
|
28
|
+
let(:options) { { :no_spaces => true } }
|
29
|
+
|
30
|
+
it_behaves_like "a stubbed get request", :including_json => Proc.new { |json|
|
31
|
+
json["entity"]["organizations"][0]["entity"]["spaces"].should == []
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when specifying custom permissions" do
|
36
|
+
let(:options) { { :permissions => [:space_manager, :space2_auditor] } }
|
37
|
+
|
38
|
+
it_behaves_like "a stubbed get request", :including_json => {
|
39
|
+
"entity" =>
|
40
|
+
{
|
41
|
+
"managed_spaces" => [{"metadata" => { "guid" => "space-id-1" }, "entity" => {}}],
|
42
|
+
"audited_spaces" => [{"metadata" => { "guid" => "space-id-2" }, "entity" => {}}]
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".fail_to_find" do
|
49
|
+
let(:url) { "http://example.com/v2/users/2345" }
|
50
|
+
subject { CcApiStub::Users.fail_to_find }
|
51
|
+
|
52
|
+
it_behaves_like "a stubbed get request", :code => 404
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".succeed_to_create" do
|
56
|
+
let(:url) { "http://example.com/v2/users" }
|
57
|
+
subject { CcApiStub::Users.succeed_to_create }
|
58
|
+
|
59
|
+
it_behaves_like "a stubbed post request"
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".fail_to_create" do
|
63
|
+
let(:url) { "http://example.com/v2/users" }
|
64
|
+
subject { CcApiStub::Users.fail_to_create }
|
65
|
+
|
66
|
+
it_behaves_like "a stubbed post request", :code => 500
|
67
|
+
end
|
68
|
+
|
69
|
+
describe ".succeed_to_replace_permissions" do
|
70
|
+
let(:url) { "http://example.com/v2/users/123" }
|
71
|
+
subject { CcApiStub::Users.succeed_to_replace_permissions }
|
72
|
+
|
73
|
+
it_behaves_like "a stubbed put request", :ignore_response => true
|
74
|
+
end
|
75
|
+
|
76
|
+
describe ".fail_to_replace_permissions" do
|
77
|
+
let(:url) { "http://example.com/v2/users/123" }
|
78
|
+
subject { CcApiStub::Users.fail_to_replace_permissions }
|
79
|
+
|
80
|
+
it_behaves_like "a stubbed put request", :ignore_response => true, :code => 500
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".organizations_fixture" do
|
84
|
+
subject { CcApiStub::Users.organizations_fixture }
|
85
|
+
|
86
|
+
it "returns a fixture" do
|
87
|
+
subject.should be_a Array
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe ".organizations_fixture_hash" do
|
92
|
+
subject { CcApiStub::Users.organization_fixture_hash }
|
93
|
+
|
94
|
+
it "returns a fixture" do
|
95
|
+
subject.should be_a Hash
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when specifying options" do
|
99
|
+
subject { CcApiStub::Users.organization_fixture_hash(:no_spaces => true, :no_managers => true) }
|
100
|
+
|
101
|
+
it "takes options into account" do
|
102
|
+
subject[:entity][:spaces].should be_nil
|
103
|
+
subject[:entity][:managers].should be_nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|