bps-google-api 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bps-google-api.gemspec +1 -1
- data/lib/google_api.rb +4 -4
- data/lib/google_api/base.rb +7 -1
- data/lib/google_api/calendar.rb +1 -1
- data/lib/google_api/calendar/clear_test_calendar.rb +0 -5
- data/lib/google_api/group.rb +1 -1
- data/spec/lib/google_api/calendar_spec.rb +18 -0
- data/spec/lib/google_api/group_spec.rb +12 -0
- data/spec/lib/google_api_spec.rb +4 -0
- data/spec/spec_helper.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de16bf3d1c0b8b9f1971b1bb77077ded52379e3502d667fb3ca168e74bf202aa
|
4
|
+
data.tar.gz: 9ef1b294632a591e4808a6d0456e346b2a29922bf0fb756905813586517d83af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a5a51dc5e75da452e7d548ad643997b9935ff8f535da11cb289e595deb2025c8bbbf15e77296f2053fd2b75a487af8a9d493ad45f28610e37d7f1b3263dffc3
|
7
|
+
data.tar.gz: 140eac17905e9b5396c79e39e7523192c3ce8616090328f893e0afe057e769dae71759a1fdcaac0a731939f485ab80868a662b2db9f48ef72d09658a2f6d2a1e
|
data/Gemfile.lock
CHANGED
data/bps-google-api.gemspec
CHANGED
data/lib/google_api.rb
CHANGED
@@ -29,11 +29,7 @@ require 'ext/hash' unless defined?(Rails)
|
|
29
29
|
require 'ext/silent_progress_bar'
|
30
30
|
|
31
31
|
class GoogleAPI
|
32
|
-
@@mock = false # Default to normal behavior
|
33
|
-
|
34
32
|
class << self
|
35
|
-
attr_reader :mock
|
36
|
-
|
37
33
|
def configuration
|
38
34
|
@configuration ||= GoogleAPI::Config.new
|
39
35
|
end
|
@@ -53,5 +49,9 @@ class GoogleAPI
|
|
53
49
|
def mock!(value = true)
|
54
50
|
@mock = value
|
55
51
|
end
|
52
|
+
|
53
|
+
def mock
|
54
|
+
@mock || false
|
55
|
+
end
|
56
56
|
end
|
57
57
|
end
|
data/lib/google_api/base.rb
CHANGED
@@ -29,10 +29,16 @@ class GoogleAPI
|
|
29
29
|
|
30
30
|
def call(method, *args)
|
31
31
|
if GoogleAPI.mock
|
32
|
-
|
32
|
+
send(:mock, method, *args)
|
33
33
|
else
|
34
34
|
ExpRetry.for(exception: RETRIES) { service.send(method, *args) }
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
# :nocov:
|
39
|
+
def mock(*)
|
40
|
+
raise 'This method must be overwritten by the inheriting class.'
|
41
|
+
end
|
42
|
+
# :nocov:
|
37
43
|
end
|
38
44
|
end
|
data/lib/google_api/calendar.rb
CHANGED
@@ -112,7 +112,7 @@ class GoogleAPI
|
|
112
112
|
Google::Apis::CalendarV3::EventDateTime.new(key => date, time_zone: ENV['TZ'])
|
113
113
|
end
|
114
114
|
|
115
|
-
def mock(
|
115
|
+
def mock(*)
|
116
116
|
Google::Apis::CalendarV3::Event.new(
|
117
117
|
id: SecureRandom.hex(8),
|
118
118
|
html_link: 'http://calendar.google.com',
|
data/lib/google_api/group.rb
CHANGED
@@ -34,7 +34,7 @@ class GoogleAPI
|
|
34
34
|
Google::Apis::AdminDirectoryV1::Member.new(email: email)
|
35
35
|
end
|
36
36
|
|
37
|
-
def mock(
|
37
|
+
def mock(*)
|
38
38
|
Google::Apis::AdminDirectoryV1::Members.new(
|
39
39
|
members: [
|
40
40
|
Google::Apis::AdminDirectoryV1::Member.new(email: 'nobody@example.com')
|
@@ -178,4 +178,22 @@ RSpec.describe GoogleAPI::Calendar do
|
|
178
178
|
expect(subject.add_conference(event.id)).to be_a(Google::Apis::CalendarV3::Event)
|
179
179
|
end
|
180
180
|
end
|
181
|
+
|
182
|
+
describe 'mock' do
|
183
|
+
subject { described_class.new }
|
184
|
+
|
185
|
+
before { GoogleAPI.mock! }
|
186
|
+
|
187
|
+
it 'calls the mock method' do
|
188
|
+
expect(subject).to receive(:mock).and_call_original
|
189
|
+
|
190
|
+
subject.create({})
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'calls the conference_mock method' do
|
194
|
+
expect(subject).to receive(:conference_mock).and_call_original
|
195
|
+
|
196
|
+
subject.conference_info('')
|
197
|
+
end
|
198
|
+
end
|
181
199
|
end
|
@@ -46,4 +46,16 @@ RSpec.describe GoogleAPI::Group do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
describe 'mock' do
|
51
|
+
subject { described_class.new }
|
52
|
+
|
53
|
+
before { GoogleAPI.mock! }
|
54
|
+
|
55
|
+
it 'calls the mock method' do
|
56
|
+
expect(subject).to receive(:mock).and_call_original
|
57
|
+
|
58
|
+
subject.members({})
|
59
|
+
end
|
60
|
+
end
|
49
61
|
end
|
data/spec/lib/google_api_spec.rb
CHANGED
@@ -12,4 +12,8 @@ RSpec.describe GoogleAPI do
|
|
12
12
|
it 'raises for invalid levels' do
|
13
13
|
expect { GoogleAPI.logging!(:WRONG) }.to raise_error(ArgumentError, 'Unknown level')
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'sets the mock flag' do
|
17
|
+
expect { GoogleAPI.mock! }.to change { GoogleAPI.mock }.from(false).to(true)
|
18
|
+
end
|
15
19
|
end
|
data/spec/spec_helper.rb
CHANGED