cloudability 0.0.1 → 0.0.5
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -11
- data/LICENSE.txt +17 -18
- data/README.md +21 -22
- data/Rakefile +8 -5
- data/cloudability.gemspec +11 -6
- data/lib/cloudability.rb +7 -7
- data/lib/cloudability/billing.rb +35 -36
- data/lib/cloudability/budgets.rb +16 -10
- data/lib/cloudability/credentials.rb +7 -5
- data/lib/cloudability/organizations.rb +71 -0
- data/lib/cloudability/time_helper.rb +4 -5
- data/lib/cloudability/version.rb +1 -1
- data/spec/cloduability/billing_spec.rb +53 -0
- data/spec/cloduability/budgets_spec.rb +65 -0
- data/spec/cloduability/credentials_spec.rb +29 -0
- data/spec/cloduability/organizations_spec.rb +64 -0
- data/spec/fixtures/all_budgets +18 -0
- data/spec/fixtures/credentials +18 -0
- data/spec/fixtures/organization +18 -0
- data/spec/fixtures/organization_invitation +18 -0
- data/spec/fixtures/organization_invitations +18 -0
- data/spec/fixtures/organization_roles +18 -0
- data/spec/fixtures/report_by_account +18 -0
- data/spec/fixtures/report_by_period +18 -0
- data/spec/spec_helper.rb +48 -0
- metadata +89 -42
- data/test/fixtures/billing_report_by-vendor.json +0 -1
- data/test/fixtures/billing_report_period.json +0 -1
- data/test/fixtures/billing_report_year.json +0 -54
- data/test/fixtures/budgets.json +0 -34
- data/test/fixtures/credentials.json +0 -28
- data/test/helper.rb +0 -22
- data/test/lib/cloudability/test_billing.rb +0 -55
- data/test/lib/cloudability/test_budgets.rb +0 -44
- data/test/lib/cloudability/test_credentials.rb +0 -21
- data/test/lib/cloudability/test_time_helper.rb +0 -24
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'date'
|
2
|
-
require '
|
2
|
+
require 'hashie'
|
3
3
|
|
4
4
|
# Cloudability requires time periods formatted in YYYY-MM-01 The date must always be 1.
|
5
5
|
# This provides a set of helpers to always return the correct period format.
|
@@ -13,9 +13,8 @@ class TimeHelper
|
|
13
13
|
last_month = (dt << 1).strftime("%Y-%m-01")
|
14
14
|
three_month = (dt << 2).strftime("%Y-%m-01")
|
15
15
|
|
16
|
-
hash = { :
|
17
|
-
|
18
|
-
return mash
|
16
|
+
hash = { current: current_month, last: last_month, three: three_month }
|
17
|
+
Hashie::Mash.new(hash)
|
19
18
|
end
|
20
19
|
|
21
20
|
# Returns the current month
|
@@ -23,4 +22,4 @@ class TimeHelper
|
|
23
22
|
DateTime.now.strftime("%Y-%m-01")
|
24
23
|
end
|
25
24
|
|
26
|
-
end
|
25
|
+
end
|
data/lib/cloudability/version.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudability::Billing do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'should raise ArgumentError when auth_token is not provided' do
|
6
|
+
expect { Cloudability::Billing.new }.to raise_exception(ArgumentError)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should not raise any exception when auth token is provided' do
|
10
|
+
expect { Cloudability::Billing.new(auth_token: 'token') }.not_to raise_exception
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
@cloudability = Cloudability::Billing.new(auth_token: 'token')
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#report_by' do
|
19
|
+
it 'should raise an ArgumentError when no dimension is passed' do
|
20
|
+
expect { @cloudability.report_by }.to raise_exception(ArgumentError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should raise an ArgumentError when unknown dimension is passed' do
|
24
|
+
expect { @cloudability.report_by(:coolness) }.to raise_exception(ArgumentError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should be an array' do
|
28
|
+
stub_get('/0/billing_reports?auth_token=token&by=account', 'report_by_account')
|
29
|
+
@cloudability.report_by(:account).class.should == Array
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should be an array of Hashie::Mashes' do
|
33
|
+
stub_get('/0/billing_reports?auth_token=token&by=account', 'report_by_account')
|
34
|
+
@cloudability.report_by(:account).each{|report| report.class.should == Hashie::Mash }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#filter_by_period' do
|
39
|
+
it 'should get a report given a period' do
|
40
|
+
stub_get('/0/billing_reports?auth_token=token&period=13-08-05', 'report_by_period')
|
41
|
+
expect { @cloudability.filter_by_period('13-08-05') }.not_to raise_exception
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should be a Hashie::Mash' do
|
45
|
+
stub_get('/0/billing_reports?auth_token=token&period=13-08-05', 'report_by_period')
|
46
|
+
@cloudability.filter_by_period('13-08-05').class.should == Hashie::Mash
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should raise an ArgumentError when an invalid date is provided' do
|
50
|
+
expect { @cloudability.filter_by_period('1343-08-05') }.to raise_exception(ArgumentError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudability::Budgets do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'should raise ArgumentError when auth_token is not provided' do
|
6
|
+
expect { Cloudability::Budgets.new }.to raise_exception(ArgumentError)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should not raise any exception when auth token is provided' do
|
10
|
+
expect { Cloudability::Budgets.new(auth_token: 'token') }.not_to raise_exception
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
@cloudability = Cloudability::Budgets.new(auth_token: 'token')
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#find_all' do
|
19
|
+
it 'should be an array' do
|
20
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
21
|
+
@cloudability.find_all.class.should == Array
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be an array of Hashie::Mashes' do
|
25
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
26
|
+
@cloudability.find_all.each{|budget| budget.class.should == Hashie::Mash }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#find_by_id' do
|
31
|
+
it 'should be a Hashie::Mash' do
|
32
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
33
|
+
@cloudability.find_by_id(2039).class.should == Hashie::Mash
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should accept a string as an argument' do
|
37
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
38
|
+
expect { @cloudability.find_by_id('2039') }.not_to raise_exception
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#find_by_subject' do
|
43
|
+
it 'should be a Hashie::Mash' do
|
44
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
45
|
+
@cloudability.find_by_subject('1111-1111-1111').class.should == Hashie::Mash
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should raise an ArgumentError when you give it a non valid key' do
|
49
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
50
|
+
expect { @cloudability.find_by_subject('1111-111-1111') }.to raise_exception(ArgumentError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#find_by_key' do
|
55
|
+
it 'should find a budget given a key value pair' do
|
56
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
57
|
+
@cloudability.find_by_key(key: :id, value: 2039).class.should == Hashie::Mash
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should raise an ArgumentError when you give it a weirdass key' do
|
61
|
+
stub_get('/1/budgets/index?auth_token=token', 'all_budgets')
|
62
|
+
expect { @cloudability.find_by_key(key: :hipsterness, value: 2039) }.to raise_exception(ArgumentError)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudability::Credentials do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'should raise ArgumentError when auth_token is not provided' do
|
6
|
+
expect { Cloudability::Credentials.new }.to raise_exception(ArgumentError)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should not raise any exception when auth token is provided' do
|
10
|
+
expect { Cloudability::Credentials.new(auth_token: 'token') }.not_to raise_exception
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
@cloudability = Cloudability::Credentials.new(auth_token: 'token')
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#find_all' do
|
19
|
+
it 'should be an array' do
|
20
|
+
stub_get('/0/credentials/index?auth_token=token', 'credentials')
|
21
|
+
@cloudability.find_all.class.should == Array
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be an array of Hashie::Mashes' do
|
25
|
+
stub_get('/0/credentials/index?auth_token=token', 'credentials')
|
26
|
+
@cloudability.find_all.each{|credential| credential.class.should == Hashie::Mash }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudability::Organizations do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'should raise ArgumentError when auth_token is not provided' do
|
6
|
+
expect { Cloudability::Organizations.new }.to raise_exception(ArgumentError)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should not raise any exception when auth token is provided' do
|
10
|
+
expect { Cloudability::Organizations.new(auth_token: 'token') }.not_to raise_exception
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
@cloudability = Cloudability::Organizations.new(auth_token: 'token')
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#my_organization' do
|
19
|
+
it 'should be a Hashie::Mashe' do
|
20
|
+
stub_get('/1/organizations?auth_token=token', 'organization')
|
21
|
+
@cloudability.my_organization.class.should == Hashie::Mash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#invitations' do
|
26
|
+
it 'should be an Array' do
|
27
|
+
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations')
|
28
|
+
@cloudability.invitations.class.should == Array
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should be an array of Hashie::Mashes' do
|
32
|
+
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations')
|
33
|
+
@cloudability.invitations.each{|invite| invite.class.should == Hashie::Mash }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#roles' do
|
38
|
+
it 'should be an Array' do
|
39
|
+
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles')
|
40
|
+
@cloudability.roles.class.should == Array
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should be an array of Hashie::Mashes' do
|
44
|
+
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles')
|
45
|
+
@cloudability.roles.each{|role| role.class.should == Hashie::Mash }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#invite_user' do
|
50
|
+
it 'should be a Hashie::Mash' do
|
51
|
+
stub_post('/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com', 'organization_invitation')
|
52
|
+
@cloudability.invite_user(email: 'colbyaleyrb@gmail.com').class.should == Hashie::Mash
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should accept a hash with email and name' do
|
56
|
+
stub_post('/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com&name=colby', 'organization_invitation')
|
57
|
+
expect { @cloudability.invite_user(email: 'colbyaleyrb@gmail.com', name: 'colby') }.not_to raise_exception
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should not accept requests without an email' do
|
61
|
+
expect { @cloudability.invite_user(name: 'Colby Aley') }.to raise_exception(ArgumentError)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 03:38:54 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 221
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=9c17829664b635eb1a6dd2d98800f709--200; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "38c868700599b19a2926ba6a2af50fa2"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: e803b952aafca52d3eb7489e1ad842d5
|
14
|
+
X-Runtime: 0.053636
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
[{"predicted_monthly_spend":{"cents":1111111,"currency":{"id":146,"key":"usd","priority":1,"iso_code":"USD"}},"subject":"1111-1111-1111","type":"Account","currency":"USD","id":2039,"is_active":true,"threshold":"50000.0"}]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 04:03:22 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 3717
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=2508838819c77588900b82fa3e330bf8--200; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "0ad575e0da63e162228af310e6d286b9"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: dce5851e15554d1eae5286bc2da84634
|
14
|
+
X-Runtime: 0.202919
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
[{"has_auth":true,"has_estimate":false,"is_duplicate":false,"vendor_key":"Amazon","id":11111,"vendor_id":1,"created_at":"2012-12-19T18:10:46Z","updated_at":"2013-12-25T03:42:05Z","nickname":"Acme Co. Production","state":"verified","account_identifier":"1111-1111-1111","account_created_at":"2013-05-01T00:00:00Z"},{"has_auth":true,"has_estimate":false,"is_duplicate":false,"vendor_key":"Heroku","id":1111,"vendor_id":2,"created_at":"2013-08-18T23:07:16Z","updated_at":"2013-12-25T03:25:32Z","nickname":"Acme Co.","state":"verified","account_identifier":"xxx","account_created_at":"2009-11-02T19:17:01Z"}]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 04:39:38 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 489
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=299338dc5633de816a18ac8c96d29724--200; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "76b41bc42bebdf7277b6eae517c77de3"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: c1bbd7740bce218bd4a97423aba86c3d
|
14
|
+
X-Runtime: 0.235944
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
{"id":1548,"name":"Colby Aley","default":false,"children":[],"invitations":[{"id":1548,"state":"accepted","user":{"id":5902,"full_name":"Colby Aley","email":"colby@aley.me","default_filter_set_id":null,"is_organization_admin":true,"currency":{"key":"usd","symbol":"$","symbol_first":true,"thousands_separator":",","decimal_mark":"."},"is_enterprise":true,"ri_az_transfer_beta":false},"organization_role":{"id":1,"key":"admin","label":"Administrator"}}],"created_at":"2013-07-11T02:35:52Z"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 201 Created
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 05:47:18 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 318
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 201 Created
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=379f814d012ea011e3b06a9d27c08589--201; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "315d11c00c3c098a8b232bdc46310b93"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: eada05630363230c2942dd46f0561cf2
|
14
|
+
X-Runtime: 1.487748
|
15
|
+
X-Rack-Cache: invalidate, pass
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
{"id":10427,"state":"pending","user":{"id":10505,"full_name":null,"email":"colbyaleyrb@gmail.com","default_filter_set_id":null,"is_organization_admin":false,"currency":{"key":"usd","symbol":"$","symbol_first":true,"thousands_separator":",","decimal_mark":"."}},"organization_role":{"id":2,"key":"user","label":"User"}}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 04:46:40 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 746
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=53ec8b9512d2efe39fd059709c8ad35c--200; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "55e062e7527926f54559b0e2ad810915"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: 2f5a92d8db37da8e719265cf74866386
|
14
|
+
X-Runtime: 0.151318
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
[{"id":10424,"state":"pending","user":{"id":10502,"full_name":"Cudi Aley","email":"ayycudi@aley.me","default_filter_set_id":null,"is_organization_admin":false,"currency":{"key":"usd","symbol":"$","symbol_first":true,"thousands_separator":",","decimal_mark":"."},"is_enterprise":true,"ri_az_transfer_beta":false},"organization_role":{"id":2,"key":"user","label":"User"}},{"id":1548,"state":"accepted","user":{"id":5902,"full_name":"Colby Aley","email":"colby@aley.me","default_filter_set_id":null,"is_organization_admin":true,"currency":{"key":"usd","symbol":"$","symbol_first":true,"thousands_separator":",","decimal_mark":"."},"is_enterprise":true,"ri_az_transfer_beta":false},"organization_role":{"id":1,"key":"admin","label":"Administrator"}}]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 06:00:08 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 85
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=7b713ce79009c9db2eaea4cde43268e9--200; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "4ccf5f4c217aaffe5601d88739504032"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: 01a7274813811338beb87e23669afdda
|
14
|
+
X-Runtime: 0.024049
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
[{"id":1,"key":"admin","label":"Administrator"},{"id":2,"key":"user","label":"User"}]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 02:18:25 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 1792
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=4f95f0a64cfeb8e02daf80dfb0ea9991--200; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "84a218eedbe7d943b0857ee19afb8fa2"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: 8891c880e5625ce8d39bdd79e7b12d7f
|
14
|
+
X-Runtime: 0.221266
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
[{"account_id":null,"account_name":null,"credential_id":22975,"credential_name":"Capsule CRM 1","vendor_id":77,"vendor_name":"Capsule CRM","spend":11111.0,"currency":"USD"},{"account_id":11731,"account_name":"xxx","credential_id":8778,"credential_name":"SL54339","vendor_id":67,"vendor_name":"SoftLayer","spend":11111.11,"currency":"USD"}]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 25 Dec 2013 02:49:35 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 2
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
Set-Cookie: _mkra_ctxt=cd4d354e0eff5733a115d60cc2cd8f7b--200; path=/; secure
|
10
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
11
|
+
ETag: "d751713988987e9331980363e24189ce"
|
12
|
+
Cache-Control: max-age=0, private, must-revalidate
|
13
|
+
X-Request-Id: dcb2471ac74c614d429872ff8996c01c
|
14
|
+
X-Runtime: 0.058661
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
Origin: app.cloudability.com
|
17
|
+
|
18
|
+
[]
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'fakeweb'
|
4
|
+
require 'cloudability'
|
5
|
+
|
6
|
+
# Borrowed this Fixtures/Fakeweb implimentation
|
7
|
+
# fromt the gauges-gem library.
|
8
|
+
# https://github.com/fastestforward/gauges-gem
|
9
|
+
# https://github.com/fastestforward/gauges-gem/blob/master/spec/helper.rb
|
10
|
+
|
11
|
+
BASE_URI = 'https://app.cloudability.com/api'
|
12
|
+
|
13
|
+
module FakeRequestHelpers
|
14
|
+
def fixture(name)
|
15
|
+
path = File.expand_path("../fixtures/#{name}", __FILE__)
|
16
|
+
File.open(path).read
|
17
|
+
end
|
18
|
+
|
19
|
+
def stub_get(url, name)
|
20
|
+
FakeWeb.register_uri(:get, BASE_URI + url, :response => fixture(name))
|
21
|
+
end
|
22
|
+
|
23
|
+
def stub_post(url, name)
|
24
|
+
FakeWeb.register_uri(:post, BASE_URI + url, :response => fixture(name))
|
25
|
+
end
|
26
|
+
|
27
|
+
def stub_put(url, name)
|
28
|
+
FakeWeb.register_uri(:put, BASE_URI + url, :response => fixture(name))
|
29
|
+
end
|
30
|
+
|
31
|
+
def stub_delete(url, name)
|
32
|
+
FakeWeb.register_uri(:delete, BASE_URI + url, :response => fixture(name))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
RSpec.configure do |c|
|
38
|
+
c.include(FakeRequestHelpers)
|
39
|
+
|
40
|
+
c.before(:each) do
|
41
|
+
FakeWeb.clean_registry
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
FakeWeb.allow_net_connect = false
|
46
|
+
|
47
|
+
# Creating fixtures:
|
48
|
+
# curl -is https://app.cloudability.com/api/0/billing_reports?auth_token=token&by=account > spec/fixtures/billing_report
|