groupme-api 0.8.0 → 0.9.4

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
  SHA256:
3
- metadata.gz: 45706e3b8b02eb4fc94fbe74fbe5ca764564f8b4712439afb3b86f144f33caf5
4
- data.tar.gz: 378805ff35b304e5cf2b8a55bab2068533079c860b8c0d447577011d4028c9f1
3
+ metadata.gz: f4746ac563db82f71e7c28e8f109a9a2df8b8b5592736029663eb016ea842e65
4
+ data.tar.gz: 848166d7fe344eb4fbe5f8d9d84262292653330af4a421b905c6e2cd2ad8eb75
5
5
  SHA512:
6
- metadata.gz: 596ea2cf189d34391cc962e3a2a450a212a8cc6e55bf7c73d7beab88f1698215ef0c12caeee6dc51225b0176396c9ded3a324c321d73448d9017dba353a8ec57
7
- data.tar.gz: 3ccb565dc625e11ada59bc68a06f815987d63af62ccd03201c7d3d1cb976ae557118a71d737a6df718604c12bf30d516e2f74f69a20c2016fe0435c83dd6e457
6
+ metadata.gz: f7792f6fe8243aedd8be71db447ce7a20b94d051e1d97737873af67589776ff15dd094c9f141416dbf5581dd39807791b69f8dba38573b873a593a05c0fd8da7
7
+ data.tar.gz: 60fe231fad7663f3ab79f44945b10d0d88e9a4caa2cf1b188e010b99a9a2bdd2c451750805ab84d9faae9cb27951eba1d8a459e4f95ae85c9de32b33244d73d0
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # GroupMe Ruby Gem (BETA)
2
2
  [![Build Status](https://travis-ci.org/kinnell/groupme-ruby-gem.svg?branch=master)](https://travis-ci.org/kinnell/groupme-ruby-gem)
3
3
  [![Coverage Status](https://coveralls.io/repos/github/kinnell/groupme-ruby-gem/badge.svg?branch=master)](https://coveralls.io/github/kinnell/groupme-ruby-gem?branch=master)
4
+ [![Known Vulnerabilities](https://snyk.io/test/github/kinnell/groupme-ruby-gem/badge.svg?targetFile=Gemfile.lock)](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
 
@@ -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
- unless blank?(response.body)
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
@@ -13,19 +13,23 @@ module GroupMe
13
13
  end
14
14
 
15
15
  def groups_per_page
16
- @groups_per_page || API_MAX_GROUPS_PER_PAGE
16
+ @groups_per_page ||= API_MAX_GROUPS_PER_PAGE
17
17
  end
18
18
  end
19
19
 
20
- def self.configuration
21
- @configuration ||= Configuration.new
20
+ def self.configure
21
+ yield(configuration)
22
+ end
23
+
24
+ def self.reset_configuration!
25
+ @configuration = Configuration.new
22
26
  end
23
27
 
24
28
  def self.configuration=(configuration)
25
29
  @configuration = configuration
26
30
  end
27
31
 
28
- def self.configure
29
- yield(configuration)
32
+ def self.configuration
33
+ @configuration ||= Configuration.new
30
34
  end
31
35
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GroupMe
4
+ module Core
5
+ def self.root
6
+ Pathname.new(__dir__)
7
+ end
8
+ end
9
+
10
+ extend Core
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GroupMe
4
- VERSION = '0.8.0'
4
+ VERSION = '0.9.4'
5
5
  end
data/lib/groupme-api.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'groupme'
3
+ require_relative 'groupme'
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
- require 'groupme/client'
7
- require 'groupme/configuration'
8
- require 'groupme/errors'
9
- require 'groupme/group'
10
- require 'groupme/image_client'
11
- require 'groupme/version'
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_api.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'groupme'
3
+ require_relative 'groupme'
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.8.0
4
+ version: 0.9.4
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-04-03 00:00:00.000000000 Z
11
+ date: 2021-11-22 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,10 +214,9 @@ 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
- rubyforge_project:
196
- rubygems_version: 2.7.6
219
+ rubygems_version: 3.1.6
197
220
  signing_key:
198
221
  specification_version: 4
199
222
  summary: GroupMe
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,11 +0,0 @@
1
- Documentation:
2
- Enabled: false
3
-
4
- Metrics/BlockLength:
5
- Enabled: false
6
-
7
- Metrics/LineLength:
8
- Enabled: false
9
-
10
- Style/BracesAroundHashParameters:
11
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.5.3
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.0
7
- before_install: gem install bundler -v 1.16.3
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
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- guard :rspec, cmd: 'bundle exec rspec' do
4
- watch(%r{^spec/.+_spec\.rb$})
5
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6
- watch('spec/spec_helper.rb') { 'spec' }
7
- watch(%r{^spec/support/(.+)$}) { 'spec' }
8
- end
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
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
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
@@ -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
@@ -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
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe GroupMe do
6
- it 'has a version number' do
7
- expect(GroupMe::VERSION).not_to be nil
8
- end
9
- end
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
@@ -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
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'webmock/rspec'
4
-
5
- WebMock.enable!