ey_services_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ group :test, :development do
7
7
  gem 'rake'
8
8
  gem 'sinatra'
9
9
  gem 'rcov'
10
+ gem 'guard-rspec'
10
11
  end
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/.*\.rb$}) { "spec" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/InternalGemfile CHANGED
@@ -16,4 +16,5 @@ group :test, :development do
16
16
  gem 'ey_services_api', :path => "../ey_services_api"
17
17
 
18
18
  gem 'sinatra'
19
+ gem 'guard-rspec'
19
20
  end
@@ -47,6 +47,10 @@ module EY
47
47
  delete(url)
48
48
  end
49
49
 
50
+ def update_service_account(url, params)
51
+ put(url, :service_account => params)
52
+ end
53
+
50
54
  def send_message(url, message)
51
55
  post(url, :message => message.to_hash)
52
56
  end
@@ -8,6 +8,7 @@ class TresfiestasFake
8
8
  @services = {}
9
9
  @invoices = []
10
10
  @status_messages = []
11
+ @service_accounts = {}
11
12
  end
12
13
  def self.services
13
14
  @services ||= {}
@@ -15,6 +16,9 @@ class TresfiestasFake
15
16
  def self.invoices
16
17
  @invoices ||= []
17
18
  end
19
+ def self.service_accounts
20
+ @service_accounts ||= {}
21
+ end
18
22
  def self.status_messages
19
23
  @status_messages ||= []
20
24
  end
@@ -60,9 +64,20 @@ class TresfiestasFake
60
64
  def service_account
61
65
  {:invoices_url => "#{BASE_URL}/api/1/invoices/12",
62
66
  :messages_url => "#{BASE_URL}/api/1/messages/12",
67
+ :url => "#{BASE_URL}/api/1/serviceaccounts/12",
63
68
  :id => 12}
64
69
  end
65
70
 
71
+ def pushed_service_account
72
+ pushed = TresfiestasFake.service_accounts[12] || {}
73
+ service_account.merge({
74
+ :provisioned_services_url => pushed['provisioned_services_url'],
75
+ :configuration_url => pushed['configuration_url'],
76
+ :url => pushed['url'],
77
+ :configuration_required => pushed['configuration_required'],
78
+ })
79
+ end
80
+
66
81
  #TODO: test this!, put in tresfiestas too!
67
82
  def create_service_account
68
83
  service = TresfiestasFake.services.values.first
@@ -115,7 +130,12 @@ class TresfiestasFake
115
130
  end
116
131
 
117
132
  def service_account_creation_request(service_account_hash)
118
- {}
133
+ {
134
+ :url => service_account_hash[:url],
135
+ :name => service_account_hash[:name],
136
+ :messages_url => service_account_hash[:messages_url],
137
+ :invoices_url => service_account_hash[:invoices_url]
138
+ }
119
139
  end
120
140
 
121
141
  def provisioned_service_creation_request(service_account_hash)
@@ -154,6 +174,10 @@ class TresfiestasFake
154
174
  disable :dump_errors
155
175
  disable :show_exceptions
156
176
 
177
+ get '/api/1/register_a_new_service' do
178
+ TresfiestasFake.services.values.map{|v| {"service" => v }}.to_json
179
+ end
180
+
157
181
  #TODO: auth!
158
182
  post '/api/1/register_a_new_service' do
159
183
  service_id = TresfiestasFake.services.size + 100
@@ -195,6 +219,12 @@ class TresfiestasFake
195
219
  {}.to_json
196
220
  end
197
221
 
222
+ put '/api/1/serviceaccounts/12' do
223
+ TresfiestasFake.service_accounts ||= {}
224
+ TresfiestasFake.service_accounts[12] = JSON.parse(request.body.read)["service_account"]
225
+ {}.to_json
226
+ end
227
+
198
228
  post '/api/1/invoices/:service_account_id' do |service_account_id|
199
229
  invoice_params = JSON.parse(request.body.read)["invoice"]
200
230
  unless invoice_params['total_amount_cents'].is_a?(Fixnum)
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module ServicesAPI
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -16,6 +16,25 @@ describe EY::ServicesAPI::ServiceAccountCreation do
16
16
  @service_account.name.should eq @creation_request[:name]
17
17
  end
18
18
 
19
+ describe "with a pushed service account" do
20
+ before do
21
+ @tresfiestas.pushed_service_account #make sure it's already pushed to the partner
22
+ end
23
+
24
+ describe "updating a service account" do
25
+ before do
26
+ @connection = EY::ServicesAPI.connection
27
+ @connection.update_service_account(@service_account.url, {:configuration_required => true, :configuration_url => "a different url"})
28
+ end
29
+
30
+ it "should work" do
31
+ pushed_service = @tresfiestas.pushed_service_account
32
+ pushed_service[:configuration_url].should eq "a different url"
33
+ pushed_service[:configuration_required].should eq true
34
+ end
35
+ end
36
+ end
37
+
19
38
  it "can produce a response body hash for service account creation requests" do
20
39
  response_hash = @service_account.creation_response_hash do |presenter|
21
40
  presenter.provisioned_services_url = "some provision url"
data/spec/service_spec.rb CHANGED
@@ -22,11 +22,8 @@ describe EY::ServicesAPI::Service do
22
22
  describe "with a registration_url" do
23
23
  before do
24
24
  partner = @tresfiestas.partner
25
-
26
25
  @registration_url = partner[:registration_url]
27
-
28
26
  @registration_params = @tresfiestas.service_registration_params
29
-
30
27
  @connection = EY::ServicesAPI.connection
31
28
  end
32
29
 
@@ -38,7 +35,7 @@ describe EY::ServicesAPI::Service do
38
35
 
39
36
  it "can list services" do
40
37
  services = @connection.list_services(@registration_url)
41
- services.should eq []
38
+ services.class.should eq Array
42
39
  end
43
40
 
44
41
  it "can handle errors on registration" do
@@ -54,7 +51,7 @@ describe EY::ServicesAPI::Service do
54
51
 
55
52
  it "can list services" do
56
53
  services = @connection.list_services(@registration_url)
57
- services.should eq [@service]
54
+ services.last.should eq @service
58
55
  end
59
56
 
60
57
  it "can fetch your service" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_services_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-20 00:00:00.000000000 Z
12
+ date: 2011-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2170284860 !ruby/object:Gem::Requirement
16
+ requirement: &2170005320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2170284860
24
+ version_requirements: *2170005320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &2170284400 !ruby/object:Gem::Requirement
27
+ requirement: &2170004660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2170284400
35
+ version_requirements: *2170004660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ey_api_hmac
38
- requirement: &2170283960 !ruby/object:Gem::Requirement
38
+ requirement: &2170003780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2170283960
46
+ version_requirements: *2170003780
47
47
  description: API for Partner Services (talks to services.engineyard.com)
48
48
  email:
49
49
  - jacob@engineyard.com
@@ -54,6 +54,7 @@ files:
54
54
  - .gitignore
55
55
  - .rspec
56
56
  - Gemfile
57
+ - Guardfile
57
58
  - InternalGemfile
58
59
  - README.md
59
60
  - Rakefile