winnie 0.0.3 → 0.0.4

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- winnie (0.0.2)
4
+ winnie (0.0.4)
5
5
  json
6
6
  rest-client
7
7
 
data/lib/winnie/client.rb CHANGED
@@ -9,15 +9,15 @@ module Winnie
9
9
  end
10
10
 
11
11
  def account
12
- get('/account')
12
+ get('/api/account')
13
13
  end
14
14
 
15
15
  def apps
16
- get('/apps')
16
+ get('/api/apps')
17
17
  end
18
18
 
19
19
  def command(command, code_name)
20
- post("/apps/#{code_name}/command", :body => command)
20
+ post("/api/apps/#{code_name}/command", :body => command)
21
21
  end
22
22
 
23
23
  def post(path, params = {})
@@ -1,3 +1,3 @@
1
1
  module Winnie
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -10,46 +10,46 @@ describe Winnie::Client do
10
10
  describe "request" do
11
11
  it "should make a request to give URL" do
12
12
  RestClient::Request.should_receive(:execute).with(
13
- request_parameters('/account', :get)
13
+ request_parameters('/api/account', :get)
14
14
  )
15
- @client.request('/account', :get)
15
+ @client.request('/api/account', :get)
16
16
  end
17
17
 
18
18
  it "should include provided parameters in the request" do
19
19
  RestClient::Request.should_receive(:execute).with(
20
- request_parameters('/account', :post,
20
+ request_parameters('/api/account', :post,
21
21
  :payload => {:api_key => 'secret_one', :name => 'test'}
22
22
  )
23
23
  )
24
- @client.request('/account', :post, :name => 'test')
24
+ @client.request('/api/account', :post, :name => 'test')
25
25
  end
26
26
 
27
27
  it "should include api_key in the request parameters" do
28
28
  @client = Winnie::Client.new('AABBCC')
29
29
  RestClient::Request.should_receive(:execute).with(
30
- request_parameters('/account', :get,
30
+ request_parameters('/api/account', :get,
31
31
  :payload => {:api_key => 'AABBCC'}
32
32
  )
33
33
  )
34
- @client.request('/account', :get)
34
+ @client.request('/api/account', :get)
35
35
  end
36
36
 
37
37
  it "should accept json responses only" do
38
38
  RestClient::Request.should_receive(:execute).with(
39
- request_parameters('/account', :get,
39
+ request_parameters('/api/account', :get,
40
40
  :headers => {:accept => 'application/json'}
41
41
  )
42
42
  )
43
- @client.request('/account', :get)
43
+ @client.request('/api/account', :get)
44
44
  end
45
45
 
46
46
  it "should pass response to process_response method" do
47
47
  response = mock(RestClient::Response)
48
48
  request = mock(RestClient::Request)
49
49
  @client.should_receive(:process_response).with(response)
50
- RestClient::Request.should_receive(:execute).with(request_parameters('/account', :get)).and_yield(response, request)
50
+ RestClient::Request.should_receive(:execute).with(request_parameters('/api/account', :get)).and_yield(response, request)
51
51
 
52
- @client.request('/account', :get)
52
+ @client.request('/api/account', :get)
53
53
  end
54
54
 
55
55
  def request_parameters(path, method, params = {})
@@ -70,13 +70,13 @@ describe Winnie::Client do
70
70
 
71
71
  it "should not follow redirections" do
72
72
  @response.should_receive(:return!)
73
- @client.get('/account')
73
+ @client.get('/api/account')
74
74
  end
75
75
 
76
76
  it "should raise UnauthorizedException when response has 401 code" do
77
77
  @response.stub(:code).and_return(401)
78
78
  lambda {
79
- @client.get('/account')
79
+ @client.get('/api/account')
80
80
  }.should raise_error(Winnie::Client::UnauthorizedException)
81
81
  end
82
82
 
@@ -85,7 +85,7 @@ describe Winnie::Client do
85
85
  @response.stub(:code).and_return(302)
86
86
 
87
87
  lambda {
88
- @client.get('/account')
88
+ @client.get('/api/account')
89
89
  }.should raise_error(Winnie::Client::UnauthorizedException)
90
90
  end
91
91
 
@@ -94,7 +94,7 @@ describe Winnie::Client do
94
94
  @response.stub(:body).and_return({'error' => 'App not found'}.to_json)
95
95
 
96
96
  lambda {
97
- @client.post('/apps/flower/command', :body => 'puts User.count')
97
+ @client.post('/api/apps/flower/command', :body => 'puts User.count')
98
98
  }.should raise_error(Winnie::Client::ResourceNotFoundException, 'App not found')
99
99
  end
100
100
 
@@ -103,34 +103,34 @@ describe Winnie::Client do
103
103
  @response.stub(:body).and_return({'error' => 'random error happened'}.to_json)
104
104
 
105
105
  lambda {
106
- @client.post('/apps/flower/command', :body => 'puts User.count')
106
+ @client.post('/api/apps/flower/command', :body => 'puts User.count')
107
107
  }.should raise_error(Winnie::Client::CommandFailedException, 'random error happened')
108
108
  end
109
109
  end
110
110
 
111
111
  it "should make GET request to given path" do
112
- @client.should_receive(:request).with('/account', :get)
113
- @client.get('/account')
112
+ @client.should_receive(:request).with('/api/account', :get)
113
+ @client.get('/api/account')
114
114
  end
115
115
 
116
116
  it "should make POST request to given path with parameters" do
117
- @client.should_receive(:request).with('/account', :post, :name => 'pink-one')
118
- @client.post('/account', :name => 'pink-one')
117
+ @client.should_receive(:request).with('/api/account', :post, :name => 'pink-one')
118
+ @client.post('/api/account', :name => 'pink-one')
119
119
  end
120
120
 
121
121
  describe "API methods" do
122
122
  it "should get the list of user applications" do
123
- @client.should_receive(:get).with('/apps')
123
+ @client.should_receive(:get).with('/api/apps')
124
124
  @client.apps
125
125
  end
126
126
 
127
127
  it "should get account info" do
128
- @client.should_receive(:get).with('/account')
128
+ @client.should_receive(:get).with('/api/account')
129
129
  @client.account
130
130
  end
131
131
 
132
132
  it "should send command to winnie" do
133
- @client.should_receive(:post).with('/apps/flower-16/command', :body => 'User[:bob].destroy')
133
+ @client.should_receive(:post).with('/api/apps/flower-16/command', :body => 'User[:bob].destroy')
134
134
  @client.command('User[:bob].destroy', 'flower-16')
135
135
  end
136
136
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winnie
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - winnie
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-26 00:00:00 +02:00
18
+ date: 2010-10-29 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency