groupme-api 0.8.0 → 0.9.0
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 +4 -4
- data/README.md +1 -0
- data/lib/groupme-api.rb +1 -1
- data/lib/groupme.rb +8 -9
- data/lib/groupme/client.rb +11 -12
- data/lib/groupme/configuration.rb +11 -6
- data/lib/groupme/core.rb +13 -0
- data/lib/groupme/version.rb +1 -1
- data/lib/groupme_api.rb +1 -1
- metadata +46 -22
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.rubocop.yml +0 -11
- data/.ruby-version +0 -1
- data/.travis.yml +0 -7
- data/Gemfile.lock +0 -106
- data/Guardfile +0 -8
- data/LICENSE +0 -21
- data/Rakefile +0 -8
- data/groupme-api.gemspec +0 -34
- data/spec/groupme/client_spec.rb +0 -194
- data/spec/groupme/configuration_spec.rb +0 -59
- data/spec/groupme/group_spec.rb +0 -13
- data/spec/groupme/image_client_spec.rb +0 -16
- data/spec/groupme_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -17
- data/spec/support/groupme.rb +0 -20
- data/spec/support/vcr.rb +0 -11
- data/spec/support/webmock.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb7a0535d333c08f75da477d9803b1199a84936e7d2a42a18802621998f728be
|
4
|
+
data.tar.gz: a97d3a4949b1df1e5474df4d141e02dbc5da10bc9bcf8dc82c4e1111b4015daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25ac7d0a4a68222fc9955d5fe43cb97c535fbb74108e9244603eebfe321b2efc8219462a966d7a1a3535ae7e984ab527e95c3b80f7c9b6bcd60a4aa4fd09c1b1
|
7
|
+
data.tar.gz: 0ff06fe7215cd5d9a4e3684fd32eaf852f6fb4acc9b33cc0b39edddae0560d46a31044f98abc162603be466cfdc17b45cc003710b403e6b8b3ad3fb91724a2da
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# GroupMe Ruby Gem (BETA)
|
2
2
|
[](https://travis-ci.org/kinnell/groupme-ruby-gem)
|
3
3
|
[](https://coveralls.io/github/kinnell/groupme-ruby-gem?branch=master)
|
4
|
+
[](https://snyk.io/test/github/kinnell/groupme-ruby-gem?targetFile=Gemfile.lock)
|
4
5
|
|
5
6
|
A Ruby wrapper for [GroupMe REST API (v3)](https://dev.groupme.com/docs/v3).
|
6
7
|
|
data/lib/groupme-api.rb
CHANGED
data/lib/groupme.rb
CHANGED
@@ -2,16 +2,15 @@
|
|
2
2
|
|
3
3
|
require 'httpclient'
|
4
4
|
require 'json'
|
5
|
+
require 'pathname'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
require_relative 'groupme/core'
|
8
|
+
require_relative 'groupme/client'
|
9
|
+
require_relative 'groupme/configuration'
|
10
|
+
require_relative 'groupme/errors'
|
11
|
+
require_relative 'groupme/group'
|
12
|
+
require_relative 'groupme/image_client'
|
13
|
+
require_relative 'groupme/version'
|
12
14
|
|
13
15
|
module GroupMe
|
14
|
-
def self.reset!
|
15
|
-
@configuration = Configuration.new
|
16
|
-
end
|
17
16
|
end
|
data/lib/groupme/client.rb
CHANGED
@@ -12,11 +12,6 @@ module GroupMe
|
|
12
12
|
@client = HTTPClient.new(base_url: API_BASE_URL, default_header: API_DEFAULT_HEADER)
|
13
13
|
end
|
14
14
|
|
15
|
-
def request(method, path, query: {}, body: nil)
|
16
|
-
response = @client.request(method, path, { token: @access_token }.merge(query), body&.to_json)
|
17
|
-
[parse_response_body(response), response.status]
|
18
|
-
end
|
19
|
-
|
20
15
|
def get(path, query = {})
|
21
16
|
request(:get, path, query: query)
|
22
17
|
end
|
@@ -29,14 +24,18 @@ module GroupMe
|
|
29
24
|
request(:delete, path, query: query)
|
30
25
|
end
|
31
26
|
|
27
|
+
def request(method, path, query: {}, body: nil)
|
28
|
+
response = @client.request(method, path, { token: @access_token }.merge(query), body&.to_json)
|
29
|
+
[parse_response_body(response), response.status]
|
30
|
+
end
|
31
|
+
|
32
32
|
private
|
33
33
|
|
34
34
|
def parse_response_body(response)
|
35
35
|
return response.reason unless response.ok?
|
36
|
+
return if blank?(response.body)
|
36
37
|
|
37
|
-
|
38
|
-
JSON.parse(response.body, symbolize_names: true).fetch(:response)
|
39
|
-
end
|
38
|
+
JSON.parse(response.body, symbolize_names: true).fetch(:response)
|
40
39
|
end
|
41
40
|
|
42
41
|
def blank?(string)
|
@@ -44,11 +43,11 @@ module GroupMe
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
def self.client
|
48
|
-
@client ||= Client.new
|
49
|
-
end
|
50
|
-
|
51
46
|
def self.client=(client)
|
52
47
|
@client = client
|
53
48
|
end
|
49
|
+
|
50
|
+
def self.client
|
51
|
+
@client ||= Client.new
|
52
|
+
end
|
54
53
|
end
|
@@ -4,7 +4,8 @@ module GroupMe
|
|
4
4
|
class Configuration
|
5
5
|
API_MAX_GROUPS_PER_PAGE = 500
|
6
6
|
|
7
|
-
attr_writer :access_token
|
7
|
+
attr_writer :access_token
|
8
|
+
attr_writer :groups_per_page
|
8
9
|
|
9
10
|
def access_token
|
10
11
|
raise MissingConfigurationError unless @access_token
|
@@ -13,19 +14,23 @@ module GroupMe
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def groups_per_page
|
16
|
-
@groups_per_page
|
17
|
+
@groups_per_page ||= API_MAX_GROUPS_PER_PAGE
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
def self.
|
21
|
-
|
21
|
+
def self.configure
|
22
|
+
yield(configuration)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.reset_configuration!
|
26
|
+
@configuration = Configuration.new
|
22
27
|
end
|
23
28
|
|
24
29
|
def self.configuration=(configuration)
|
25
30
|
@configuration = configuration
|
26
31
|
end
|
27
32
|
|
28
|
-
def self.
|
29
|
-
|
33
|
+
def self.configuration
|
34
|
+
@configuration ||= Configuration.new
|
30
35
|
end
|
31
36
|
end
|
data/lib/groupme/core.rb
ADDED
data/lib/groupme/version.rb
CHANGED
data/lib/groupme_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupme-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kinnell Shah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: coveralls
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,20 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.16'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.16'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: guard-rspec
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +94,20 @@ dependencies:
|
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '4.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
69
111
|
- !ruby/object:Gem::Dependency
|
70
112
|
name: rake
|
71
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,36 +185,18 @@ executables: []
|
|
143
185
|
extensions: []
|
144
186
|
extra_rdoc_files: []
|
145
187
|
files:
|
146
|
-
- ".gitignore"
|
147
|
-
- ".rspec"
|
148
|
-
- ".rubocop.yml"
|
149
|
-
- ".ruby-version"
|
150
|
-
- ".travis.yml"
|
151
188
|
- Gemfile
|
152
|
-
- Gemfile.lock
|
153
|
-
- Guardfile
|
154
|
-
- LICENSE
|
155
189
|
- README.md
|
156
|
-
- Rakefile
|
157
|
-
- groupme-api.gemspec
|
158
190
|
- lib/groupme-api.rb
|
159
191
|
- lib/groupme.rb
|
160
192
|
- lib/groupme/client.rb
|
161
193
|
- lib/groupme/configuration.rb
|
194
|
+
- lib/groupme/core.rb
|
162
195
|
- lib/groupme/errors.rb
|
163
196
|
- lib/groupme/group.rb
|
164
197
|
- lib/groupme/image_client.rb
|
165
198
|
- lib/groupme/version.rb
|
166
199
|
- lib/groupme_api.rb
|
167
|
-
- spec/groupme/client_spec.rb
|
168
|
-
- spec/groupme/configuration_spec.rb
|
169
|
-
- spec/groupme/group_spec.rb
|
170
|
-
- spec/groupme/image_client_spec.rb
|
171
|
-
- spec/groupme_spec.rb
|
172
|
-
- spec/spec_helper.rb
|
173
|
-
- spec/support/groupme.rb
|
174
|
-
- spec/support/vcr.rb
|
175
|
-
- spec/support/webmock.rb
|
176
200
|
homepage: https://github.com/kinnell/groupme-ruby-gem
|
177
201
|
licenses:
|
178
202
|
- MIT
|
@@ -190,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
214
|
requirements:
|
191
215
|
- - ">="
|
192
216
|
- !ruby/object:Gem::Version
|
193
|
-
version: '0'
|
217
|
+
version: '2.0'
|
194
218
|
requirements: []
|
195
219
|
rubyforge_project:
|
196
220
|
rubygems_version: 2.7.6
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.3
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
groupme-api (0.8.0)
|
5
|
-
httpclient (~> 2.8)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
addressable (2.7.0)
|
11
|
-
public_suffix (>= 2.0.2, < 5.0)
|
12
|
-
coderay (1.1.2)
|
13
|
-
coveralls (0.8.23)
|
14
|
-
json (>= 1.8, < 3)
|
15
|
-
simplecov (~> 0.16.1)
|
16
|
-
term-ansicolor (~> 1.3)
|
17
|
-
thor (>= 0.19.4, < 2.0)
|
18
|
-
tins (~> 1.6)
|
19
|
-
crack (0.4.3)
|
20
|
-
safe_yaml (~> 1.0.0)
|
21
|
-
diff-lcs (1.3)
|
22
|
-
docile (1.3.2)
|
23
|
-
ffi (1.12.2)
|
24
|
-
formatador (0.2.5)
|
25
|
-
guard (2.16.2)
|
26
|
-
formatador (>= 0.2.4)
|
27
|
-
listen (>= 2.7, < 4.0)
|
28
|
-
lumberjack (>= 1.0.12, < 2.0)
|
29
|
-
nenv (~> 0.1)
|
30
|
-
notiffany (~> 0.0)
|
31
|
-
pry (>= 0.9.12)
|
32
|
-
shellany (~> 0.0)
|
33
|
-
thor (>= 0.18.1)
|
34
|
-
guard-compat (1.2.1)
|
35
|
-
guard-rspec (4.7.3)
|
36
|
-
guard (~> 2.1)
|
37
|
-
guard-compat (~> 1.1)
|
38
|
-
rspec (>= 2.99.0, < 4.0)
|
39
|
-
hashdiff (1.0.1)
|
40
|
-
httpclient (2.8.3)
|
41
|
-
json (2.3.0)
|
42
|
-
listen (3.2.1)
|
43
|
-
rb-fsevent (~> 0.10, >= 0.10.3)
|
44
|
-
rb-inotify (~> 0.9, >= 0.9.10)
|
45
|
-
lumberjack (1.2.4)
|
46
|
-
method_source (1.0.0)
|
47
|
-
nenv (0.3.0)
|
48
|
-
notiffany (0.1.3)
|
49
|
-
nenv (~> 0.1)
|
50
|
-
shellany (~> 0.0)
|
51
|
-
pry (0.13.0)
|
52
|
-
coderay (~> 1.1)
|
53
|
-
method_source (~> 1.0)
|
54
|
-
public_suffix (4.0.3)
|
55
|
-
rake (13.0.1)
|
56
|
-
rb-fsevent (0.10.3)
|
57
|
-
rb-inotify (0.10.1)
|
58
|
-
ffi (~> 1.0)
|
59
|
-
rspec (3.9.0)
|
60
|
-
rspec-core (~> 3.9.0)
|
61
|
-
rspec-expectations (~> 3.9.0)
|
62
|
-
rspec-mocks (~> 3.9.0)
|
63
|
-
rspec-core (3.9.1)
|
64
|
-
rspec-support (~> 3.9.1)
|
65
|
-
rspec-expectations (3.9.1)
|
66
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.9.0)
|
68
|
-
rspec-mocks (3.9.1)
|
69
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
-
rspec-support (~> 3.9.0)
|
71
|
-
rspec-support (3.9.2)
|
72
|
-
safe_yaml (1.0.5)
|
73
|
-
shellany (0.0.1)
|
74
|
-
simplecov (0.16.1)
|
75
|
-
docile (~> 1.1)
|
76
|
-
json (>= 1.8, < 3)
|
77
|
-
simplecov-html (~> 0.10.0)
|
78
|
-
simplecov-html (0.10.2)
|
79
|
-
sync (0.5.0)
|
80
|
-
term-ansicolor (1.7.1)
|
81
|
-
tins (~> 1.0)
|
82
|
-
thor (1.0.1)
|
83
|
-
tins (1.24.1)
|
84
|
-
sync
|
85
|
-
vcr (5.1.0)
|
86
|
-
webmock (3.8.3)
|
87
|
-
addressable (>= 2.3.6)
|
88
|
-
crack (>= 0.3.2)
|
89
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
90
|
-
|
91
|
-
PLATFORMS
|
92
|
-
ruby
|
93
|
-
|
94
|
-
DEPENDENCIES
|
95
|
-
bundler (~> 2.1)
|
96
|
-
coveralls (~> 0.8)
|
97
|
-
groupme-api!
|
98
|
-
guard-rspec (~> 4.7)
|
99
|
-
rake (~> 13.0)
|
100
|
-
rspec (~> 3.9)
|
101
|
-
simplecov (~> 0.16)
|
102
|
-
vcr (~> 5.0)
|
103
|
-
webmock (~> 3.8)
|
104
|
-
|
105
|
-
BUNDLED WITH
|
106
|
-
2.1.4
|
data/Guardfile
DELETED
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2018 Kinnell Shah
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
data/Rakefile
DELETED
data/groupme-api.gemspec
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
|
6
|
-
require 'groupme/version'
|
7
|
-
|
8
|
-
Gem::Specification.new do |spec|
|
9
|
-
spec.name = 'groupme-api'
|
10
|
-
spec.version = GroupMe::VERSION
|
11
|
-
spec.platform = Gem::Platform::RUBY
|
12
|
-
spec.authors = ['Kinnell Shah']
|
13
|
-
spec.email = ['kinnell@gmail.com']
|
14
|
-
|
15
|
-
spec.summary = 'GroupMe'
|
16
|
-
spec.description = 'A Ruby wrapper for GroupMe REST API (v3)'
|
17
|
-
spec.homepage = 'https://github.com/kinnell/groupme-ruby-gem'
|
18
|
-
spec.license = 'MIT'
|
19
|
-
|
20
|
-
spec.files = `git ls-files`.split("\n")
|
21
|
-
spec.require_paths = ['lib']
|
22
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
23
|
-
|
24
|
-
spec.add_dependency 'httpclient', '~> 2.8'
|
25
|
-
|
26
|
-
spec.add_development_dependency 'bundler', '~> 2.1'
|
27
|
-
spec.add_development_dependency 'coveralls', '~> 0.8'
|
28
|
-
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
29
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
30
|
-
spec.add_development_dependency 'rspec', '~> 3.9'
|
31
|
-
spec.add_development_dependency 'simplecov', '~> 0.16'
|
32
|
-
spec.add_development_dependency 'vcr', '~> 5.0'
|
33
|
-
spec.add_development_dependency 'webmock', '~> 3.8'
|
34
|
-
end
|
data/spec/groupme/client_spec.rb
DELETED
@@ -1,194 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe GroupMe::Client do
|
4
|
-
include_context :with_default_groupme_configuration
|
5
|
-
|
6
|
-
let(:client) { GroupMe::Client.new(access_token: access_token) }
|
7
|
-
let(:base_url) { GroupMe::Client::API_BASE_URL }
|
8
|
-
|
9
|
-
describe '.new' do
|
10
|
-
context 'when :access_token is not supplied' do
|
11
|
-
let(:client) { GroupMe::Client.new }
|
12
|
-
|
13
|
-
it 'should use configured :access_token' do
|
14
|
-
expect(client.access_token).to eq(GroupMe.configuration.access_token)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when :access_token is supplied' do
|
19
|
-
let(:client) { GroupMe::Client.new(access_token: new_access_token) }
|
20
|
-
|
21
|
-
it 'should not use configured :access_token' do
|
22
|
-
expect(client.access_token).not_to eq(GroupMe.configuration.access_token)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should use the supplied :access_token' do
|
26
|
-
expect(client.access_token).to eq(new_access_token)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#request' do
|
32
|
-
let(:stubbed_data) { { id: 1, name: 'Group' } }
|
33
|
-
let(:stubbed_response_body) { { response: stubbed_data }.to_json }
|
34
|
-
let(:stubbed_response_status) { 200 }
|
35
|
-
|
36
|
-
before do
|
37
|
-
stub_request(:any, /api.groupme.com/).to_return(
|
38
|
-
body: stubbed_response_body,
|
39
|
-
status: stubbed_response_status
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when no parameters are supplied' do
|
44
|
-
it 'should send the correct HTTP request' do
|
45
|
-
client.request(:get, 'groups')
|
46
|
-
|
47
|
-
expect(WebMock).to have_requested(:get, "#{base_url}groups").with(query: { token: access_token })
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when query parameters are supplied' do
|
52
|
-
it 'should send the correct HTTP request' do
|
53
|
-
client.request(:get, 'groups', query: { per_page: 1 })
|
54
|
-
|
55
|
-
expect(WebMock).to have_requested(:get, "#{base_url}groups").with(query: { token: access_token, per_page: 1 })
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when body parameters are supplied' do
|
60
|
-
it 'should send the correct HTTP request' do
|
61
|
-
client.request(:post, 'groups', body: { name: 'Group' })
|
62
|
-
|
63
|
-
expect(WebMock).to have_requested(:post, "#{base_url}groups?token=#{access_token}").with(body: { name: 'Group' }.to_json)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when the response is successful' do
|
68
|
-
let(:stubbed_response_body) { { response: stubbed_data }.to_json }
|
69
|
-
let(:stubbed_response_status) { 201 }
|
70
|
-
|
71
|
-
it 'should parse and return the response' do
|
72
|
-
response, _status = client.request(:post, 'groups')
|
73
|
-
|
74
|
-
expect(response).to eq(stubbed_data)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should return the successful status code' do
|
78
|
-
_response, status = client.request(:post, 'groups')
|
79
|
-
|
80
|
-
expect(status).to eq(201)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'when the response is unsuccessful' do
|
85
|
-
let(:stubbed_response_body) { '' }
|
86
|
-
let(:stubbed_response_status) { [404, 'Not Found'] }
|
87
|
-
|
88
|
-
it 'should return the response reason' do
|
89
|
-
response, _status = client.request(:post, 'groups')
|
90
|
-
|
91
|
-
expect(response).to eq('Not Found')
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'should return the unsuccesful status code' do
|
95
|
-
_response, status = client.request(:post, 'groups')
|
96
|
-
|
97
|
-
expect(status).to eq(404)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#get' do
|
103
|
-
let(:stubbed_data) { { id: 1, name: 'Group' } }
|
104
|
-
let(:stubbed_response_code) { 200 }
|
105
|
-
|
106
|
-
before do
|
107
|
-
stub_request(:get, /api.groupme.com/).to_return(
|
108
|
-
body: { response: stubbed_data }.to_json,
|
109
|
-
status: stubbed_response_code
|
110
|
-
)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should parse and return the response' do
|
114
|
-
response, _status = client.get('groups', per_page: 1)
|
115
|
-
|
116
|
-
expect(response).to eq(stubbed_data)
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'should return the status code' do
|
120
|
-
_response, status = client.get('groups', per_page: 1)
|
121
|
-
|
122
|
-
expect(status).to eq(stubbed_response_code)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe '#post' do
|
127
|
-
let(:stubbed_data) { { id: 1, name: 'Group' } }
|
128
|
-
let(:stubbed_response_code) { 200 }
|
129
|
-
|
130
|
-
before do
|
131
|
-
stub_request(:post, /api.groupme.com/).to_return(
|
132
|
-
body: { response: stubbed_data }.to_json,
|
133
|
-
status: stubbed_response_code
|
134
|
-
)
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'should parse and return the response' do
|
138
|
-
response, _status = client.post('groups', name: 'Group')
|
139
|
-
|
140
|
-
expect(response).to eq(stubbed_data)
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'should return the status code' do
|
144
|
-
_response, status = client.post('groups', name: 'Group')
|
145
|
-
|
146
|
-
expect(status).to eq(stubbed_response_code)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe '#delete' do
|
151
|
-
let(:stubbed_data) { 'OK' }
|
152
|
-
let(:stubbed_response_code) { 200 }
|
153
|
-
|
154
|
-
before do
|
155
|
-
stub_request(:delete, /api.groupme.com/).to_return(
|
156
|
-
body: { response: stubbed_data }.to_json,
|
157
|
-
status: stubbed_response_code
|
158
|
-
)
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'should parse and return the response' do
|
162
|
-
response, _status = client.delete('groups', id: 1)
|
163
|
-
|
164
|
-
expect(response).to eq(stubbed_data)
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'should return the status code' do
|
168
|
-
_response, status = client.delete('groups', id: 1)
|
169
|
-
|
170
|
-
expect(status).to eq(stubbed_response_code)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
RSpec.describe GroupMe do
|
176
|
-
include_context :with_default_groupme_configuration
|
177
|
-
|
178
|
-
describe '.client' do
|
179
|
-
it 'should return a GroupMe::Client object' do
|
180
|
-
expect(GroupMe.client).to be_a_instance_of(GroupMe::Client)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe '.client=' do
|
185
|
-
it 'should set a new default client' do
|
186
|
-
old_client = GroupMe.client
|
187
|
-
new_client = GroupMe::Client.new
|
188
|
-
GroupMe.client = new_client
|
189
|
-
|
190
|
-
expect(GroupMe.client).not_to eq(old_client)
|
191
|
-
expect(GroupMe.client).to eq(new_client)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe GroupMe::Configuration do
|
6
|
-
before(:each) { GroupMe.reset! }
|
7
|
-
|
8
|
-
describe '#access_token' do
|
9
|
-
context 'when :access_token is not configured' do
|
10
|
-
it 'should raise an error' do
|
11
|
-
expect { GroupMe.configuration.access_token }.to raise_error(GroupMe::MissingConfigurationError)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'when :access_token is configured' do
|
16
|
-
include_context :with_default_groupme_configuration
|
17
|
-
|
18
|
-
it 'should return the access_token' do
|
19
|
-
expect(GroupMe.configuration.access_token).to eq(access_token)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
RSpec.describe GroupMe do
|
26
|
-
describe '.configuration' do
|
27
|
-
it 'should return a GroupMe::Configuration object' do
|
28
|
-
expect(GroupMe.configuration).to be_an_instance_of(GroupMe::Configuration)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '.configuration=' do
|
33
|
-
it 'should set a new default configuration' do
|
34
|
-
old_configuration = GroupMe.configuration
|
35
|
-
new_configuration = GroupMe::Configuration.new
|
36
|
-
GroupMe.configuration = new_configuration
|
37
|
-
|
38
|
-
expect(GroupMe.configuration).not_to eq(old_configuration)
|
39
|
-
expect(GroupMe.configuration).to eq(new_configuration)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'configure' do
|
44
|
-
it 'should set configuration attributes' do
|
45
|
-
GroupMe.configure { |config| config.access_token = access_token }
|
46
|
-
|
47
|
-
expect(GroupMe.configuration.access_token).to eq(access_token)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'reset!' do
|
52
|
-
it 'should reset the configuration' do
|
53
|
-
old_configuration = GroupMe.configuration
|
54
|
-
GroupMe.reset!
|
55
|
-
|
56
|
-
expect(GroupMe.configuration).not_to eq(old_configuration)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/spec/groupme/group_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe GroupMe::Group do
|
4
|
-
include_context :with_default_groupme_configuration
|
5
|
-
|
6
|
-
describe '#all' do
|
7
|
-
it 'should send the correct HTTP request' do
|
8
|
-
_groups = GroupMe::Group.all
|
9
|
-
|
10
|
-
expect(WebMock).to have_requested(:get, 'https://api.groupme.com/v3/groups').with(query: { token: access_token, omit: :memberships, per_page: GroupMe.configuration.groups_per_page })
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe GroupMe::ImageClient do
|
4
|
-
include_context :with_default_groupme_configuration
|
5
|
-
|
6
|
-
let(:image_blob) { '\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\b\x03\x00\x00\x00(\xCB4\xBB\x00\x00\x00\x03PLTE\xDD.DX\x9D\x17\x1C\x00\x00\x00\x01tRNS\xD8\xC8\xEE\x82\x80\x00\x00\x00\nIDATx\x01c`\x00\x00\x00\x02\x00\x01su\x01\x18\x00\x00\x00\x00IEND\xAEB`\x82' }
|
7
|
-
|
8
|
-
describe '#new' do
|
9
|
-
it 'should send the correct HTTP request' do
|
10
|
-
_image_client = GroupMe::ImageClient.new
|
11
|
-
_image_client.upload(image_blob)
|
12
|
-
|
13
|
-
expect(WebMock).to have_requested(:post, 'https://image.groupme.com/pictures').with(body: image_blob)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/spec/groupme_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'simplecov'
|
4
|
-
require 'coveralls'
|
5
|
-
|
6
|
-
SimpleCov.start
|
7
|
-
Coveralls.wear!
|
8
|
-
|
9
|
-
require 'groupme'
|
10
|
-
|
11
|
-
require 'support/groupme'
|
12
|
-
require 'support/vcr'
|
13
|
-
require 'support/webmock'
|
14
|
-
|
15
|
-
RSpec.configure do |config|
|
16
|
-
config.filter_run_when_matching :focus
|
17
|
-
end
|
data/spec/support/groupme.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'securerandom'
|
4
|
-
|
5
|
-
RSpec.shared_context :with_defined_access_token do
|
6
|
-
let(:access_token) { 'cQOvtsbxn7mHCS6yRimKuKHwXCGtqRwcU4E4NToe' }
|
7
|
-
let(:new_access_token) { SecureRandom.base64(30).tr('+', '0') }
|
8
|
-
end
|
9
|
-
|
10
|
-
RSpec.shared_context :with_default_groupme_configuration do
|
11
|
-
before(:each) do
|
12
|
-
GroupMe.configure do |config|
|
13
|
-
config.access_token = 'cQOvtsbxn7mHCS6yRimKuKHwXCGtqRwcU4E4NToe'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
RSpec.configure do |config|
|
19
|
-
config.include_context :with_defined_access_token
|
20
|
-
end
|
data/spec/support/vcr.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'vcr'
|
4
|
-
|
5
|
-
VCR.configure do |config|
|
6
|
-
config.hook_into :webmock
|
7
|
-
config.allow_http_connections_when_no_cassette = true
|
8
|
-
config.cassette_library_dir = 'spec/fixtures'
|
9
|
-
config.default_cassette_options = { record: :new_episodes }
|
10
|
-
config.filter_sensitive_data('ACCESS_TOKEN') { ACCESS_TOKEN }
|
11
|
-
end
|