snapshot 0.6.1 → 0.7.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: abb441723ec5d8919da77815f6f0a1b1b4b080ee
4
- data.tar.gz: b39ed6ef457d26b551c512f29533efcee29a00d9
3
+ metadata.gz: 8b7ef10f6e12380310c76e6ced44550c9ae5a2c2
4
+ data.tar.gz: 120e6691fd0afa1ef2d0adbed6ce688e7ee9c723
5
5
  SHA512:
6
- metadata.gz: 618a96767d35d67ab98d99088fdd4e66b7d603631973e820c136efaa62f32a9dfff72a59de49bd0ae46badf10c60494137d6eab6c5941d9f3259bb0914e1ab11
7
- data.tar.gz: 8b9d135eac10e162c969b75020c1f2cfb7081b90c1fbbbb81d0f7a6c4aec8b9796070b8fe40cad0ed457e53dbd2fe3acab127f43184bba36e35416e750a48699
6
+ metadata.gz: c2fb55b160f240f56c9ea8ca8ffc9328e025c25d1a7a43ac1fb11d78a362590128b6e7a8f71e8036b097e3c6491eea98854fbe90948bc5a939095cb1a966d1ff
7
+ data.tar.gz: bd014a18b50266f83502bf9eb8eeb5e0cc4ecc641b5630529c14957bccb0cefa7af7c8d4ef10a0680c79f578e1125487c666c4e4d39c8c66fc79e1aaae15e1d9
data/README.md CHANGED
@@ -191,7 +191,8 @@ devices([
191
191
  languages([
192
192
  "en-US",
193
193
  "de-DE",
194
- "es-ES"
194
+ "es-ES",
195
+ ["cmn-Hans", "cmn-Hans_CN"] # you can specify a locale if needed
195
196
  ])
196
197
  ```
197
198
 
@@ -242,6 +243,13 @@ Here is an example for adding a preprocessor macro `SNAPSHOT` and a custom buil
242
243
  custom_build_args "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SNAPSHOT=1' SNAPSHOT_ENABLE = YES"
243
244
  ```
244
245
 
246
+ ### Custom Args for the run command
247
+ Add a ```custom_run_args``` line to your ```Snapfile``` to add custom arguments to the run command (i.e. the invocation of `instruments`. You can use this to set the value of a specific `NSUserDefaults` key, for example
248
+
249
+ ```ruby
250
+ custom_run_args "-DidViewOnboarding YES"
251
+ ```
252
+
245
253
  ### Custom Build Command
246
254
  If for some reason, the default build command does not work for your project, you can pass your own build script. The script will be executed **once** before the tests are being run.
247
255
 
@@ -17,13 +17,21 @@ module Snapshot
17
17
  FileUtils.rm_rf SnapshotConfig.shared_instance.screenshots_path if SnapshotConfig.shared_instance.clear_previous_screenshots
18
18
 
19
19
  SnapshotConfig.shared_instance.devices.each do |device|
20
- SnapshotConfig.shared_instance.languages.each do |language|
21
- reinstall_app(device, language) unless ENV["SNAPSHOT_SKIP_UNINSTALL"]
20
+ SnapshotConfig.shared_instance.languages.each do |language_item|
21
+
22
+ if language_item.instance_of?String
23
+ language = language_item
24
+ locale = language_item
25
+ else
26
+ (language, locale) = language_item
27
+ end
28
+
29
+ reinstall_app(device, language, locale) unless ENV["SNAPSHOT_SKIP_UNINSTALL"]
22
30
 
23
31
  prepare_simulator(device, language)
24
32
 
25
33
  begin
26
- errors.concat(run_tests(device, language))
34
+ errors.concat(run_tests(device, language, locale))
27
35
  counter += copy_screenshots(language)
28
36
  rescue => ex
29
37
  Helper.log.error(ex)
@@ -72,7 +80,7 @@ module Snapshot
72
80
  raise "Could not find simulator '#{name}' to install the app on."
73
81
  end
74
82
 
75
- def reinstall_app(device, language)
83
+ def reinstall_app(device, language, locale)
76
84
 
77
85
  app_identifier = ENV["SNAPSHOT_APP_IDENTIFIER"]
78
86
  app_identifier ||= @app_identifier
@@ -95,13 +103,13 @@ module Snapshot
95
103
  com("xcrun simctl shutdown booted")
96
104
  end
97
105
 
98
- def run_tests(device, language)
99
- Helper.log.info "Running tests on #{device} in language #{language}".green
100
-
106
+ def run_tests(device, language, locale)
107
+ Helper.log.info "Running tests on #{device} in language #{language} (locale #{locale})".green
108
+
101
109
  clean_old_traces
102
110
 
103
111
  ENV['SNAPSHOT_LANGUAGE'] = language
104
- command = generate_test_command(device, language)
112
+ command = generate_test_command(device, language, locale)
105
113
  Helper.log.debug command.yellow
106
114
 
107
115
  retry_run = false
@@ -145,7 +153,7 @@ module Snapshot
145
153
  if retry_run
146
154
  Helper.log.error "Instruments tool failed again. Re-trying..."
147
155
  sleep 2 # We need enough sleep... that's an instruments bug
148
- errors = run_tests(device, language)
156
+ errors = run_tests(device, language, locale)
149
157
  end
150
158
 
151
159
  return errors
@@ -200,9 +208,10 @@ module Snapshot
200
208
  return Dir.glob("#{TRACE_DIR}/**/*.png").count
201
209
  end
202
210
 
203
- def generate_test_command(device, language)
211
+ def generate_test_command(device, language, locale)
204
212
  is_ipad = (device.downcase.include?'ipad')
205
213
  script_path = SnapshotConfig.shared_instance.js_file(is_ipad)
214
+ custom_run_args = SnapshotConfig.shared_instance.custom_run_args || ENV["SNAPSHOT_CUSTOM_RUN_ARGS"] || ''
206
215
 
207
216
  [
208
217
  "instruments",
@@ -213,7 +222,8 @@ module Snapshot
213
222
  "-e UIARESULTSPATH '#{TRACE_DIR}'",
214
223
  "-e UIASCRIPT '#{script_path}'",
215
224
  "-AppleLanguages '(#{language})'",
216
- "-AppleLocale '#{language}'"
225
+ "-AppleLocale '#{locale}'",
226
+ custom_run_args,
217
227
  ].join(' ')
218
228
  end
219
229
  end
@@ -43,6 +43,9 @@ module Snapshot
43
43
  # @return (String) This will be appended to the actual build command
44
44
  attr_accessor :custom_build_args
45
45
 
46
+ # @return (String) This will be appended to the run command
47
+ attr_accessor :custom_run_args
48
+
46
49
  # @return (Hash) All the blocks, which are called on specific actions
47
50
  attr_accessor :blocks
48
51
 
@@ -53,6 +53,9 @@ module Snapshot
53
53
  when :custom_build_args
54
54
  raise "custom_build_args has to be an String".red unless value.kind_of?String
55
55
  @config.custom_build_args = value
56
+ when :custom_run_args
57
+ raise "custom_run_args has to be an String".red unless value.kind_of?String
58
+ @config.custom_run_args = value
56
59
  when :skip_alpha_removal
57
60
  @config.skip_alpha_removal = true
58
61
  when :clear_previous_screenshots
@@ -1,3 +1,3 @@
1
1
  module Snapshot
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-12 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage