foaas-client 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a23ada1b0746e38f8bd9193043ad0814ed200e2
4
- data.tar.gz: 5ff1439e07fcee8aa1cb46b89d5e6577dd82a468
3
+ metadata.gz: d6f403c522cdcffe8b5b575db4ecdeb9799c5841
4
+ data.tar.gz: f8acfb17a7d5b7683c0d041437f5642c11b8c21a
5
5
  SHA512:
6
- metadata.gz: 4a68ccdf4fc92ff705c82108ccdd5d016f21fc6dfdc34effa81a234bf3f26fb0062640ece308c8e4d16db777d8b9297d6b2b2889ced389c6e6c5d78eea3de14a
7
- data.tar.gz: 2c27e49551364bf2055ffd8911a24f1b9a63b97bff8d4f430cc8ebf3adef55ac1ba3ade69253cbc63cee7cbc51011fc2ece3480e147e76f2a517ae8e82bfa8f2
6
+ metadata.gz: ee06f9dbd7d1c2eba915bfc48acbae3237654eb29d2f68f7744e890076228826cd1844dc89b938d9436849a802fd1ca4b871d4490f960c97e1f5dd13d3d8d30e
7
+ data.tar.gz: 7f24ff69a416d1cb0eac18e445d5742756400d3b49846a38d5448093d844961eeaf46847128b1637a8ef6b38db4f116f0a74bc256a7a77e5f8e1c4758656a3ef
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.0
4
+
5
+ * Fix errors in README
6
+ * Add support for XML response type
7
+ * Implement the following FOAAS methods:
8
+ * Ballmer
9
+ * Field
10
+ * Caniuse
11
+ * Because
12
+ * What
13
+ * Yoda
14
+ * Nugget
15
+ * Cool
16
+ * Madison
17
+
3
18
  ## v0.1.0
4
19
 
5
20
  * Implement the following FOAAS methods:
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # Foaas Client
2
2
 
3
+ [![Build Status](https://travis-ci.org/petedmarsh/foaas-client.png)](https://travis-ci.org/petedmarsh/foaas-client)
4
+ [![Code Climate](https://codeclimate.com/github/petedmarsh/foaas-client.png)](https://codeclimate.com/github/petedmarsh/foaas-client)
5
+
3
6
  A client for [FOAAS](http://foaas.com).
4
7
 
5
8
  ## API Version
6
9
 
7
- Version `0.0.2` of the FOAAS API is supported.
10
+ Version `0.0.4` of the FOAAS API is supported.
8
11
 
9
12
  ## Usage
10
13
 
@@ -28,71 +31,81 @@ fuck.off('Bob', 'Alice', :text)
28
31
 
29
32
  fuck.off('Bob', 'Alice', :html)
30
33
  #=> '<html>...</html>'
34
+
35
+ fuck.off('Bob', 'Alice', :xml)
36
+ #=> '<?xml version="1.0" encoding="utf-8"?>'
31
37
  ```
32
38
 
33
39
  ### Methods
34
40
 
35
- #### Everyone
41
+ ### Ballmer
36
42
 
37
43
  ```ruby
38
- fuck.everyone('Alice')
39
- #=> { 'message' => 'Everyone can go and fuck off.', 'subtitle' => '- Alice' }
44
+ fuck.ballmer('Bob', 'Alice', 'Clara')
45
+ #=> { 'message' => 'Fucking Bob is a fucking pussy. I'm going to fucking bury that guy, I have done it before, and I will do it again. I'm going to fucking kill Alice.', 'subtitle' => 'Clara' }
40
46
  ```
41
47
 
42
- #### Everything
48
+ ### Because
43
49
 
44
50
  ```ruby
45
- fuck.everything('Alice')
46
- #=> { 'message' => 'Fuck everything.', 'subtitle' => '- Alice' }
51
+ fuck.because('Alice')
52
+ #=> { 'message' => 'Why? Because Fuck you, that\'s why.', 'subtitle' => 'Alice' }
47
53
  ```
48
54
 
49
- #### Fascinating
55
+ ### Can I use?
50
56
 
51
57
  ```ruby
52
- fuck.fascinating('Alice')
53
- #=> { 'message' => 'Fascinating story, in what chapter do you shut the fuck up?', 'subtitle' => '- Alice' }
58
+ fuck.caniuse('Bob', 'Alice')
59
+ #=> { 'message' => 'Can you use Bob? Fuck no!', 'subtitle' => '- Alice' }
54
60
  ```
55
61
 
56
- #### Life
62
+ #### Chainsaw
57
63
 
58
64
  ```ruby
59
- fuck.donut('Alice')
60
- #=> { 'message' => 'Fuck my life.', 'subtitle' => '- Alice' }
65
+ fuck.chainsaw('Bob', 'Alice')
66
+ #=> { 'message' => 'Fuck me gently with a chainsaw, Bob. Do I look like Mother Teresa?', 'subtitle' => '- Alice' }
61
67
  ```
62
68
 
63
- #### Pink
69
+ ### Cool
64
70
 
65
71
  ```ruby
66
- fuck.donut('Alice')
67
- #=> { 'message' => 'Well, Fuck me pink.', 'subtitle' => '- Alice' }
72
+ fuck.cool('Alice')
73
+ #=> { 'message' => 'Cool story, Bro', '- Alice' }
68
74
  ```
69
75
 
70
- #### That
76
+ #### Donut
71
77
 
72
78
  ```ruby
73
- fuck.that('Alice')
74
- #=> { 'message' => 'Fuck that', 'subtitle' => '- Alice' }
79
+ fuck.donut('Bob', 'Alice')
80
+ #=> { 'message' => 'Bob, go and take a flying fuck at a rolling donut.', 'subtitle' => '- Alice' }
75
81
  ```
76
82
 
77
- #### This
83
+ #### Everyone
78
84
 
79
85
  ```ruby
80
- fuck.this(Alice')
81
- #=> { 'message' => 'Fuck this.', 'subtitle' => '- Alice' }
86
+ fuck.everyone('Alice')
87
+ #=> { 'message' => 'Everyone can go and fuck off.', 'subtitle' => '- Alice' }
82
88
  ```
83
89
 
84
- #### Chainsaw
90
+ #### Everything
85
91
 
86
92
  ```ruby
87
- fuck.chainsaw('Bob', 'Alice')
88
- #=> { 'message' => 'Fuck me gently with a chainsaw, Bob. Do I look like Mother Teresa?', 'subtitle' => '- Alice' }
93
+ fuck.everything('Alice')
94
+ #=> { 'message' => 'Fuck everything.', 'subtitle' => '- Alice' }
89
95
  ```
90
96
 
91
- #### Donut
97
+ #### Fascinating
92
98
 
93
99
  ```ruby
94
- fuck.donut('Bob', 'Alice')
95
- #=> { 'message' => 'Bob, go and take a flying fuck at a rolling donut.', 'subtitle' => '- Alice' }
100
+ fuck.fascinating('Alice')
101
+ #=> { 'message' => 'Fascinating story, in what chapter do you shut the fuck up?', 'subtitle' => '- Alice' }
102
+ ```
103
+
104
+ ### Field
105
+
106
+ ```ruby
107
+ fuck.field('Bob', 'Alice', 'Clara')
108
+ #=> { 'message' => 'And Alice said on to Bob, "Verily, cast thine eyes upon the field in which I grow my fucks", and Bobgave witness onto the field, and saw that it was barren.', => '- Clara' }
96
109
  ```
97
110
 
98
111
  #### King
@@ -102,6 +115,13 @@ fuck.king('Bob', 'Alice')
102
115
  #=> { 'message' => 'Oh fuck off, just really fuck off you total dickface. Christ Bob, you are fucking thick.', 'subtitle' => '- Alice' }
103
116
  ```
104
117
 
118
+ #### Life
119
+
120
+ ```ruby
121
+ fuck.life('Alice')
122
+ #=> { 'message' => 'Fuck my life.', 'subtitle' => '- Alice' }
123
+ ```
124
+
105
125
  #### Linus
106
126
 
107
127
  ```ruby
@@ -109,6 +129,20 @@ fuck.linus('Bob', 'Alice')
109
129
  #=> { 'message' => 'Bob, there aren't enough swear-words in the English language, so now I'll have to call you perkeleen vittupää just to express my disgust and frustration with this crap.', 'subtitle' => '- Alice' }
110
130
  ```
111
131
 
132
+ ### Madison
133
+
134
+ ```ruby
135
+ fuck.madison('Bob', 'Alice')
136
+ #=> { 'What you\'ve said is one of the most insantely idiotic things I have ever heard, Bob. At no point in your rambling, incoherent response were you even close to anything that could be considered a rational thought. Everyone in this room is now dumber for having listened to it. I award you no points Bob, and may God have mercy on your soul.', 'subtitle' => '- Alice' }
137
+ ```
138
+
139
+ ### Nugget
140
+
141
+ ```ruby
142
+ fuck.nugget('Bob', 'Alice')
143
+ #=> { ''Well Bob, aren\'t you a shining example of a rancid fuck-nugget.', 'subtitle' => '- Alice' }
144
+ ```
145
+
112
146
  #### Off
113
147
 
114
148
  ```ruby
@@ -116,6 +150,20 @@ fuck.off('Bob', 'Alice')
116
150
  #=> { 'message' => 'Fuck off, Bob.', 'subtitle' => '- Alice' }
117
151
  ```
118
152
 
153
+ ### Outside
154
+
155
+ ```ruby
156
+ fuck.outside('Bob', 'Alice')
157
+ #=> { 'message' => 'Bob, why don\'t you go outside and play hide-and-go-fuck-yourself?', 'subtitle' => '- Alice' }
158
+ ```
159
+
160
+ #### Pink
161
+
162
+ ```ruby
163
+ fuck.pink('Alice')
164
+ #=> { 'message' => 'Well, Fuck me pink.', 'subtitle' => '- Alice' }
165
+ ```
166
+
119
167
  #### Shakespeare
120
168
 
121
169
  ```ruby
@@ -130,11 +178,11 @@ fuck.thanks('Bob', 'Alice')
130
178
  #=> { 'message' => 'Fuck you very much', 'subtitle' => '- Alice' }
131
179
  ```
132
180
 
133
- #### You
181
+ #### That
134
182
 
135
183
  ```ruby
136
- fuck.you('Bob', 'Alice')
137
- #=> { 'message' => 'Fuck you, Bob.', 'subtitle' => '- Alice' }
184
+ fuck.that('Alice')
185
+ #=> { 'message' => 'Fuck that', 'subtitle' => '- Alice' }
138
186
  ```
139
187
 
140
188
  #### Thing
@@ -143,3 +191,31 @@ fuck.you('Bob', 'Alice')
143
191
  fuck.thing('it', 'Alice')
144
192
  #=> { 'message' => 'Fuck it.', 'subtitle' => '- Alice' }
145
193
  ```
194
+
195
+ #### This
196
+
197
+ ```ruby
198
+ fuck.this('Alice')
199
+ #=> { 'message' => 'Fuck this.', 'subtitle' => '- Alice' }
200
+ ```
201
+
202
+ ### What
203
+
204
+ ```ruby
205
+ fuck.what('Alice')
206
+ #=> { 'message' => 'What the fuck?!', 'subtitle' => '- Alice' }
207
+ ```
208
+
209
+ ### Yoda
210
+
211
+ ```ruby
212
+ fuck.yoda('Bob', 'Alice')
213
+ #=> { 'message' => 'Fuck off, you must, Bob', 'subtitle' => '- Alice' }
214
+ ```
215
+
216
+ #### You
217
+
218
+ ```ruby
219
+ fuck.you('Bob', 'Alice')
220
+ #=> { 'message' => 'Fuck you, Bob.', 'subtitle' => '- Alice' }
221
+ ```
@@ -5,16 +5,19 @@ require 'json'
5
5
  module Foaas
6
6
  class Client
7
7
 
8
- URL = Addressable::Template.new("http://foaas.com/{method}{/name}/{from}")
8
+ URL = Addressable::Template.new("http://foaas.com/{method}{/name}/{from}{/other}")
9
9
 
10
- METHODS_ONE_PARAM = [:this, :everything, :everyone, :pink, :life, :thanks, :flying, :fascinating]
11
- METHODS_TWO_PARAMS = [:off, :you, :donut, :shakespeare, :linus, :king, :chainsaw, :outside]
10
+ METHODS_ONE_PARAM = [:because, :cool, :everyone, :everything, :fascinating, :flying, :life, :pink, :thanks, :this, :what]
11
+ METHODS_TWO_PARAMS = [:donut, :caniuse, :chainsaw, :king, :linus, :madison, :nugget, :off, :outside, :shakespeare, :you, :yoda]
12
+ METHODS_THREE_PARAMS = [:ballmer, :field]
12
13
 
13
14
  def method_missing(sym, *args, &block)
14
15
  if METHODS_TWO_PARAMS.include? sym
15
16
  make_request(URL.expand(method: sym, name: args[0], from: args[1]), args[2])
16
17
  elsif METHODS_ONE_PARAM.include? sym
17
18
  make_request(URL.expand(method: sym, from: args[0]), args[1])
19
+ elsif METHODS_THREE_PARAMS.include? sym
20
+ make_request(URL.expand(method: sym, name: args[0], from: args[1], other: args[2]), args[3])
18
21
  elsif sym == :thing
19
22
  make_request(URL.expand(method: args[0], from: args[1]), args[2])
20
23
  else
@@ -1,3 +1,3 @@
1
1
  module Foaas
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -4,242 +4,350 @@ require 'foaas-client/client'
4
4
 
5
5
  describe Foaas::Client do
6
6
 
7
- it 'raises an exception if a method is unsupported' do
8
- expect { client.not_a_foaas_method }.to raise_error NoMethodError
9
- end
7
+ it 'raises an exception if a method is unsupported' do
8
+ expect { client.not_a_foaas_method }.to raise_error NoMethodError
9
+ end
10
10
 
11
- let(:client) { Foaas::Client.new }
11
+ let(:client) { Foaas::Client.new }
12
12
 
13
- Foaas::Client::METHODS_TWO_PARAMS.each do |method|
14
- describe "##{method}" do
13
+ Foaas::Client::METHODS_THREE_PARAMS.each do |method|
14
+ describe "##{method}" do
15
15
 
16
- before do
17
- RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
18
- end
16
+ before do
17
+ RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
18
+ end
19
19
 
20
- let(:name) { 'name' }
21
- let(:from) { 'from' }
22
- let(:type) { nil }
20
+ let(:name) { 'name' }
21
+ let(:from) { 'from' }
22
+ let(:other) { 'other' }
23
+ let(:type) { nil }
23
24
 
24
- let(:url) { "http://foaas.com/#{method}/#{name}/#{from}" }
25
+ let(:url) { "http://foaas.com/#{method}/#{name}/#{from}/#{other}" }
25
26
 
26
- context 'type is' do
27
+ context 'type is' do
27
28
 
28
- context 'not specified' do
29
+ context 'not specified' do
29
30
 
30
- let(:accept) { :json }
31
+ let(:accept) { :json }
31
32
 
32
- it 'defaults to JSON' do
33
- client.send(method, name, from, type)
34
- end
33
+ it 'defaults to JSON' do
34
+ client.send(method, name, from, other, type)
35
+ end
35
36
 
36
- end
37
+ end
37
38
 
38
- context 'is specified' do
39
+ context 'is specified' do
39
40
 
40
- context 'as HTML' do
41
+ context 'as HTML' do
41
42
 
42
- let(:type) { :html }
43
- let(:accept) { :html }
43
+ let(:type) { :html }
44
+ let(:accept) { :html }
44
45
 
45
- it 'specifies text/html as the accept type' do
46
- client.send(method, name, from, type)
47
- end
48
- end
46
+ it 'specifies text/html as the accept type' do
47
+ client.send(method, name, from, other, type)
48
+ end
49
+ end
49
50
 
50
- context 'as JSON' do
51
+ context 'as JSON' do
51
52
 
52
- let(:type) { :json }
53
- let(:accept) { :json}
53
+ let(:type) { :json }
54
+ let(:accept) { :json}
54
55
 
55
- it 'specifies application/json as the accept type' do
56
- client.send(method, name, from, type)
57
- end
56
+ it 'specifies application/json as the accept type' do
57
+ client.send(method, name, from, other, type)
58
+ end
58
59
 
59
- it 'parses the response into a hash' do
60
- client.send(method, name, from, type).should == { 'message' => '', 'subtitle' => ''}
61
- end
60
+ it 'parses the response into a hash' do
61
+ client.send(method, name, from, other, type).should == { 'message' => '', 'subtitle' => ''}
62
+ end
62
63
 
63
- end
64
+ end
64
65
 
65
- context 'as text' do
66
+ context 'as text' do
66
67
 
67
- let(:type) { :text }
68
- let(:accept) { 'text/plain' }
68
+ let(:type) { :text }
69
+ let(:accept) { 'text/plain' }
69
70
 
70
- it 'specifies text/plain as the accept type' do
71
- client.send(method, name, from, type)
72
- end
73
- end
74
-
75
- end
71
+ it 'specifies text/plain as the accept type' do
72
+ client.send(method, name, from, other, type)
73
+ end
74
+ end
76
75
 
77
- end
78
-
79
- end
80
- end
76
+ context 'as xml' do
81
77
 
78
+ let(:type) { :xml }
79
+ let(:accept) { :xml }
82
80
 
83
- Foaas::Client::METHODS_ONE_PARAM.each do |method|
84
- describe "##{method}" do
81
+ it 'specifies application/xml as the acccept type' do
82
+ client.send(method, name, from, other, type)
83
+ end
84
+ end
85
85
 
86
- before do
87
- RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
88
- end
86
+ end
89
87
 
90
- let(:url) { "http://foaas.com/#{method}/#{from}" }
91
- let(:from) { 'from' }
92
- let(:type) { nil }
88
+ end
89
+
90
+ end
91
+ end
93
92
 
94
- context 'type is' do
95
93
 
96
- context 'not specified' do
94
+ Foaas::Client::METHODS_TWO_PARAMS.each do |method|
95
+ describe "##{method}" do
97
96
 
98
- let(:accept) { :json }
97
+ before do
98
+ RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
99
+ end
99
100
 
100
- it 'defaults to JSON' do
101
- client.send(method, from, type)
102
- end
101
+ let(:name) { 'name' }
102
+ let(:from) { 'from' }
103
+ let(:type) { nil }
103
104
 
104
- end
105
+ let(:url) { "http://foaas.com/#{method}/#{name}/#{from}" }
105
106
 
106
- context 'is specified' do
107
+ context 'type is' do
107
108
 
108
- context 'as HTML' do
109
+ context 'not specified' do
109
110
 
110
- let(:type) { :html }
111
- let(:accept) { :html }
111
+ let(:accept) { :json }
112
112
 
113
- it 'specifies text/html as the accept type' do
114
- client.send(method, from, type)
115
- end
116
- end
113
+ it 'defaults to JSON' do
114
+ client.send(method, name, from, type)
115
+ end
117
116
 
118
- context 'as JSON' do
117
+ end
119
118
 
120
- let(:type) { :json }
121
- let(:accept) { :json }
119
+ context 'is specified' do
122
120
 
123
- it 'specifies application/json as the accept type' do
124
- client.send(method, from, type)
125
- end
121
+ context 'as HTML' do
126
122
 
127
- it 'parses the response into a hash' do
128
- client.send(method, from, type).should == { 'message' => '', 'subtitle' => ''}
129
- end
123
+ let(:type) { :html }
124
+ let(:accept) { :html }
130
125
 
131
- end
126
+ it 'specifies text/html as the accept type' do
127
+ client.send(method, name, from, type)
128
+ end
129
+ end
132
130
 
133
- context 'as text' do
131
+ context 'as JSON' do
134
132
 
135
- let(:type) { :text }
136
- let(:accept) { 'text/plain'}
133
+ let(:type) { :json }
134
+ let(:accept) { :json}
137
135
 
138
- it 'specifies text/plain as the accept type' do
139
- client.send(method, from, type)
140
- end
141
- end
142
-
143
- end
136
+ it 'specifies application/json as the accept type' do
137
+ client.send(method, name, from, type)
138
+ end
144
139
 
145
- end
146
-
147
- end
148
- end
140
+ it 'parses the response into a hash' do
141
+ client.send(method, name, from, type).should == { 'message' => '', 'subtitle' => ''}
142
+ end
149
143
 
150
- describe '#thing' do
144
+ end
151
145
 
152
- before do
153
- RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
154
- end
146
+ context 'as text' do
155
147
 
156
- let(:url) { "http://foaas.com/#{thing}/#{from}" }
157
- let(:thing) { 'thing' }
158
- let(:from) { 'from' }
159
- let(:type) { nil }
148
+ let(:type) { :text }
149
+ let(:accept) { 'text/plain' }
160
150
 
161
- context 'type is' do
151
+ it 'specifies text/plain as the accept type' do
152
+ client.send(method, name, from, type)
153
+ end
154
+ end
162
155
 
163
- context 'not specified' do
156
+ context 'as xml' do
164
157
 
165
- let(:accept) { :json }
158
+ let(:type) { :xml }
159
+ let(:accept) { :xml }
166
160
 
167
- it 'defaults to JSON' do
168
- client.thing(thing, from, type)
169
- end
170
- end
161
+ it 'specifies application/xml as the acccept type' do
162
+ client.send(method, name, from, type)
163
+ end
164
+ end
171
165
 
172
- context 'is specified' do
166
+ end
173
167
 
174
- context 'as HTML' do
168
+ end
169
+
170
+ end
171
+ end
175
172
 
176
- let(:type) { :html }
177
- let(:accept) { :html }
178
173
 
179
- it 'specifies text/html as the accept type' do
180
- client.thing(thing, from, type)
181
- end
182
- end
174
+ Foaas::Client::METHODS_ONE_PARAM.each do |method|
175
+ describe "##{method}" do
183
176
 
184
- context 'as JSON' do
177
+ before do
178
+ RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
179
+ end
185
180
 
186
- let(:type) { :json }
187
- let(:accept) { :json }
181
+ let(:url) { "http://foaas.com/#{method}/#{from}" }
182
+ let(:from) { 'from' }
183
+ let(:type) { nil }
188
184
 
189
- it 'specifies application/json as the accept type' do
190
- client.thing(thing, from, type)
191
- end
185
+ context 'type is' do
192
186
 
193
- it 'parses the response into a hash' do
194
- client.thing(thing, from, type).should == { 'message' => '', 'subtitle' => ''}
195
- end
196
-
197
- end
187
+ context 'not specified' do
198
188
 
199
- context 'as text' do
189
+ let(:accept) { :json }
200
190
 
201
- let(:type) { :text }
202
- let(:accept) { 'text/plain' }
191
+ it 'defaults to JSON' do
192
+ client.send(method, from, type)
193
+ end
203
194
 
204
- it 'specifies text/plain as the accept type' do
205
- client.thing(thing, from, type)
206
- end
207
- end
208
-
209
- end
195
+ end
210
196
 
211
- end
197
+ context 'is specified' do
212
198
 
213
- end
199
+ context 'as HTML' do
214
200
 
215
- describe '#respond_to?' do
201
+ let(:type) { :html }
202
+ let(:accept) { :html }
216
203
 
217
- let(:sym) { nil }
204
+ it 'specifies text/html as the accept type' do
205
+ client.send(method, from, type)
206
+ end
207
+ end
218
208
 
219
- subject do
220
- client.respond_to?(sym)
221
- end
209
+ context 'as JSON' do
222
210
 
223
- (Foaas::Client::METHODS_ONE_PARAM + Foaas::Client::METHODS_TWO_PARAMS + [:thing]).each do |method|
211
+ let(:type) { :json }
212
+ let(:accept) { :json }
224
213
 
225
- context "for :#{method}" do
214
+ it 'specifies application/json as the accept type' do
215
+ client.send(method, from, type)
216
+ end
226
217
 
227
- let(:sym) { method }
218
+ it 'parses the response into a hash' do
219
+ client.send(method, from, type).should == { 'message' => '', 'subtitle' => ''}
220
+ end
228
221
 
229
- it { should be_true }
222
+ end
230
223
 
231
- end
224
+ context 'as text' do
232
225
 
233
- context 'for non-FOAAS methods' do
226
+ let(:type) { :text }
227
+ let(:accept) { 'text/plain'}
234
228
 
235
- let(:sym) { :not_a_foaas_method }
229
+ it 'specifies text/plain as the accept type' do
230
+ client.send(method, from, type)
231
+ end
232
+ end
236
233
 
237
- it { should be_false }
234
+ context 'as xml' do
235
+ let(:type) { :xml }
236
+ let(:accept) { :xml }
238
237
 
239
- end
238
+ it 'specifies application/xml as the accept type' do
239
+ client.send(method, from, type)
240
+ end
241
+ end
242
+ end
240
243
 
241
- end
244
+ end
245
+
246
+ end
247
+ end
242
248
 
243
- end
249
+ describe '#thing' do
250
+
251
+ before do
252
+ RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
253
+ end
254
+
255
+ let(:url) { "http://foaas.com/#{thing}/#{from}" }
256
+ let(:thing) { 'thing' }
257
+ let(:from) { 'from' }
258
+ let(:type) { nil }
259
+
260
+ context 'type is' do
261
+
262
+ context 'not specified' do
263
+
264
+ let(:accept) { :json }
265
+
266
+ it 'defaults to JSON' do
267
+ client.thing(thing, from, type)
268
+ end
269
+ end
270
+
271
+ context 'is specified' do
272
+
273
+ context 'as HTML' do
274
+
275
+ let(:type) { :html }
276
+ let(:accept) { :html }
277
+
278
+ it 'specifies text/html as the accept type' do
279
+ client.thing(thing, from, type)
280
+ end
281
+ end
282
+
283
+ context 'as JSON' do
284
+
285
+ let(:type) { :json }
286
+ let(:accept) { :json }
287
+
288
+ it 'specifies application/json as the accept type' do
289
+ client.thing(thing, from, type)
290
+ end
291
+
292
+ it 'parses the response into a hash' do
293
+ client.thing(thing, from, type).should == { 'message' => '', 'subtitle' => ''}
294
+ end
295
+
296
+ end
297
+
298
+ context 'as text' do
299
+
300
+ let(:type) { :text }
301
+ let(:accept) { 'text/plain' }
302
+
303
+ it 'specifies text/plain as the accept type' do
304
+ client.thing(thing, from, type)
305
+ end
306
+ end
307
+
308
+ context 'as xml' do
309
+
310
+ let(:type) { :xml }
311
+ let(:accept) { :xml }
312
+
313
+ it 'specifies application/xml as the accept type' do
314
+ client.thing(thing, from, type)
315
+ end
316
+ end
317
+ end
318
+
319
+ end
320
+
321
+ end
322
+
323
+ describe '#respond_to?' do
324
+
325
+ let(:sym) { nil }
326
+
327
+ subject do
328
+ client.respond_to?(sym)
329
+ end
330
+
331
+ (Foaas::Client::METHODS_ONE_PARAM + Foaas::Client::METHODS_TWO_PARAMS + [:thing]).each do |method|
332
+
333
+ context "for :#{method}" do
334
+
335
+ let(:sym) { method }
336
+
337
+ it { should eq true }
338
+
339
+ end
340
+
341
+ context 'for non-FOAAS methods' do
342
+
343
+ let(:sym) { :not_a_foaas_method }
344
+
345
+ it { should eq false }
346
+
347
+ end
348
+
349
+ end
350
+
351
+ end
244
352
 
245
353
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foaas-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Marsh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-11 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -90,7 +90,6 @@ files:
90
90
  - .gitignore
91
91
  - .travis.yml
92
92
  - CHANGELOG.md
93
- - CHANGELOG.md~
94
93
  - Gemfile
95
94
  - LICENSE
96
95
  - README.md
@@ -121,10 +120,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
120
  version: '0'
122
121
  requirements: []
123
122
  rubyforge_project:
124
- rubygems_version: 2.0.3
123
+ rubygems_version: 2.2.2
125
124
  signing_key:
126
125
  specification_version: 4
127
126
  summary: A client for FOAAS
128
127
  test_files:
129
128
  - spec/foaas-client/client_spec.rb
130
129
  - spec/spec_helper.rb
130
+ has_rdoc:
data/CHANGELOG.md~ DELETED
@@ -1,20 +0,0 @@
1
- # Changelog
2
-
3
- ## v0.0.0
4
-
5
- * Implement the following FOAAS methods
6
- * Everyone
7
- * Everything
8
- * Life
9
- * Pink
10
- * That
11
- * This
12
- * Chainsaw
13
- * Donut
14
- * King
15
- * Linus
16
- * Off
17
- * Shakespeare
18
- * Thanks
19
- * You
20
- * Thing