play_time 0.0.3 → 0.1.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: 52263d955063ada0381b1f92eb4f3eb888e9b09a
4
- data.tar.gz: a4a5c66750eeba46e127b1a16813fb3935873559
3
+ metadata.gz: e23c57d7102a28cbe8b3554651891b0a5b6bff67
4
+ data.tar.gz: 813f6b865d38e05b6998991d307c8fa8c973a0e6
5
5
  SHA512:
6
- metadata.gz: 416e3bbdbde16698f213f275b444181ca7e5ccbb448bb6f51de1fe026d87acc436da08573ce16df454d001ea2a6bc3ca405e5f4af51f6110f704363cfe28aa73
7
- data.tar.gz: c8a5867c0c328306ee31d97a5d2f555e82bc85946d4ba10c3d72e79ebe6046ef13c7e2a125748a49a982af22242a33affd816da19bad15854cd51678b677f736
6
+ metadata.gz: 90cd9ec3380d972328fef4105a8729b57fd39aabc9c71269ecac47ed51938b3b18daba3b30adb24545a9fe5d7679dd633999f17ad8fcb848962aa2ac0325d7df
7
+ data.tar.gz: 841c881c775d74055937b3e3be0d96ce9dc68a883dae45440023ea01f51d9664a67297c5c383a23db913ab8df5af08383d83db93278a2346e8fb7ff696f825ac
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.3
data/README.md CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
22
22
 
23
23
  TODO: Write usage instructions here
24
24
 
25
+ * add promotion syntax like `rake play_time:promote['alpha', 'beta']`
26
+
25
27
  ## Contributing
26
28
 
27
29
  1. Fork it ( https://github.com/[my-github-username]/play_time/fork )
@@ -5,6 +5,8 @@ require 'play_time/apk'
5
5
 
6
6
  module PlayTime
7
7
  class Client
8
+ class VersionCodeNotFound < StandardError; end
9
+
8
10
  TOKEN_URI = 'https://accounts.google.com/o/oauth2/token'.freeze
9
11
  SCOPE = 'https://www.googleapis.com/auth/androidpublisher'.freeze
10
12
  API = 'androidpublisher'.freeze
@@ -17,27 +19,45 @@ module PlayTime
17
19
 
18
20
  def commit(track)
19
21
  create_insert
20
- upload_apk
21
- update_track(track)
22
+ version_code = upload_apk
23
+ update_track(track, version_code)
24
+ save
25
+ end
26
+
27
+ def update(track, version_code)
28
+ create_insert
29
+ old_track = get_old_track! version_code
30
+ update_track(old_track.track, *old_track.versionCodes - [version_code])
31
+ update_track(track, version_code)
22
32
  save
23
33
  end
24
34
 
25
35
  private
26
36
 
27
- attr_reader :edit_id, :version_code
37
+ attr_reader :edit_id
28
38
 
29
39
  def create_insert
30
40
  @edit_id = run!(api_method: service.edits.insert, parameters: parameters).data.id
31
41
  end
32
42
 
43
+ def get_old_track!(version_code)
44
+ old_track = get_tracks.find { |track| track.versionCodes.include? version_code }
45
+
46
+ old_track || raise(VersionCodeNotFound, version_code)
47
+ end
48
+
49
+ def get_tracks
50
+ run!(api_method: service.edits.tracks.list, parameters: parameters.merge(editId: edit_id)).data.tracks
51
+ end
52
+
33
53
  def upload_apk
34
54
  upload_params = parameters.merge(editId: edit_id, uploadType: 'media')
35
- @version_code = run!(api_method: service.edits.apks.upload, parameters: upload_params, media: Apk.load).data.versionCode
55
+ run!(api_method: service.edits.apks.upload, parameters: upload_params, media: Apk.load).data.versionCode
36
56
  end
37
57
 
38
- def update_track(track)
58
+ def update_track(track, *version_codes)
39
59
  update_params = parameters.merge(editId: edit_id, track: track)
40
- run! api_method: service.edits.tracks.update, parameters: update_params, body_object: { versionCodes: [version_code] }
60
+ run! api_method: service.edits.tracks.update, parameters: update_params, body_object: { versionCodes: version_codes }
41
61
  end
42
62
 
43
63
  def save
@@ -13,6 +13,18 @@ module PlayTime
13
13
  package_name
14
14
  ).freeze
15
15
 
16
+ def self.exists?
17
+ File.exist? PlayTime.config_path
18
+ end
19
+
20
+ def self.create_config(config_dir, config_path)
21
+ unless File.exist?(config_dir)
22
+ FileUtils.mkdir_p(config_dir)
23
+ end
24
+
25
+ FileUtils.cp("#{__dir__}/templates/play_time.yml", config_path)
26
+ end
27
+
16
28
  def initialize(config)
17
29
  @config = config
18
30
  end
@@ -0,0 +1,22 @@
1
+ require 'play_time/client'
2
+
3
+ module PlayTime
4
+ class Promote
5
+ class << self
6
+ def promote(version_code, track)
7
+ new(Client.new).promote(version_code, track)
8
+ end
9
+ end
10
+
11
+ attr_reader :client
12
+
13
+ def initialize(client)
14
+ @client = client
15
+ end
16
+
17
+ def promote(version_code, track)
18
+ client.authorize!
19
+ client.update(track, version_code)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ require 'rake'
2
+ require 'play_time'
3
+
4
+ namespace :play_time do
5
+ namespace :upload do
6
+ PlayTime::Track::TRACKS.each do |track|
7
+ desc "Uploads apk to #{track}"
8
+ task(track) do |task|
9
+ PlayTime.upload(track)
10
+ end
11
+ end
12
+ end
13
+
14
+ namespace :promote do
15
+ PlayTime::Track::TRACKS.each do |track|
16
+ desc "Promote apk version code to #{track}"
17
+ task(track, :version_code) do |task, args|
18
+ PlayTime.promote(track, args[:version_code].to_i)
19
+ end
20
+ end
21
+ end
22
+
23
+ desc 'Creates a config file in config/play_time.yml'
24
+ task :install do
25
+ PlayTime.install
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ package_name: # package name
2
+ secret_path: # path to secret.p12
3
+ secret_passphrase: # secret.p12 passphrase
4
+ apk_path: # path to apk
5
+ client_name: # Google developer client application name
6
+ client_version: # Google developer client application version
7
+ issuer: # issuer for Google developer application
@@ -7,6 +7,8 @@ module PlayTime
7
7
  ROLLOUT = 'rollout'.freeze
8
8
  PRODUCTION = 'production'.freeze
9
9
 
10
+ TRACKS = [ALPHA, BETA, ROLLOUT, PRODUCTION].freeze
11
+
10
12
  def self.validate!(track)
11
13
  raise InvalidTrack.new("#{track} is an invalid track") unless valid?(track)
12
14
  end
@@ -3,8 +3,7 @@ require 'play_time/client'
3
3
  module PlayTime
4
4
  class Upload
5
5
  def self.upload(track)
6
- upload = Upload.new(Client.new)
7
- upload.upload(track)
6
+ new(Client.new).upload(track)
8
7
  end
9
8
 
10
9
  attr_reader :client
@@ -1,3 +1,3 @@
1
1
  module PlayTime
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/play_time.rb CHANGED
@@ -3,17 +3,33 @@ require 'play_time/version'
3
3
  require 'play_time/track'
4
4
  require 'play_time/configuration'
5
5
  require 'play_time/upload'
6
+ require 'play_time/promote'
6
7
 
7
8
  module PlayTime
8
- def self.config_path
9
- ENV['PLAY_TIME_CONFIG_PATH'] || Configuration::DEFAULT_CONFIG
10
- end
9
+ class << self
10
+ def config_path
11
+ ENV['PLAY_TIME_CONFIG_PATH'] || Configuration::DEFAULT_CONFIG
12
+ end
11
13
 
12
- def self.configuration
13
- @configuration ||= Configuration.new(YAML.load(open(config_path).read))
14
- end
14
+ def configuration
15
+ @configuration ||= Configuration.new(YAML.load(open(config_path).read))
16
+ end
17
+
18
+ def upload(track)
19
+ Upload.upload(track)
20
+ end
21
+
22
+ def promote(version_code, track)
23
+ Promote.promote(version_code, track)
24
+ end
15
25
 
16
- def self.upload(track)
17
- Upload.upload(track)
26
+ def install
27
+ if Configuration.exists?
28
+ puts "You already have a config file in #{config_path}!"
29
+ else
30
+ puts "Generating a new config file: #{config_path}"
31
+ Configuration.create_config('config', config_path)
32
+ end
33
+ end
18
34
  end
19
35
  end
File without changes
@@ -129,4 +129,113 @@ describe PlayTime::Client do
129
129
  )
130
130
  end
131
131
  end
132
+
133
+ describe '#update' do
134
+ let(:version_code) { 99 }
135
+ let(:track) { 'alpha' }
136
+ let(:service) { double(Google::APIClient::API) }
137
+ let(:data) { double(:data, id: 'id', tracks: tracks) }
138
+ let(:response) { double(:response, data: data) }
139
+ let(:tracks) { [double(:track, track: 'old track', versionCodes: [version_code])] }
140
+
141
+ subject { PlayTime::Client.new.update(track, version_code) }
142
+
143
+ before do
144
+ allow(PlayTime.configuration).to receive(:package_name).and_return('com.package.name')
145
+ allow(PlayTime::Runner).to receive(:run!).and_return(response)
146
+ allow(api_client).to receive(:discovered_api).and_return(service)
147
+ allow(service).to receive_message_chain('edits.insert').and_return('insert')
148
+ allow(service).to receive_message_chain('edits.tracks.update').and_return('track update')
149
+ allow(service).to receive_message_chain('edits.tracks.list').and_return('lists')
150
+ allow(service).to receive_message_chain('edits.commit').and_return('commit')
151
+ end
152
+
153
+
154
+ it 'creates a service' do
155
+ subject
156
+
157
+ expect(api_client).to have_received(:discovered_api).with('androidpublisher', 'v2')
158
+ end
159
+
160
+ it 'creates an edit' do
161
+ subject
162
+
163
+ expect(PlayTime::Runner).to have_received(:run!).with(
164
+ api_client, api_method: 'insert', parameters: { packageName: 'com.package.name' })
165
+ end
166
+
167
+ context 'when the version code is in no other track' do
168
+ let(:tracks) { [double(:track, track: 'old track', versionCodes: [-23])] }
169
+
170
+ it 'raises an error' do
171
+ expect {
172
+ subject
173
+ }.to raise_error PlayTime::Client::VersionCodeNotFound, version_code.to_s
174
+ end
175
+ end
176
+
177
+ context 'when the version code is in another track' do
178
+ let(:tracks) { [double(:track, track: 'old track', versionCodes: [version_code])] }
179
+
180
+ context 'when it is the only version in that track' do
181
+ it 'removes everything from the old track' do
182
+ subject
183
+
184
+ expect(PlayTime::Runner).to have_received(:run!).with(
185
+ api_client,
186
+ api_method: 'track update',
187
+ parameters: { packageName: 'com.package.name', editId: 'id', track: 'old track' },
188
+ body_object: { versionCodes: [] }
189
+ )
190
+ end
191
+ end
192
+
193
+ context 'when there are other versions in the track' do
194
+ let(:tracks) { [double(:track, track: 'old track', versionCodes: [version_code, 100])] }
195
+
196
+ it 'only removes itself from the track' do
197
+ subject
198
+
199
+ expect(PlayTime::Runner).to have_received(:run!).with(
200
+ api_client,
201
+ api_method: 'track update',
202
+ parameters: { packageName: 'com.package.name', editId: 'id', track: 'old track' },
203
+ body_object: { versionCodes: [100] }
204
+ )
205
+ end
206
+ end
207
+ end
208
+
209
+ it 'updates a track with the new version code' do
210
+ subject
211
+
212
+ expect(PlayTime::Runner).to have_received(:run!).with(
213
+ api_client,
214
+ api_method: 'track update',
215
+ parameters: { packageName: 'com.package.name', editId: 'id', track: track },
216
+ body_object: { versionCodes: [version_code] }
217
+ )
218
+ end
219
+
220
+ it 'updates a track with the new version code' do
221
+ subject
222
+
223
+ expect(PlayTime::Runner).to have_received(:run!).with(
224
+ api_client,
225
+ api_method: 'track update',
226
+ parameters: { packageName: 'com.package.name', editId: 'id', track: track },
227
+ body_object: { versionCodes: [version_code] }
228
+ )
229
+ end
230
+
231
+ it 'commits the changes' do
232
+ subject
233
+
234
+ expect(PlayTime::Runner).to have_received(:run!).with(
235
+ api_client,
236
+ api_method: 'commit',
237
+ parameters: { packageName: 'com.package.name', editId: 'id' }
238
+ )
239
+ end
240
+ end
132
241
  end
@@ -0,0 +1,69 @@
1
+ describe PlayTime::Configuration do
2
+ shared_examples_for 'configuration option' do
3
+ let(:configuration) { PlayTime::Configuration.new({option.to_s => option, 'foo' => 'bar'}) }
4
+
5
+ subject { configuration.send(option) }
6
+
7
+ it "fetchings the option from the config" do
8
+ expect(subject).to eq option
9
+ end
10
+
11
+ context 'missing options' do
12
+ let(:configuration) { PlayTime::Configuration.new({'foo' => 'bar'}) }
13
+
14
+ it "raises an exception for each missing param" do
15
+ expect {
16
+ subject
17
+ }.to raise_error PlayTime::Configuration::MissingOption, "Missing #{option} in #{PlayTime.config_path}"
18
+ end
19
+ end
20
+ end
21
+
22
+ PlayTime::Configuration::OPTIONS.each do |option|
23
+ describe "##{option}" do
24
+ let(:option) { option }
25
+
26
+ it_behaves_like 'configuration option'
27
+ end
28
+ end
29
+
30
+ describe '.exists?' do
31
+ before do
32
+ allow(File).to receive(:exist?).and_return(true)
33
+ allow(PlayTime).to receive(:config_path).and_return('/path')
34
+ end
35
+
36
+ it 'delegates to file' do
37
+ PlayTime::Configuration.exists?
38
+
39
+ expect(File).to have_received(:exist?).with('/path')
40
+ end
41
+ end
42
+
43
+ describe '.create_config' do
44
+ let(:config_path) { '/config/path.yml' }
45
+ let(:config_dir) { '/config/dir' }
46
+
47
+ subject { PlayTime::Configuration.create_config(config_dir, config_path) }
48
+
49
+ before do
50
+ allow(FileUtils).to receive(:mkdir_p)
51
+ end
52
+
53
+ context 'when config dir exists' do
54
+ before do
55
+ allow(File).to receive(:exist?).and_return(true)
56
+ end
57
+
58
+ it 'does not create a config dir' do
59
+ expect(FileUtils).not_to have_received(:mkdir_p).with(config_dir)
60
+ end
61
+ end
62
+
63
+ context 'when config dir does not exist' do
64
+ before do
65
+ allow(File).to receive(:exist?).and_return(false)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,53 @@
1
+ describe PlayTime::Promote do
2
+ let(:version_code) { 99 }
3
+ let(:track) { 'alpha' }
4
+
5
+ describe '.promote' do
6
+ let(:promote) { instance_double(PlayTime::Promote) }
7
+ let(:client) { instance_double(PlayTime::Client) }
8
+
9
+ subject { PlayTime::Promote.promote(version_code, track) }
10
+
11
+ before do
12
+ allow(promote).to receive(:promote)
13
+ allow(PlayTime::Client).to receive(:new).and_return(client)
14
+ allow(PlayTime::Promote).to receive(:new).and_return(promote)
15
+ end
16
+
17
+ it 'promotes the track' do
18
+ subject
19
+
20
+ expect(promote).to have_received(:promote).with(version_code, track)
21
+ end
22
+
23
+ it 'instantiates upload with new authorization and client' do
24
+ subject
25
+
26
+ expect(PlayTime::Promote).to have_received(:new).with(client)
27
+ end
28
+ end
29
+
30
+ describe '#promote' do
31
+ let(:client) { instance_double(PlayTime::Client) }
32
+ let(:promote) { PlayTime::Promote.new(client) }
33
+
34
+ subject { promote.promote(version_code, track) }
35
+
36
+ before do
37
+ allow(client).to receive(:authorize!)
38
+ allow(client).to receive(:update)
39
+ end
40
+
41
+ it 'authroizes the client' do
42
+ subject
43
+
44
+ expect(client).to have_received(:authorize!)
45
+ end
46
+
47
+ it 'updates the track with the version code' do
48
+ subject
49
+
50
+ expect(client).to have_received(:update).with(track, version_code)
51
+ end
52
+ end
53
+ end
File without changes
@@ -0,0 +1,76 @@
1
+ require 'play_time/tasks'
2
+
3
+ describe 'play_time tasks' do
4
+ describe 'upload' do
5
+ shared_examples_for 'upload task' do
6
+ it 'uploads an apk to production' do
7
+ allow(PlayTime).to receive(:upload)
8
+
9
+ Rake::Task["play_time:upload:#{track}"].invoke
10
+
11
+ expect(PlayTime).to have_received(:upload).with(track)
12
+ end
13
+ end
14
+
15
+ PlayTime::Track::TRACKS.each do |track|
16
+ it_behaves_like 'upload task' do
17
+ let(:track) { track }
18
+ end
19
+ end
20
+ end
21
+
22
+ describe 'promote' do
23
+ shared_examples_for 'promote task' do
24
+ it 'promotes the version number' do
25
+ allow(PlayTime).to receive(:promote)
26
+
27
+ Rake::Task["play_time:promote:#{track}"].invoke("232")
28
+
29
+ expect(PlayTime).to have_received(:promote).with(track, 232)
30
+ end
31
+ end
32
+
33
+ PlayTime::Track::TRACKS.each do |track|
34
+ it_behaves_like 'promote task' do
35
+ let(:track) { track }
36
+ end
37
+ end
38
+ end
39
+
40
+ describe 'install task' do
41
+ let(:config_file) { File.expand_path('config/play_time.yml') }
42
+
43
+ before do
44
+ allow(PlayTime).to receive(:config_path).and_return('config/play_time.yml')
45
+ Rake::Task['play_time:install'].reenable
46
+ end
47
+
48
+ after do
49
+ File.delete(config_file) if File.exist?(config_file)
50
+ end
51
+
52
+ context "when config file doesn't exist" do
53
+ it 'generates an exmaple config file' do
54
+ Rake::Task['play_time:install'].invoke
55
+
56
+ expect(File).to exist(config_file)
57
+ expect(open(File.expand_path("lib/play_time/templates/play_time.yml")).read). to eq(open(config_file).read)
58
+ end
59
+ end
60
+
61
+ context "when config file already exists" do
62
+ before do
63
+ Rake::Task['play_time:install'].invoke
64
+ Rake::Task['play_time:install'].reenable
65
+ end
66
+
67
+ it "doesn't do anything" do
68
+ sleep(0.5)
69
+
70
+ expect do
71
+ Rake::Task['play_time:install'].invoke
72
+ end.not_to change { File.open(PlayTime.config_path).mtime }
73
+ end
74
+ end
75
+ end
76
+ end
File without changes
File without changes
@@ -8,7 +8,6 @@ describe PlayTime, if: PlayTime.config_path.end_with?('default.yml') do
8
8
  end
9
9
 
10
10
  describe '.upload' do
11
- let(:apk_path) { '/path/to/app.apk' }
12
11
  let(:track) { PlayTime::Track::ALPHA }
13
12
 
14
13
  subject { PlayTime.upload(track) }
@@ -21,4 +20,52 @@ describe PlayTime, if: PlayTime.config_path.end_with?('default.yml') do
21
20
  expect(PlayTime::Upload).to have_received(:upload).with(track)
22
21
  end
23
22
  end
23
+
24
+ describe '.promote' do
25
+ let(:version_code) { 99 }
26
+ let(:track) { PlayTime::Track::BETA }
27
+
28
+ subject { PlayTime.promote(version_code, track) }
29
+
30
+ it 'promotes the version code' do
31
+ allow(PlayTime::Promote).to receive(:promote)
32
+
33
+ subject
34
+
35
+ expect(PlayTime::Promote).to have_received(:promote).with(version_code, track)
36
+ end
37
+ end
38
+
39
+ describe '.install' do
40
+ subject { PlayTime.install }
41
+
42
+ context 'when configuration exists' do
43
+ it 'outputs message' do
44
+ allow(PlayTime::Configuration).to receive(:exists?).and_return(true)
45
+
46
+ expect{
47
+ subject
48
+ }.to output("You already have a config file in #{PlayTime.config_path}!\n").to_stdout
49
+ end
50
+ end
51
+
52
+ context 'when the configuration does not exist' do
53
+
54
+ before do
55
+ allow(PlayTime::Configuration).to receive(:create_config)
56
+ allow(PlayTime::Configuration).to receive(:exists?).and_return(false)
57
+ end
58
+
59
+ it 'outputs message' do
60
+ expect{
61
+ subject
62
+ }.to output("Generating a new config file: #{PlayTime.config_path}\n").to_stdout
63
+ end
64
+
65
+ it 'creates the config' do
66
+ subject
67
+ expect(PlayTime::Configuration).to have_received(:create_config).with('config', PlayTime.config_path)
68
+ end
69
+ end
70
+ end
24
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: play_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - IS Dev team
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
+ - ".ruby-version"
78
79
  - Gemfile
79
80
  - LICENSE.txt
80
81
  - README.md
@@ -83,20 +84,25 @@ files:
83
84
  - lib/play_time/apk.rb
84
85
  - lib/play_time/client.rb
85
86
  - lib/play_time/configuration.rb
87
+ - lib/play_time/promote.rb
86
88
  - lib/play_time/runner.rb
89
+ - lib/play_time/tasks.rb
90
+ - lib/play_time/templates/play_time.yml
87
91
  - lib/play_time/track.rb
88
92
  - lib/play_time/upload.rb
89
93
  - lib/play_time/version.rb
90
94
  - play_time.gemspec
91
- - spec/apk_spec.rb
92
- - spec/client_spec.rb
93
- - spec/configuration_spec.rb
95
+ - spec/lib/apk_spec.rb
96
+ - spec/lib/client_spec.rb
97
+ - spec/lib/configuration_spec.rb
98
+ - spec/lib/promote_spec.rb
99
+ - spec/lib/runner_spec.rb
100
+ - spec/lib/tasks_spec.rb
101
+ - spec/lib/track_spec.rb
102
+ - spec/lib/upload_spec.rb
94
103
  - spec/play_time_spec.rb
95
- - spec/runner_spec.rb
96
104
  - spec/spec_helper.rb
97
105
  - spec/support/config/default.yml
98
- - spec/track_spec.rb
99
- - spec/upload_spec.rb
100
106
  homepage: https://github.com/is-devteam/play_time
101
107
  licenses:
102
108
  - MIT
@@ -122,12 +128,14 @@ signing_key:
122
128
  specification_version: 4
123
129
  summary: PlayTime is a gem for uploading apks to the Google Play Store
124
130
  test_files:
125
- - spec/apk_spec.rb
126
- - spec/client_spec.rb
127
- - spec/configuration_spec.rb
131
+ - spec/lib/apk_spec.rb
132
+ - spec/lib/client_spec.rb
133
+ - spec/lib/configuration_spec.rb
134
+ - spec/lib/promote_spec.rb
135
+ - spec/lib/runner_spec.rb
136
+ - spec/lib/tasks_spec.rb
137
+ - spec/lib/track_spec.rb
138
+ - spec/lib/upload_spec.rb
128
139
  - spec/play_time_spec.rb
129
- - spec/runner_spec.rb
130
140
  - spec/spec_helper.rb
131
141
  - spec/support/config/default.yml
132
- - spec/track_spec.rb
133
- - spec/upload_spec.rb
@@ -1,29 +0,0 @@
1
- describe PlayTime::Configuration do
2
- shared_examples_for 'configuration option' do
3
- let(:configuration) { PlayTime::Configuration.new({option.to_s => option, 'foo' => 'bar'}) }
4
-
5
- subject { configuration.send(option) }
6
-
7
- it "fetchings the option from the config" do
8
- expect(subject).to eq option
9
- end
10
-
11
- context 'missing options' do
12
- let(:configuration) { PlayTime::Configuration.new({'foo' => 'bar'}) }
13
-
14
- it "raises an exception for each missing param" do
15
- expect {
16
- subject
17
- }.to raise_error PlayTime::Configuration::MissingOption, "Missing #{option} in #{PlayTime.config_path}"
18
- end
19
- end
20
- end
21
-
22
- PlayTime::Configuration::OPTIONS.each do |option|
23
- describe "##{option}" do
24
- let(:option) { option }
25
-
26
- it_behaves_like 'configuration option'
27
- end
28
- end
29
- end