drink-socially 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +674 -0
- data/README.md +54 -0
- data/config/endpoints.yml +231 -0
- data/lib/drink-socially.rb +43 -0
- data/lib/drink-socially/api.rb +124 -0
- data/lib/drink-socially/api/credential.rb +69 -0
- data/lib/drink-socially/api/notification.rb +13 -0
- data/lib/drink-socially/api/object.rb +83 -0
- data/lib/drink-socially/api/pagination.rb +73 -0
- data/lib/drink-socially/api/rate_limit.rb +17 -0
- data/lib/drink-socially/api/url_tokenizer.rb +47 -0
- data/lib/drink-socially/config.rb +48 -0
- data/lib/drink-socially/extensions/hash.rb +17 -0
- data/lib/drink-socially/http_service.rb +61 -0
- data/lib/drink-socially/http_service/response.rb +27 -0
- data/lib/drink-socially/version.rb +8 -0
- data/spec/cases/drink-socially/api/credential_spec.rb +107 -0
- data/spec/cases/drink-socially/api/object_spec.rb +112 -0
- data/spec/cases/drink-socially/api/pagination_spec.rb +43 -0
- data/spec/cases/drink-socially/api/rate_limit_spec.rb +15 -0
- data/spec/cases/drink-socially/api/url_tokenizer_spec.rb +41 -0
- data/spec/cases/drink-socially/api_spec.rb +79 -0
- data/spec/cases/drink-socially/config_spec.rb +95 -0
- data/spec/cases/drink-socially/extensions/hash_spec.rb +17 -0
- data/spec/cases/drink-socially/http_service/response_spec.rb +38 -0
- data/spec/cases/drink-socially/http_service_spec.rb +70 -0
- data/spec/cases/drink-socially/version_spec.rb +14 -0
- data/spec/cases/drink-socially_spec.rb +41 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/config.yml +3 -0
- metadata +202 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
|
5
|
+
let(:original) { { drink: :more, new: :republic, its: :great } }
|
6
|
+
let(:expected) { { drink: :more, new: :republic } }
|
7
|
+
|
8
|
+
it 'responds to #slice' do
|
9
|
+
subject.should respond_to(:slice)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
it 'slices' do
|
14
|
+
original.slice(*expected.keys).should eq expected
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NRB::HTTPService::Response do
|
4
|
+
|
5
|
+
let(:body) { { 'llama' => 'Drink New Republic Beer' } }
|
6
|
+
let(:headers) { { stupid: :llama } }
|
7
|
+
let(:response) { NRB::HTTPService::Response.new body: body, headers: headers, status: status }
|
8
|
+
let(:status) { 200 }
|
9
|
+
|
10
|
+
|
11
|
+
context 'successful requests' do
|
12
|
+
let(:status) { 200 }
|
13
|
+
|
14
|
+
it 'correctly answers errored?' do
|
15
|
+
response.should_not be_errored
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'correctly answers success?' do
|
19
|
+
response.should be_success
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
context 'failed requests' do
|
26
|
+
let(:status) { 900 }
|
27
|
+
|
28
|
+
it 'correctly answers errored?' do
|
29
|
+
response.should be_errored
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'correctly answers success?' do
|
33
|
+
response.should_not be_success
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NRB::HTTPService do
|
4
|
+
|
5
|
+
describe 'class methods' do
|
6
|
+
|
7
|
+
it 'has a default middleware' do
|
8
|
+
NRB::HTTPService.default_middleware.should be_a(Proc)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has a default response class' do
|
12
|
+
NRB::HTTPService.default_response_class.should eq NRB::HTTPService::Response
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'making requests' do
|
18
|
+
|
19
|
+
let(:args) { {} }
|
20
|
+
let(:body) { {} }
|
21
|
+
let(:connection) { stub "here's a beer", verb => connection_response }
|
22
|
+
let(:connection_response) { double "skal", body: body, headers: headers, status: status }
|
23
|
+
let(:headers) { {} }
|
24
|
+
let(:path) { '/' }
|
25
|
+
let(:response) { NRB::HTTPService.new(path: path, verb: verb).make_request }
|
26
|
+
let(:status) { 200 }
|
27
|
+
let(:verb) { :get }
|
28
|
+
|
29
|
+
context 'successful requests' do
|
30
|
+
|
31
|
+
before do
|
32
|
+
Faraday.stub(:new).and_return(connection)
|
33
|
+
end
|
34
|
+
it 'returns a Response object' do
|
35
|
+
response.should be_a(NRB::HTTPService.default_response_class)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'resuces with an successful Response object' do
|
39
|
+
response.should be_success
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
context 'parse errors' do
|
46
|
+
|
47
|
+
let(:error) { Faraday::Error::ParsingError.new(message) }
|
48
|
+
let(:message) { "!Blark!" }
|
49
|
+
|
50
|
+
before do
|
51
|
+
Faraday.stub(:new).and_raise(error)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'resuces with a Response object' do
|
55
|
+
response.should be_a(NRB::HTTPService.default_response_class)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'resuces with an errored Response object' do
|
59
|
+
response.should be_errored
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'gives you the error' do
|
63
|
+
response.body[:error].should eq message
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NRB::Untappd do
|
4
|
+
|
5
|
+
it 'has a http_service accessor' do
|
6
|
+
subject.should respond_to(:http_service=)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
it 'has a default http_service' do
|
11
|
+
subject.http_service.should == NRB::HTTPService
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
let(:filename) { NRB::Untappd.config_file_path '../spec/support/config.yml' }
|
16
|
+
|
17
|
+
it 'loads a config resource' do
|
18
|
+
subject.load_config(filename: filename).should be_a(NRB::Untappd::Config)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
describe 'config file location' do
|
23
|
+
|
24
|
+
let(:absolute_path) { '/llama' }
|
25
|
+
let(:basedir) { File.expand_path( File.join( File.dirname(__FILE__), '..', '..', 'config' ) ) }
|
26
|
+
let(:relative_path) { 'llama' }
|
27
|
+
let(:expected_from_relative) { File.join( basedir, relative_path ) }
|
28
|
+
|
29
|
+
|
30
|
+
it 'returns an absolute path' do
|
31
|
+
subject.config_file_path(absolute_path).should eq absolute_path
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
it 'finds the config directory' do
|
36
|
+
subject.config_file_path(relative_path).should eq expected_from_relative
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drink-socially
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dean Brundage
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: faraday_middleware-parse_oj
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: hashie
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: guard-rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rb-inotify
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: See summary
|
127
|
+
email:
|
128
|
+
- dean@newrepublicbrewing.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- LICENSE
|
134
|
+
- README.md
|
135
|
+
- config/endpoints.yml
|
136
|
+
- lib/drink-socially.rb
|
137
|
+
- lib/drink-socially/api.rb
|
138
|
+
- lib/drink-socially/api/credential.rb
|
139
|
+
- lib/drink-socially/api/notification.rb
|
140
|
+
- lib/drink-socially/api/object.rb
|
141
|
+
- lib/drink-socially/api/pagination.rb
|
142
|
+
- lib/drink-socially/api/rate_limit.rb
|
143
|
+
- lib/drink-socially/api/url_tokenizer.rb
|
144
|
+
- lib/drink-socially/config.rb
|
145
|
+
- lib/drink-socially/extensions/hash.rb
|
146
|
+
- lib/drink-socially/http_service.rb
|
147
|
+
- lib/drink-socially/http_service/response.rb
|
148
|
+
- lib/drink-socially/version.rb
|
149
|
+
- spec/cases/drink-socially/api/credential_spec.rb
|
150
|
+
- spec/cases/drink-socially/api/object_spec.rb
|
151
|
+
- spec/cases/drink-socially/api/pagination_spec.rb
|
152
|
+
- spec/cases/drink-socially/api/rate_limit_spec.rb
|
153
|
+
- spec/cases/drink-socially/api/url_tokenizer_spec.rb
|
154
|
+
- spec/cases/drink-socially/api_spec.rb
|
155
|
+
- spec/cases/drink-socially/config_spec.rb
|
156
|
+
- spec/cases/drink-socially/extensions/hash_spec.rb
|
157
|
+
- spec/cases/drink-socially/http_service/response_spec.rb
|
158
|
+
- spec/cases/drink-socially/http_service_spec.rb
|
159
|
+
- spec/cases/drink-socially/version_spec.rb
|
160
|
+
- spec/cases/drink-socially_spec.rb
|
161
|
+
- spec/spec_helper.rb
|
162
|
+
- spec/support/config.yml
|
163
|
+
homepage: https://github.com/NewRepublicBrewing/drink-socially
|
164
|
+
licenses: []
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
171
|
+
requirements:
|
172
|
+
- - ! '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ! '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
requirements: []
|
182
|
+
rubyforge_project: drink-socially
|
183
|
+
rubygems_version: 1.8.24
|
184
|
+
signing_key:
|
185
|
+
specification_version: 3
|
186
|
+
summary: A gem for interfacing with the Untappd API
|
187
|
+
test_files:
|
188
|
+
- spec/cases/drink-socially/api/credential_spec.rb
|
189
|
+
- spec/cases/drink-socially/api/object_spec.rb
|
190
|
+
- spec/cases/drink-socially/api/pagination_spec.rb
|
191
|
+
- spec/cases/drink-socially/api/rate_limit_spec.rb
|
192
|
+
- spec/cases/drink-socially/api/url_tokenizer_spec.rb
|
193
|
+
- spec/cases/drink-socially/api_spec.rb
|
194
|
+
- spec/cases/drink-socially/config_spec.rb
|
195
|
+
- spec/cases/drink-socially/extensions/hash_spec.rb
|
196
|
+
- spec/cases/drink-socially/http_service/response_spec.rb
|
197
|
+
- spec/cases/drink-socially/http_service_spec.rb
|
198
|
+
- spec/cases/drink-socially/version_spec.rb
|
199
|
+
- spec/cases/drink-socially_spec.rb
|
200
|
+
- spec/spec_helper.rb
|
201
|
+
- spec/support/config.yml
|
202
|
+
has_rdoc:
|