deliver 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +37 -10
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/.yardopts +1 -0
- data/Gemfile.lock +106 -0
- data/LICENSE +21 -0
- data/README.md +268 -17
- data/Rakefile +3 -0
- data/assets/PDFExample.png +0 -0
- data/assets/SubmitForReviewInformation.png +0 -0
- data/assets/deliver.png +0 -0
- data/assets/deliver.pxm +0 -0
- data/assets/deliverFullSize.png +0 -0
- data/bin/deliver +32 -0
- data/deliver.gemspec +15 -9
- data/lib/assets/DeliverfileDefault +47 -0
- data/lib/assets/DeliverfileExample +62 -0
- data/lib/assets/ScreenshotsHelp +4 -0
- data/lib/deliver.rb +20 -1
- data/lib/deliver/app.rb +146 -0
- data/lib/deliver/app_metadata.rb +487 -0
- data/lib/deliver/app_screenshot.rb +119 -0
- data/lib/deliver/commands.rb +4 -0
- data/lib/deliver/commands/init.rb +12 -0
- data/lib/deliver/commands/run.rb +20 -0
- data/lib/deliver/deliver_process.rb +241 -0
- data/lib/deliver/deliverer.rb +112 -0
- data/lib/deliver/deliverfile/deliverfile.rb +35 -0
- data/lib/deliver/deliverfile/deliverfile_creator.rb +115 -0
- data/lib/deliver/deliverfile/dsl.rb +124 -0
- data/lib/deliver/dependency_checker.rb +32 -0
- data/lib/deliver/helper.rb +55 -0
- data/lib/deliver/ipa_uploader.rb +160 -0
- data/lib/deliver/itunes_connect.rb +514 -0
- data/lib/deliver/itunes_search_api.rb +48 -0
- data/lib/deliver/itunes_transporter.rb +154 -0
- data/lib/deliver/languages.rb +6 -0
- data/lib/deliver/metadata_item.rb +94 -0
- data/lib/deliver/password_manager.rb +86 -0
- data/lib/deliver/pdf_generator.rb +131 -0
- data/lib/deliver/version.rb +1 -1
- data/spec/app_metadata_spec.rb +350 -0
- data/spec/app_screenshot_spec.rb +88 -0
- data/spec/app_spec.rb +85 -0
- data/spec/deliverer_spec.rb +48 -0
- data/spec/deliverfile_creator_spec.rb +73 -0
- data/spec/example_deliver_files_spec.rb +227 -0
- data/spec/fixtures/Deliverfiles/DeliverfileCallbacks +14 -0
- data/spec/fixtures/Deliverfiles/DeliverfileCallbacksFailingTests +14 -0
- data/spec/fixtures/Deliverfiles/DeliverfileCallbacksNoErrorBlock +6 -0
- data/spec/fixtures/Deliverfiles/DeliverfileDefaultLanguageNotOnTop +8 -0
- data/spec/fixtures/Deliverfiles/DeliverfileDuplicateIpa +2 -0
- data/spec/fixtures/Deliverfiles/DeliverfileLocales +16 -0
- data/spec/fixtures/Deliverfiles/DeliverfileMetadataJson +6 -0
- data/spec/fixtures/Deliverfiles/DeliverfileMissingAppVersion +1 -0
- data/spec/fixtures/Deliverfiles/DeliverfileMissingBlockForTests +7 -0
- data/spec/fixtures/Deliverfiles/DeliverfileMissingIdentifier +1 -0
- data/spec/fixtures/Deliverfiles/DeliverfileMissingLanguage +1 -0
- data/spec/fixtures/Deliverfiles/DeliverfileMissingValue +3 -0
- data/spec/fixtures/Deliverfiles/DeliverfileMixed +37 -0
- data/spec/fixtures/Deliverfiles/DeliverfileNoVersion +3 -0
- data/spec/fixtures/Deliverfiles/DeliverfileScreenshots +6 -0
- data/spec/fixtures/Deliverfiles/DeliverfileScreenshotsFallbackDefaultLanguage +7 -0
- data/spec/fixtures/Deliverfiles/DeliverfileSimple +8 -0
- data/spec/fixtures/Deliverfiles/DeliverfileVersionMismatchPackage +8 -0
- data/spec/fixtures/Deliverfiles/DeliverfileWrongIdentifier +5 -0
- data/spec/fixtures/Deliverfiles/DeliverfileWrongVersion +5 -0
- data/spec/fixtures/Deliverfiles/metadata.json +24 -0
- data/spec/fixtures/example1.itmsp/metadata.xml +121 -0
- data/spec/fixtures/example2.itmsp/metadata.xml +54 -0
- data/spec/fixtures/ipas/Example1.ipa +0 -0
- data/spec/fixtures/metadata/ipa_result.xml +12 -0
- data/spec/fixtures/metadata/ipa_result2.xml +12 -0
- data/spec/fixtures/packages/464686641.itmsp/metadata.xml +104 -0
- data/spec/fixtures/packages/794902327.itmsp/metadata.xml +107 -0
- data/spec/fixtures/packages/878567776.itmsp/metadata.xml +104 -0
- data/spec/fixtures/screenshots/de-DE/iPhone4.png +0 -0
- data/spec/fixtures/screenshots/de-DE/iPhone6.png +0 -0
- data/spec/fixtures/screenshots/de-DE/iPhone6Plus1.png +0 -0
- data/spec/fixtures/screenshots/de-DE/iPhone6Plus2.png +0 -0
- data/spec/fixtures/screenshots/de-DE/screenshot1.png +0 -0
- data/spec/fixtures/screenshots/de-DE/screenshot2.png +0 -0
- data/spec/fixtures/screenshots/de-DE/screenshot3.png +0 -0
- data/spec/fixtures/screenshots/de-DE/screenshot5.png +0 -0
- data/spec/fixtures/screenshots/en-US/english.png +0 -0
- data/spec/fixtures/screenshots/iPhone4.png +0 -0
- data/spec/fixtures/screenshots/invalidImage.png +0 -0
- data/spec/fixtures/screenshots/screenshot1.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4 2.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4 copy 2.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4 copy 3.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4 copy 4.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4 copy 5.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4 copy 6.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4 copy.png +0 -0
- data/spec/fixtures/screenshots/tooMany/de-DE/iPhone4.png +0 -0
- data/spec/helper_spec.rb +16 -0
- data/spec/ipa_uploader_spec.rb +61 -0
- data/spec/itunes_connect_spec.rb +12 -0
- data/spec/itunes_search_api_spec.rb +24 -0
- data/spec/itunes_transporter_spec.rb +52 -0
- data/spec/languages_spec.rb +7 -0
- data/spec/metadata_item_spec.rb +36 -0
- data/spec/mocking/transporter_mocking.rb +40 -0
- data/spec/mocking/webmocking.rb +31 -0
- data/spec/password_manager_spec.rb +27 -0
- data/spec/responses/itunesLookup-.json +4 -0
- data/spec/responses/itunesLookup-0.json +4 -0
- data/spec/responses/itunesLookup-284882215.json +106 -0
- data/spec/responses/itunesLookup-at.felixkrause.iTanky.json +8 -0
- data/spec/responses/itunesLookup-com.facebook.Facebook.json +106 -0
- data/spec/responses/itunesLookup-invalid.json +4 -0
- data/spec/responses/itunesLookup-net.sunapps.invalid.json +4 -0
- data/spec/responses/transporter/download_invalid_apple_id.txt +35 -0
- data/spec/responses/transporter/download_valid_apple_id.txt +32 -0
- data/spec/responses/transporter/upload_invalid.txt +174 -0
- data/spec/responses/transporter/upload_valid.txt +290 -0
- data/spec/spec_helper.rb +23 -0
- data/tasks/rspec.rake +3 -0
- metadata +242 -8
- data/LICENSE.txt +0 -22
data/lib/deliver/version.rb
CHANGED
@@ -0,0 +1,350 @@
|
|
1
|
+
describe Deliver do
|
2
|
+
describe Deliver::AppMetadata do
|
3
|
+
let (:apple_id) { 794902327 }
|
4
|
+
let (:app_identifier) { 'net.sunapps.1' }
|
5
|
+
|
6
|
+
[
|
7
|
+
"./spec/fixtures/example1.itmsp/",
|
8
|
+
"./spec/fixtures/example2.itmsp/"
|
9
|
+
].each do |current_path|
|
10
|
+
describe "Example metadata #{current_path.split('/').last}" do
|
11
|
+
before do
|
12
|
+
@app = Deliver::App.new(apple_id: apple_id, app_identifier: app_identifier)
|
13
|
+
|
14
|
+
@app.metadata = Deliver::AppMetadata.new(@app, current_path, false)
|
15
|
+
|
16
|
+
@number_of_screenshots = (current_path.include?("example1") ? 8 : 0)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "properly cleaned up the live version, which cannot be updated" do
|
20
|
+
expect(@app.metadata.fetch_value("//x:version").count).to eq(1)
|
21
|
+
expect(@app.metadata.fetch_value("//x:version").first['string']).to eq("0.9.10")
|
22
|
+
end
|
23
|
+
|
24
|
+
if current_path.include?'example1'
|
25
|
+
it "properly loaded all the app metadata into the information hash" do
|
26
|
+
info = @app.metadata.information['de-DE']
|
27
|
+
expect(info[:title][:value]).to eq("Example App Title")
|
28
|
+
expect(info[:title][:modified]).to eq(false)
|
29
|
+
expect(info[:description][:value].include?"3D GPS Birdiebuch").to eq(true)
|
30
|
+
expect(info[:keywords][:value]).to eq(%w|personal sunapps sun sunapps felix krause|)
|
31
|
+
expect(info[:version_whats_new][:value]).to eq("- Changelog Line 1\n- Changelog Line 2")
|
32
|
+
expect(info[:software_url][:value]).to eq("http://sunapps.net")
|
33
|
+
expect(info[:support_url][:value]).to eq("http://www.sunapps.net/")
|
34
|
+
|
35
|
+
expect(@app.metadata.information.count).to eq(2)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#update_title" do
|
40
|
+
|
41
|
+
it "updates the title" do
|
42
|
+
new_title = "So new title"
|
43
|
+
|
44
|
+
expect(@app.metadata.fetch_value("//x:title").last.content).to eq('Example App Title')
|
45
|
+
@app.metadata.update_title({ 'de-DE' => new_title })
|
46
|
+
|
47
|
+
expect(@app.metadata.fetch_value("//x:title").last.content).to eq(new_title)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "supports the & symbol properly" do
|
51
|
+
new_title = "something & something else"
|
52
|
+
@app.metadata.update_title({ 'de-DE' => new_title })
|
53
|
+
|
54
|
+
expect(@app.metadata.fetch_value("//x:title").last.content).to eq(new_title)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "raises an error when passing an invalid language" do
|
58
|
+
begin
|
59
|
+
@app.metadata.update_title({ 'de' => 'asdf' })
|
60
|
+
raise "No exception was raised"
|
61
|
+
rescue Exception => ex
|
62
|
+
expect(ex.to_s).to include("Language 'de' is invalid. It must be in [")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#add_new_locale" do
|
68
|
+
it "throws an exception when an invalid language was passed" do
|
69
|
+
expect {
|
70
|
+
@app.metadata.add_new_locale('asdf')
|
71
|
+
}.to raise_error(/is invalid. It must be in/)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "throws return false when languag already exists" do
|
75
|
+
expect(@app.metadata.add_new_locale('es-ES')).to eq(true)
|
76
|
+
expect(@app.metadata.add_new_locale('es-ES')).to eq(false)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "adds a new language if it's valid" do
|
80
|
+
expect(@app.metadata.add_new_locale('es-ES')).to eq(true)
|
81
|
+
|
82
|
+
expect(@app.metadata.fetch_value("//x:locale").count).to eq(3)
|
83
|
+
expect(@app.metadata.fetch_value("//x:title").count).to eq(3)
|
84
|
+
|
85
|
+
@app.metadata.fetch_value("//x:title").each do |current|
|
86
|
+
# it properly set the default title to be valid
|
87
|
+
expect(current.content.length).to be > 5
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#update_description" do
|
93
|
+
|
94
|
+
it "throws an exception when a string is given instead of a hash" do
|
95
|
+
expect {
|
96
|
+
@app.metadata.update_description("something")
|
97
|
+
}.to raise_error("Please pass a hash of languages to this method")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "updates the description when a hash is given" do
|
101
|
+
description = "Something Deutsch"
|
102
|
+
|
103
|
+
expect(@app.metadata.information['de-DE'][:description][:modified]).to eq(false)
|
104
|
+
|
105
|
+
@app.metadata.update_description({
|
106
|
+
'de-DE' => description
|
107
|
+
})
|
108
|
+
|
109
|
+
expect(@app.metadata.fetch_value("//x:description").first.content).to eq(description)
|
110
|
+
|
111
|
+
expect(@app.metadata.information['de-DE'][:description][:value]).to eq(description)
|
112
|
+
expect(@app.metadata.information['de-DE'][:description][:modified]).to eq(true)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#update_changelog" do
|
117
|
+
it "updates the changelog" do
|
118
|
+
new_value = "What's new?"
|
119
|
+
@app.metadata.update_changelog({ 'de-DE' => new_value })
|
120
|
+
expect(@app.metadata.fetch_value("//x:version_whats_new").first.content).to eq(new_value)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "#update_marketing_url" do
|
125
|
+
it "updates the marketing URL" do
|
126
|
+
new_value = "http://google.com"
|
127
|
+
expect(@app.metadata.fetch_value("//x:software_url").first.content).to eq('http://sunapps.net')
|
128
|
+
@app.metadata.update_marketing_url({ 'de-DE' => new_value })
|
129
|
+
expect(@app.metadata.fetch_value("//x:software_url").first.content).to eq(new_value)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#update_support_url" do
|
134
|
+
it "updates the support URL" do
|
135
|
+
new_value = "http://krause.pizza"
|
136
|
+
expect(@app.metadata.fetch_value("//x:support_url").first.content).to eq('http://www.sunapps.net/')
|
137
|
+
@app.metadata.update_support_url({ 'de-DE' => new_value })
|
138
|
+
expect(@app.metadata.fetch_value("//x:support_url").first.content).to eq(new_value)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "doesn't set the modified to true if it's the same value" do
|
142
|
+
old = @app.metadata.information['de-DE'][:support_url][:value]
|
143
|
+
expect(@app.metadata.information['de-DE'][:support_url][:modified]).to eq(false)
|
144
|
+
|
145
|
+
@app.metadata.update_support_url({'de-DE' => old})
|
146
|
+
|
147
|
+
expect(@app.metadata.information['de-DE'][:support_url][:modified]).to eq(false)
|
148
|
+
|
149
|
+
@app.metadata.update_support_url({'de-DE' => 'something new'})
|
150
|
+
|
151
|
+
expect(@app.metadata.information['de-DE'][:support_url][:modified]).to eq(true)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#update_privacy_url" do
|
156
|
+
it "updates the privacy URL" do
|
157
|
+
new_value = "http://krause.pizza"
|
158
|
+
expect(@app.metadata.fetch_value("//x:privacy_url").first).to eq(nil)
|
159
|
+
|
160
|
+
@app.metadata.update_privacy_url({ 'de-DE' => new_value })
|
161
|
+
|
162
|
+
expect(@app.metadata.fetch_value("//x:privacy_url").first.content).to eq(new_value)
|
163
|
+
expect(@app.metadata.information['de-DE'][:privacy_url][:value]).to eq(new_value)
|
164
|
+
expect(@app.metadata.information['de-DE'][:privacy_url][:modified]).to eq(true)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
describe "#update_keywords" do
|
170
|
+
it "throws an exception when a string is given instead of an array" do
|
171
|
+
expect {
|
172
|
+
@app.metadata.update_keywords({ "de-DE" => "keyword1, keyword2" })
|
173
|
+
}.to raise_error("Parameter needs to be a hash (each language) with an array of keywords in it (given: {\"de-DE\"=>\"keyword1, keyword2\"})")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "updates the keywords when a hash of arrays is given" do
|
177
|
+
tags = ["SunApps", "Felix", "Krause"]
|
178
|
+
|
179
|
+
@app.metadata.fetch_value("//x:keyword")
|
180
|
+
|
181
|
+
@app.metadata.update_keywords({
|
182
|
+
'de-DE' => tags
|
183
|
+
})
|
184
|
+
|
185
|
+
result = @app.metadata.fetch_value("//x:keyword")
|
186
|
+
expect(result.count).to eq(tags.count)
|
187
|
+
expect(result[0].content).to eq(tags[0])
|
188
|
+
expect(result[1].content).to eq(tags[1])
|
189
|
+
expect(result[2].content).to eq(tags[2])
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "#clear_all_screenshots" do
|
194
|
+
it "clears all the screenshots of the given language" do
|
195
|
+
expect(@app.metadata.fetch_value("//x:software_screenshot").count).to eq(0)
|
196
|
+
|
197
|
+
path = './spec/fixtures/screenshots/screenshot1.png'
|
198
|
+
@app.metadata.set_all_screenshots({
|
199
|
+
'de-DE' => [
|
200
|
+
Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_40)
|
201
|
+
]
|
202
|
+
})
|
203
|
+
|
204
|
+
expect(@app.metadata.fetch_value("//x:software_screenshot").count).to eq(1)
|
205
|
+
|
206
|
+
@app.metadata.clear_all_screenshots("de-DE")
|
207
|
+
|
208
|
+
expect(@app.metadata.fetch_value("//x:software_screenshot").count).to eq(0)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "throws an exception when language is invalid" do
|
212
|
+
expect {
|
213
|
+
@app.metadata.clear_all_screenshots("de")
|
214
|
+
}.to raise_error("The specified language could not be found. Make sure it is available in Deliver::Languages::ALL_LANGUAGES")
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe "#set_all_screenshots" do
|
219
|
+
let (:error_message) { "Please pass a hash, containing an array of AppScreenshot objects" }
|
220
|
+
it "raises an error when not passing a hash" do
|
221
|
+
expect {
|
222
|
+
@app.metadata.set_all_screenshots([])
|
223
|
+
}.to raise_error(error_message)
|
224
|
+
end
|
225
|
+
|
226
|
+
it "raises an error when passing empty arrays" do
|
227
|
+
expect {
|
228
|
+
@app.metadata.set_all_screenshots({ 'de-DE' => [] })
|
229
|
+
}.to raise_error(error_message)
|
230
|
+
end
|
231
|
+
|
232
|
+
it "raises an error when not using AppScreenshot objects" do
|
233
|
+
expect {
|
234
|
+
@app.metadata.set_all_screenshots({ 'de-DE' => ["./screenshot.png"] })
|
235
|
+
}.to raise_error(error_message)
|
236
|
+
end
|
237
|
+
|
238
|
+
it "properly updates the metadata information when providing correct inputs" do
|
239
|
+
path = './spec/fixtures/screenshots/screenshot1.png'
|
240
|
+
|
241
|
+
expect(@app.metadata.fetch_value("//x:software_screenshot").count).to eq(0)
|
242
|
+
@app.metadata.set_all_screenshots({
|
243
|
+
'de-DE' => [
|
244
|
+
Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_40),
|
245
|
+
Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_40),
|
246
|
+
Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_40)
|
247
|
+
]
|
248
|
+
})
|
249
|
+
results = @app.metadata.fetch_value("//x:software_screenshot")
|
250
|
+
expect(results.count).to eq(3)
|
251
|
+
expect(results[0]['position']).to eq('1')
|
252
|
+
expect(results[1]['position']).to eq('2')
|
253
|
+
expect(results[2]['position']).to eq('3')
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe "#set_screenshots_for_each_language" do
|
258
|
+
it "automatically detects all screenshots in the given folder" do
|
259
|
+
@app.metadata.clear_all_screenshots("de-DE")
|
260
|
+
@app.metadata.clear_all_screenshots("en-US")
|
261
|
+
|
262
|
+
path = './spec/fixtures/screenshots/de-DE'
|
263
|
+
expect(@app.metadata.set_screenshots_for_each_language({'de-DE' => path})).to eq(true)
|
264
|
+
results = @app.metadata.fetch_value("//x:software_screenshot")
|
265
|
+
|
266
|
+
expect(results.count).to eq(Dir["./spec/fixtures/screenshots/de-DE/*"].length)
|
267
|
+
|
268
|
+
example = results.first
|
269
|
+
expect(example['display_target']).to eq("iOS-3.5-in")
|
270
|
+
expect(example['position']).to eq("1")
|
271
|
+
|
272
|
+
expect(results[1]['position']).to eq("1") # other screen size
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe "#set_all_screenshots_from_path" do
|
277
|
+
it "return false if no folders could be found" do
|
278
|
+
expect(@app.metadata.set_all_screenshots_from_path('./notfound')).to equal(false)
|
279
|
+
end
|
280
|
+
|
281
|
+
it "automatically detects all screenshots in the given folder" do
|
282
|
+
@app.metadata.clear_all_screenshots("de-DE")
|
283
|
+
@app.metadata.clear_all_screenshots("en-US")
|
284
|
+
|
285
|
+
path = './spec/fixtures/screenshots/'
|
286
|
+
expect(@app.metadata.set_all_screenshots_from_path(path)).to equal(true)
|
287
|
+
|
288
|
+
results = @app.metadata.fetch_value("//x:software_screenshot")
|
289
|
+
|
290
|
+
expect(results.count).to eq(Dir["./spec/fixtures/screenshots/de-DE/*"].length +
|
291
|
+
Dir["./spec/fixtures/screenshots/en-US/*"].length)
|
292
|
+
|
293
|
+
example = results.first
|
294
|
+
expect(example['display_target']).to eq("iOS-4-in")
|
295
|
+
expect(example['position']).to eq("1")
|
296
|
+
|
297
|
+
expect(results[1]['position']).to eq("1") # other screen size
|
298
|
+
end
|
299
|
+
|
300
|
+
it "throws an exception when there are too many screenshots" do
|
301
|
+
expect {
|
302
|
+
@app.metadata.set_all_screenshots_from_path('./spec/fixtures/screenshots/tooMany/')
|
303
|
+
}.to raise_error("Only 5 screenshots are allowed per language per device type (iOS-3.5-in)")
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe "#add_screenshot" do
|
308
|
+
it "allows the user to add multiple screenshots" do
|
309
|
+
@app.apple_id = 878567776
|
310
|
+
@app.metadata.clear_all_screenshots('de-DE')
|
311
|
+
@app.metadata.clear_all_screenshots('en-US')
|
312
|
+
expect(@app.metadata.fetch_value("//x:software_screenshot").count).to eq(0)
|
313
|
+
|
314
|
+
path = './spec/fixtures/screenshots/screenshot1.png'
|
315
|
+
# The order is quite important. en-US first, since we check using the index afterwards
|
316
|
+
@app.metadata.add_screenshot('en-US', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_47))
|
317
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_55))
|
318
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_55))
|
319
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_47))
|
320
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_55))
|
321
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_IPAD))
|
322
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_IPAD))
|
323
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_IPAD))
|
324
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_IPAD))
|
325
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_IPAD))
|
326
|
+
|
327
|
+
expect {
|
328
|
+
@app.metadata.add_screenshot('de-DE', Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_IPAD))
|
329
|
+
}.to raise_error("Only 5 screenshots are allowed per language per device type (iOS-iPad)")
|
330
|
+
|
331
|
+
|
332
|
+
results = @app.metadata.fetch_value("//x:software_screenshot")
|
333
|
+
expect(results.count).to eq(10)
|
334
|
+
|
335
|
+
expect(results[0]['position']).to eq('1')
|
336
|
+
expect(results[1]['position']).to eq('1')
|
337
|
+
expect(results[2]['position']).to eq('2')
|
338
|
+
expect(results[3]['position']).to eq('1')
|
339
|
+
expect(results[4]['position']).to eq('3')
|
340
|
+
expect(results[5]['position']).to eq('1')
|
341
|
+
expect(results[6]['position']).to eq('2')
|
342
|
+
expect(results[7]['position']).to eq('3')
|
343
|
+
expect(results[8]['position']).to eq('4')
|
344
|
+
expect(results[9]['position']).to eq('5')
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
describe Deliver do
|
2
|
+
describe Deliver::AppScreenshot do
|
3
|
+
let (:path) { "./spec/fixtures/screenshots/screenshot1.png" }
|
4
|
+
|
5
|
+
describe "#init" do
|
6
|
+
it "raises an exception if image file was not found" do
|
7
|
+
path = "./notHere.png"
|
8
|
+
expect {
|
9
|
+
Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_40)
|
10
|
+
}.to raise_error("File not found at path '#{path}'")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "properly saves the path and screen size" do
|
14
|
+
res = Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_40)
|
15
|
+
expect(res.path).to eq(path)
|
16
|
+
expect(res.screen_size).to eq(Deliver::ScreenSize::IOS_40)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "after init" do
|
21
|
+
before do
|
22
|
+
@item = Deliver::AppScreenshot.new(path, Deliver::ScreenSize::IOS_40)
|
23
|
+
@doc = Nokogiri::XML(File.read("./spec/fixtures/example1.itmsp/metadata.xml"))
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#create_xml_node" do
|
27
|
+
it "properly creates a valid nokogiri xml node for the screenshot" do
|
28
|
+
order_index = 1
|
29
|
+
node = @item.create_xml_node(@doc, order_index)
|
30
|
+
expect(node.children.first.content).to eq(File.size(path).to_s)
|
31
|
+
expect(node.children[1].content).to eq("30fbc3071dc36b824bcd5960bcfef775.png")
|
32
|
+
expect(node.children.last['type']).to eq("md5")
|
33
|
+
expect(node.children.last.content).to eq("e2c116d8f1ab7982a2b131ac681b6e86")
|
34
|
+
|
35
|
+
expect(node['position']).to eq(order_index.to_s)
|
36
|
+
expect(node['display_target']).to eq(Deliver::ScreenSize::IOS_40)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#is_valid?" do
|
41
|
+
it "is not valid when it's not a png" do
|
42
|
+
expect(@item.is_valid?).to eq(true)
|
43
|
+
|
44
|
+
@item.path = "./something.jpg"
|
45
|
+
expect(@item.is_valid?).to eq(false)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "it is not valid, when the size does not match the given type" do
|
49
|
+
expect(@item.is_valid?).to eq(true)
|
50
|
+
|
51
|
+
@item.screen_size = Deliver::ScreenSize::IOS_55
|
52
|
+
expect(@item.is_valid?).to eq(false) # wrong size
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#calculate_screen_size" do
|
57
|
+
it "will raise an error if the file can not be found" do
|
58
|
+
expect {
|
59
|
+
Deliver::AppScreenshot.calculate_screen_size('./notHere.png')
|
60
|
+
}.to raise_error("Could not find or parse file at path './notHere.png'")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "will raise an error if the size is invalid" do
|
64
|
+
expect {
|
65
|
+
Deliver::AppScreenshot.calculate_screen_size('./spec/fixtures/screenshots/invalidImage.png')
|
66
|
+
}.to raise_error("Unsupported screen size [20, 36] for path './spec/fixtures/screenshots/invalidImage.png'")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "it will return the size for a given png file" do
|
70
|
+
p = "./spec/fixtures/screenshots/de-DE/"
|
71
|
+
|
72
|
+
files = [
|
73
|
+
['iPhone4.png', 'iOS-3.5-in'],
|
74
|
+
['iPhone6.png', 'iOS-4.7-in'],
|
75
|
+
['iPhone6Plus1.png', 'iOS-5.5-in'],
|
76
|
+
['iPhone6Plus2.png', 'iOS-5.5-in'],
|
77
|
+
['screenshot1.png', 'iOS-4-in']
|
78
|
+
]
|
79
|
+
|
80
|
+
files.each do |value|
|
81
|
+
expect(Deliver::AppScreenshot.calculate_screen_size(p + value[0])).to eq(value[1])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
data/spec/app_spec.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
describe Deliver do
|
2
|
+
describe Deliver::App do
|
3
|
+
let (:apple_id) { 284882215 }
|
4
|
+
let (:app_identifier) { 'com.facebook.Facebook' }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "automatically fetches the app identifier, if only Apple ID is given" do
|
8
|
+
app = Deliver::App.new(apple_id: apple_id)
|
9
|
+
|
10
|
+
expect(app.app_identifier).to eq(app_identifier)
|
11
|
+
expect(app.apple_id).to eq(apple_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "lets me create an app using an Apple ID and app identifier" do
|
15
|
+
app = Deliver::App.new(apple_id: apple_id,
|
16
|
+
app_identifier: app_identifier)
|
17
|
+
|
18
|
+
expect(app.app_identifier).to eq(app_identifier)
|
19
|
+
expect(app.apple_id).to eq(apple_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "lets me create an app without any information given (yet)" do
|
23
|
+
expect(Deliver::App.new.app_identifier).to eq(nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "raises an exception if given app identifier is invalid" do
|
27
|
+
expect {
|
28
|
+
Deliver::App.new(app_identifier: 'net.sunapps.invalid')
|
29
|
+
}.to raise_error("Please pass a valid Apple ID using 'apple_id'".red)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#to_s" do
|
34
|
+
it "returns a well formatted string" do
|
35
|
+
app = Deliver::App.new(apple_id: apple_id)
|
36
|
+
expect(app.to_s).to eq("#{apple_id} - #{app_identifier}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "Accessing App Metadata" do
|
41
|
+
let (:apple_id) { 794902327 }
|
42
|
+
before do
|
43
|
+
@app = Deliver::App.new(apple_id: apple_id, app_identifier: 'net.sunapps.1')
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#metadata_downloaded?" do
|
47
|
+
it "return false if not done yet" do
|
48
|
+
Deliver::ItunesTransporter.set_mock_file("spec/responses/transporter/download_valid_apple_id.txt")
|
49
|
+
|
50
|
+
expect(@app.metadata_downloaded?).to eq(false)
|
51
|
+
@app.metadata
|
52
|
+
expect(@app.metadata_downloaded?).to eq(true)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#set_metadata_directory" do
|
57
|
+
|
58
|
+
it "throws an exception when updating the location after accessing metadata" do
|
59
|
+
@app.metadata = Deliver::AppMetadata.new(@app, "./spec/fixtures/example1.itmsp/", false)
|
60
|
+
expect {
|
61
|
+
@app.set_metadata_directory("something")
|
62
|
+
}.to raise_error("Can not change metadata directory after accessing metadata of an app")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "let's the user modify the download directory" do
|
66
|
+
expect(@app.get_metadata_directory).to eq("./spec/fixtures/packages/")
|
67
|
+
|
68
|
+
alternative = '/tmp/'
|
69
|
+
@app.set_metadata_directory(alternative)
|
70
|
+
|
71
|
+
expect(@app.get_metadata_directory).to eq(alternative)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#upload_metadata!" do
|
77
|
+
it "throws an exception when metadata was not yet downloaded" do
|
78
|
+
expect {
|
79
|
+
@app.upload_metadata!
|
80
|
+
}.to raise_error("You first have to modify the metadata using app.metadata.setDescription")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|