reflex-packager 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
1
+ %w[../xot ../rucy ../rays ../reflex .]
2
+ .map {|s| File.expand_path "../#{s}/lib", __dir__}
3
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
+
5
+ require 'xot/test'
6
+ require 'reflex/extension'
7
+ require 'reflex/packager'
8
+
9
+ require 'test/unit'
10
+ require 'tmpdir'
11
+
12
+ include Xot::Test
13
+
14
+
15
+ TEST_PROFILE = Reflex::Packager::Profile.new(
16
+ pod: 'Reflex',
17
+ git: 'https://github.com/xord/reflex',
18
+ version: Reflex::Extension.version,
19
+ libraries: %w[Xot Rucy Rays Reflex],
20
+ extensions: %w[rays_ext reflex_ext],
21
+ config_files: %w[reflex.yml reflex.yaml],
22
+ template: <<~RUBY)
23
+ require 'reflex'
24
+
25
+ Reflex.start do
26
+ Reflex::Window.new(title: '{{name}}', frame: [100, 100, 400, 300]).show
27
+ end
28
+ RUBY
@@ -0,0 +1,80 @@
1
+ require_relative 'helper'
2
+
3
+ require 'stringio'
4
+ require 'fileutils'
5
+
6
+
7
+ class TestPackagerCLI < Test::Unit::TestCase
8
+
9
+ RP = Reflex::Packager
10
+ CLI = RP::CLI
11
+
12
+ def capture(&block)
13
+ old = [$stdout, $stderr]
14
+ out, err = StringIO.new, StringIO.new
15
+ $stdout, $stderr = out, err
16
+ block.call
17
+ return out.string, err.string
18
+ ensure
19
+ $stdout, $stderr = old
20
+ end
21
+
22
+ def tmpdir(&block)
23
+ Dir.mktmpdir {|dir| Dir.chdir(dir) {block.call dir}}
24
+ end
25
+
26
+ def cli()
27
+ CLI.new TEST_PROFILE
28
+ end
29
+
30
+ def test_run()
31
+ out, = capture {cli.run []}
32
+ assert_include out, 'Usage: reflex'
33
+
34
+ out, = capture {cli.run ['--version']}
35
+ assert_equal Reflex::Extension.version, out.strip
36
+
37
+ assert_raise(SystemExit) {capture {cli.run ['unknown']}}
38
+ end
39
+
40
+ def test_new()
41
+ tmpdir do
42
+ capture {cli.create ['myapp']}
43
+ assert File.file?('myapp/main.rb')
44
+ assert File.file?('myapp/reflex.yml')
45
+
46
+ main = File.read('myapp/main.rb')
47
+ assert_include main, "require 'reflex'"
48
+ assert_include main, 'Reflex.start'
49
+
50
+ config = RP::Config.load TEST_PROFILE, 'myapp'
51
+ assert_equal 'myapp', config.name
52
+ assert_equal 'main.rb', config.main
53
+ end
54
+
55
+ tmpdir do
56
+ FileUtils.mkdir 'myapp'
57
+ assert_raise(RP::Error) {cli.create ['myapp']}
58
+ end
59
+
60
+ assert_raise(RP::Error) {cli.create []}
61
+ end
62
+
63
+ def test_package()
64
+ tmpdir do
65
+ capture {cli.create ['myapp']}
66
+ cli.package ['--generate-only', 'myapp']
67
+ %w[project.yml Podfile src/main.mm app/main.rb].each do |f|
68
+ assert File.exist?("myapp/build/macos/#{f}"), "missing #{f}"
69
+ end
70
+ end
71
+
72
+ tmpdir do
73
+ capture {cli.create ['myapp']}
74
+ assert_raise(RP::Error) do
75
+ cli.package ['--generate-only', '--platform', 'unknown', 'myapp']
76
+ end
77
+ end
78
+ end
79
+
80
+ end# TestPackagerCLI
@@ -0,0 +1,240 @@
1
+ # -*- coding: utf-8 -*-
2
+ require_relative 'helper'
3
+
4
+
5
+ class TestPackagerConfig < Test::Unit::TestCase
6
+
7
+ RP = Reflex::Packager
8
+ Config = RP::Config
9
+ MacOSConfig = RP::MacOSConfig
10
+
11
+ MAIN = File.basename(__FILE__)
12
+
13
+ def config(dir: __dir__, main: nil, parent: nil, stderr: nil, **hash)
14
+ main ||= MAIN
15
+ Config.new TEST_PROFILE, dir, {main: main, **hash}, stderr: stderr
16
+ end
17
+
18
+ def load_config(dir, path = nil)
19
+ Config.load TEST_PROFILE, dir, path
20
+ end
21
+
22
+ def stderr()
23
+ [].tap {|array|
24
+ def array.puts(s) = self << s
25
+ }
26
+ end
27
+
28
+ def touch(path, data = '')
29
+ FileUtils.mkdir_p File.dirname path
30
+ File.write path, data
31
+ end
32
+
33
+ def tmpdir(
34
+ yaml_path: 'reflex.yaml',
35
+ yaml: '',
36
+ main_path: 'main.rb',
37
+ main: '',
38
+ &block)
39
+
40
+ Dir.mktmpdir do |dir|
41
+ Dir.chdir dir do
42
+ File.write yaml_path, yaml if yaml_path && yaml
43
+ File.write main_path, main if main_path && main
44
+ block.call dir
45
+ end
46
+ end
47
+ end
48
+
49
+ def test_load()
50
+ tmpdir {|dir| assert_equal 'main.rb', load_config(dir).main}
51
+ tmpdir(yaml: nil) {|dir| assert_equal 'main.rb', load_config(dir).main}
52
+ tmpdir(yaml: 'a: b: c') {|dir| assert_raise(RP::Error) {load_config dir}}
53
+ tmpdir {|dir| assert_raise(RP::Error) {load_config "#{dir}/nodir"}}
54
+
55
+ tmpdir(yaml_path: '1.yaml') {|dir| assert_equal 'main.rb', load_config(dir, '1.yaml').main}
56
+ tmpdir {|dir| assert_raise(RP::Error) {load_config dir, '2.yaml'}}
57
+ tmpdir(yaml_path: '3.yml') {|dir| assert_raise(RP::Error) {load_config dir, '3.yaml'}}
58
+ tmpdir(yaml_path: '4.yaml') {|dir| assert_raise(RP::Error) {load_config dir, '4.yml'}}
59
+
60
+ tmpdir(yaml: 'name: 5') {|dir| assert_equal '5', load_config(dir).name}
61
+
62
+ tmpdir(yaml_path: 'reflex.yml', yaml: 'main: 6.rb', main_path: '6.rb') {|dir|
63
+ File.write 'reflex.yaml', 'main: 7.rb'
64
+ assert_equal '6.rb', load_config(dir).main
65
+ }
66
+ end
67
+
68
+ def test_load_full_config()
69
+ tmpdir yaml: <<~YAML, main_path: 'app.rb' do |dir|
70
+ name: My App
71
+ bundle_id: com.example.myapp
72
+ version: 1.2.3
73
+ main: app.rb
74
+ icon: icon.png
75
+ files: ['*.rb', data]
76
+ pods:
77
+ reflex: {git: https://example.com/reflex, tag: v1}
78
+ macos:
79
+ deployment_target: '12.0'
80
+ archs: [arm64, x86_64]
81
+ codesign: {identity: Developer ID, team_id: ABCDE12345}
82
+ YAML
83
+ touch 'icon.png'
84
+ touch '1.rb'
85
+ touch 'data/2.json'
86
+ c = load_config dir
87
+ assert_equal 'My App', c.name
88
+ assert_equal 'com.example.myapp', c.bundle_id
89
+ assert_equal '1.2.3', c.version
90
+ assert_equal 'app.rb', c.main
91
+ assert_equal 'icon.png', c.icon
92
+ assert_equal %w[*.rb data], c.files
93
+ assert_equal %w[1.rb app.rb data], c.app_files
94
+ assert_equal({git: 'https://example.com/reflex', tag: 'v1'}, c.pods[:reflex])
95
+ assert_equal '12.0', c.macos.deployment_target
96
+ assert_equal %w[arm64 x86_64], c.macos.archs
97
+ assert_equal 'Developer ID', c.macos.codesign_identity
98
+ assert_equal 'ABCDE12345', c.macos.codesign_team_id
99
+ end
100
+ end
101
+
102
+ def test_name()
103
+ assert_equal 'test', config() .name
104
+ assert_equal '1', config(name: 1) .name
105
+ assert_equal 'test', config(name: nil).name
106
+ end
107
+
108
+ def test_bundle_id()
109
+ assert_equal 'org.xord.reflex.test', config() .bundle_id
110
+ assert_equal 'a.b', config(bundle_id: 'a.b') .bundle_id
111
+ assert_equal 'org.xord.reflex.name-1', config( name: 'Name-1').bundle_id
112
+ assert_equal 'org.xord.reflex.name-2', config('name' => 'Name-2').bundle_id
113
+ assert_raise(RP::Error) {config bundle_id: ''}
114
+ assert_raise(RP::Error) {config bundle_id: 'a'}
115
+ assert_raise(RP::Error) {config bundle_id: 'a.'}
116
+ assert_raise(RP::Error) {config name: 'アプリ'}
117
+ end
118
+
119
+ def test_version()
120
+ assert_equal '0.1.0', config() .version
121
+ assert_equal '1', config(version: '1') .version
122
+ assert_equal '2.3', config(version: '2.3').version
123
+ assert_equal '0.1.0', config(version: nil) .version
124
+ assert_raise(RP::Error) {config version: '4.'}
125
+ end
126
+
127
+ def test_main()
128
+ assert_equal 'test_packager_config.rb', config() .main
129
+ assert_equal 'helper.rb', config(main: 'helper.rb').main
130
+ assert_raise(RP::Error) {config main: 'nofile.rb'}
131
+ end
132
+
133
+ def test_icon()
134
+ assert_nil config() .icon
135
+ assert_equal 'helper.rb', config(icon: 'helper.rb').icon
136
+ assert_raise(RP::Error) {config icon: 'nofile.png'}
137
+ end
138
+
139
+ def test_files()
140
+ assert_nil config() .files
141
+ assert_equal %w[helper.rb], config(files: 'helper.rb').files
142
+ assert_equal %w[a b], config(files: %w[a b]) .files
143
+ end
144
+
145
+ def test_pods()
146
+ assert_equal({cruby: {}, reflex: {}}, config() .pods)
147
+ assert_equal({tag: '6'}, config(pods: {cruby: {tag: '6'}}).pods[:cruby])
148
+ assert_equal({branch: '7'}, config(pods: {cruby: {branch: '7'}}).pods[:cruby])
149
+ assert_equal({git: '8'}, config(pods: {cruby: {git: '8'}}).pods[:cruby])
150
+ assert_equal({path: '9'}, config(pods: {cruby: {path: '9'}}).pods[:cruby])
151
+ end
152
+
153
+ def test_app_files()
154
+ tmpdir do |dir|
155
+ touch 'x.rb'
156
+ assert_equal %w[main.rb], load_config(dir).app_files
157
+ end
158
+
159
+ tmpdir yaml: "files: ['*']" do |dir|
160
+ touch 'x.rb'
161
+ assert_equal %w[main.rb x.rb], load_config(dir).app_files
162
+ end
163
+
164
+ tmpdir yaml: "files: ['*']" do |dir|
165
+ %w[build dist].each {Dir.mkdir _1}
166
+ touch 'build/1.rb'
167
+ touch 'dist/2.rb'
168
+ assert_equal %w[main.rb], load_config(dir).app_files
169
+ end
170
+
171
+ tmpdir yaml_path: 'a.yaml', yaml: <<~YAML, main_path: 'b.rb' do |dir|
172
+ main: b.rb
173
+ files: '*'
174
+ YAML
175
+ %w[c.json d.png].each {touch _1}
176
+ assert_equal(
177
+ %w[a.yaml b.rb c.json d.png],
178
+ load_config(dir, 'a.yaml').app_files.map {File.basename _1})
179
+ end
180
+ end
181
+
182
+ def test_macos_deployment_target()
183
+ assert_equal '11.0', config() .macos.deployment_target
184
+ assert_equal '11.0', config(macos: {}) .macos.deployment_target
185
+ assert_equal '1', config(macos: {deployment_target: 1}) .macos.deployment_target
186
+ assert_equal '11.0', config(macos: {deployment_target: nil}).macos.deployment_target
187
+ assert_raise(RP::Error) {config(macos: {deployment_target: {}})}
188
+ end
189
+
190
+ def test_macos_archs()
191
+ assert_equal ['arm64'], config() .macos.archs
192
+ assert_equal ['arm64'], config(macos: {}) .macos.archs
193
+ assert_equal ['1'], config(macos: {archs: 1}) .macos.archs
194
+ assert_equal ['2', '3'], config(macos: {archs: [2, 3]}).macos.archs
195
+ assert_equal ['arm64'], config(macos: {archs: nil}) .macos.archs
196
+ assert_raise(RP::Error) {config(macos: {archs: []})}
197
+ assert_raise(RP::Error) {config(macos: {archs: {}})}
198
+ end
199
+
200
+ def test_macos_codesign_identity()
201
+ assert_equal '-', config() .macos.codesign_identity
202
+ assert_equal '-', config(macos: {}) .macos.codesign_identity
203
+ assert_equal '-', config(macos: {codesign: {}}) .macos.codesign_identity
204
+ assert_equal '-', config(macos: {codesign: nil}) .macos.codesign_identity
205
+ assert_equal '1', config(macos: {codesign: {identity: 1}}) .macos.codesign_identity
206
+ assert_equal '-', config(macos: {codesign: {identity: nil}}).macos.codesign_identity
207
+ assert_raise(RP::Error) {config(macos: {codesign: 2})}
208
+ assert_raise(RP::Error) {config(macos: {codesign: {identity: {}}})}
209
+ end
210
+
211
+ def test_macos_codesign_team_id()
212
+ assert_nil config() .macos.codesign_team_id
213
+ assert_nil config(macos: {}) .macos.codesign_team_id
214
+ assert_nil config(macos: {codesign: {}}) .macos.codesign_team_id
215
+ assert_nil config(macos: {codesign: nil}) .macos.codesign_team_id
216
+ assert_equal '1', config(macos: {codesign: {team_id: 1}}) .macos.codesign_team_id
217
+ assert_nil config(macos: {codesign: {team_id: nil}}).macos.codesign_team_id
218
+ assert_raise(RP::Error) {config(macos: {codesign: 2})}
219
+ assert_raise(RP::Error) {config(macos: {codesign: {team_id: {}}})}
220
+ end
221
+
222
+ def test_warn_unknown_key()
223
+ e = stderr
224
+
225
+ config stderr: e, k1: 1
226
+ assert_equal "unknown key '/k1'", e.shift
227
+
228
+ config stderr: e, macos: {k2: 2}
229
+ assert_equal "unknown key '/macos/k2'", e.shift
230
+
231
+ config stderr: e, macos: {codesign: {k3: 3}}
232
+ assert_equal "unknown key '/macos/codesign/k3'", e.shift
233
+ end
234
+
235
+ def test_invalid_value_type()
236
+ assert_raise(RP::Error) {config macos: 'arm64'}
237
+ assert_raise(RP::Error) {config pods: ['cruby']}
238
+ end
239
+
240
+ end# TestPackagerConfig
@@ -0,0 +1,225 @@
1
+ # -*- coding: utf-8 -*-
2
+ require_relative 'helper'
3
+
4
+
5
+ class TestPackagerMacOS < Test::Unit::TestCase
6
+
7
+ RP = Reflex::Packager
8
+ MacOS = RP::MacOS
9
+
10
+ def packager(yaml = nil, files: ['main.rb'], env: {}, &block)
11
+ Dir.mktmpdir do |dir|
12
+ files.each do |f|
13
+ path = File.join dir, f
14
+ FileUtils.mkdir_p File.dirname(path)
15
+ FileUtils.touch path
16
+ end
17
+ File.write File.join(dir, 'reflex.yml'), yaml if yaml
18
+ with_env({'REFLEX_PODS_PATH' => nil}.merge(env)) do
19
+ config = RP::Config.load TEST_PROFILE, dir
20
+ block.call MacOS.new(config), dir
21
+ end
22
+ end
23
+ end
24
+
25
+ def with_env(env, &block)
26
+ saved = env.map {|key, _| [key, ENV[key]]}
27
+ env.each {|key, value| value ? ENV[key] = value : ENV.delete(key)}
28
+ block.call
29
+ ensure
30
+ saved.each {|key, value| value ? ENV[key] = value : ENV.delete(key)}
31
+ end
32
+
33
+ def read(dir, path)
34
+ File.read File.join(dir, 'build', 'macos', path)
35
+ end
36
+
37
+ # --- generate ----------------------------------------------------------
38
+
39
+ def test_generate_creates_files()
40
+ packager do |pkg, dir|
41
+ pkg.generate
42
+ %w[project.yml Podfile src/main.mm app/main.rb].each do |f|
43
+ assert File.exist?(File.join dir, 'build/macos', f), "missing #{f}"
44
+ end
45
+ end
46
+ end
47
+
48
+ def test_app_dir_includes_files_and_excludes_build()
49
+ packager "files: [data]", files: %w[main.rb data/x.png] do |pkg, dir|
50
+ pkg.generate
51
+ pkg.generate # regenerating must not nest a previous build/ into app/
52
+ app = File.join dir, 'build/macos/app'
53
+ assert File.exist?(File.join app, 'data/x.png')
54
+ assert !File.exist?(File.join app, 'build')
55
+ end
56
+ end
57
+
58
+ def test_project_yml()
59
+ packager "name: My App\nbundle_id: com.example.myapp" do |pkg, dir|
60
+ pkg.generate
61
+ str = read dir, 'project.yml'
62
+ yml = YAML.safe_load str
63
+ base = yml.dig 'settings', 'base'
64
+ assert_equal 'MyApp', yml['name']
65
+ assert_equal 'com.example.myapp', base['PRODUCT_BUNDLE_IDENTIFIER']
66
+ assert_equal '0.1.0', base['MARKETING_VERSION']
67
+ assert_equal 'arm64', base['ARCHS']
68
+ assert_equal '-', base['CODE_SIGN_IDENTITY']
69
+ assert_equal '11.0', yml.dig('options', 'deploymentTarget', 'macOS')
70
+ assert_not_include str, 'CFBundleIconFile'
71
+ assert_not_include str, 'DEVELOPMENT_TEAM'
72
+ end
73
+ end
74
+
75
+ def test_project_yml_with_icon_and_team()
76
+ yaml = <<~YML
77
+ icon: icon.png
78
+ macos:
79
+ codesign: {team_id: ABCDE12345}
80
+ YML
81
+ packager yaml, files: %w[main.rb icon.png] do |pkg, dir|
82
+ # render only: a full generate would shell out to sips / iconutil
83
+ str = pkg.__send__ :render, 'project.yml.erb'
84
+ assert_include str, 'CFBundleIconFile: AppIcon'
85
+ assert_include str, 'path: AppIcon.icns'
86
+ assert_include str, 'DEVELOPMENT_TEAM: ABCDE12345'
87
+ end
88
+ end
89
+
90
+ # --- build (checked before shelling out to xcodegen / pod / xcodebuild) -
91
+
92
+ def test_check_tools_reports_missing()
93
+ packager do |pkg, _|
94
+ with_env 'PATH' => '' do
95
+ error = assert_raise(RP::Error) {pkg.__send__ :check_tools, MacOS::TOOLS}
96
+ assert_include error.message, 'xcodegen'
97
+ assert_include error.message, 'brew install xcodegen'
98
+ end
99
+ end
100
+ end
101
+
102
+ # Runs the block with a packager whose CRuby / Reflex pods resolve to
103
+ # local directories under +repos+ (via REFLEX_PODS_PATH).
104
+ def with_pods(repos, &block)
105
+ packager(nil, env: {'REFLEX_PODS_PATH' => repos}) {|pkg, _| block.call pkg}
106
+ end
107
+
108
+ def test_check_dev_pods_missing_dir()
109
+ Dir.mktmpdir do |repos|
110
+ with_pods repos do |pkg| # neither repos/cruby nor repos/reflex exists
111
+ error = assert_raise(RP::Error) {pkg.__send__ :check_dev_pods}
112
+ assert_include error.message, 'pod directory not found'
113
+ end
114
+ end
115
+ end
116
+
117
+ def test_check_dev_pods_cruby_not_built()
118
+ Dir.mktmpdir do |repos|
119
+ FileUtils.mkdir_p File.join(repos, 'cruby') # exists but has no CRuby/include
120
+ with_pods repos do |pkg|
121
+ error = assert_raise(RP::Error) {pkg.__send__ :check_dev_pods}
122
+ assert_include error.message, 'no CRuby binary'
123
+ assert_include error.message, 'download_or_build'
124
+ end
125
+ end
126
+ end
127
+
128
+ def test_check_dev_pods_reflex_not_set_up()
129
+ Dir.mktmpdir do |repos|
130
+ FileUtils.mkdir_p File.join(repos, 'cruby', 'CRuby', 'include') # CRuby is OK
131
+ FileUtils.mkdir_p File.join(repos, 'reflex') # exists but has no xot
132
+ with_pods repos do |pkg|
133
+ error = assert_raise(RP::Error) {pkg.__send__ :check_dev_pods}
134
+ assert_include error.message, 'not set up for CocoaPods'
135
+ assert_include error.message, 'pod.rake setup'
136
+ end
137
+ end
138
+ end
139
+
140
+ def test_copy_app_without_build_product_raises()
141
+ packager do |pkg, _|
142
+ # nothing was built, so the .app is not under DerivedData
143
+ error = assert_raise(RP::Error) {pkg.__send__ :copy_app}
144
+ assert_include error.message, 'application not found'
145
+ end
146
+ end
147
+
148
+ # --- target ------------------------------------------------------------
149
+
150
+ def test_target_strips_unsafe_chars()
151
+ # a non-ascii name needs an explicit bundle_id (one cannot be derived),
152
+ # so set it here to keep the focus on target-name normalization
153
+ packager("name: My App!") {|pkg, _| assert_equal 'MyApp', pkg.target}
154
+ packager("name: アプリ\nbundle_id: com.example.app") {|pkg, _| assert_equal 'App', pkg.target}
155
+ end
156
+
157
+ # --- extensions / libraries (registered with CRuby in main.mm) ---------
158
+
159
+ def test_main_mm_registers_runtime_and_starts()
160
+ packager "main: app.rb", files: %w[app.rb] do |pkg, dir|
161
+ pkg.generate
162
+ str = read dir, 'src/main.mm'
163
+ assert_include str, '@"app.rb"' # the entry script
164
+ assert_include str, 'Init_reflex_ext' # native ext registered
165
+ assert_include str, 'Init_rays_ext'
166
+ assert_include str, '@"Reflex"' # library bundle added
167
+ assert_include str, 'changeCurrentDirectoryPath' # cwd set to app dir
168
+ assert_include str, '@"app"' # the bundled app dir
169
+ assert_include str, '[CRuby start:main]'
170
+ end
171
+ end
172
+
173
+ # --- pod_refs / dev_pod_paths (rendered into the Podfile) --------------
174
+
175
+ def test_podfile_defaults_to_git_pods()
176
+ packager do |pkg, dir|
177
+ pkg.generate
178
+ str = read dir, 'Podfile'
179
+ assert_include str, "pod 'CRuby', git: 'https://github.com/xord/cruby'"
180
+ assert_include str,
181
+ "pod 'Reflex', git: 'https://github.com/xord/reflex', " +
182
+ "tag: 'v#{Reflex::Extension.version}'"
183
+ assert_not_include str, 'PODS_ROOT'
184
+ end
185
+ end
186
+
187
+ def test_podfile_with_pods_path_env()
188
+ packager nil, env: {'REFLEX_PODS_PATH' => '/repos'} do |pkg, dir|
189
+ pkg.generate
190
+ str = read dir, 'Podfile'
191
+ assert_include str, "pod 'CRuby', path: '/repos/cruby'"
192
+ assert_include str, "pod 'Reflex', path: '/repos/reflex'"
193
+ # development pods need the ${PODS_ROOT} rewrite block
194
+ assert_include str, "s.gsub! '${PODS_ROOT}/CRuby', '/repos/cruby'"
195
+ assert_include str, "s.gsub! '${PODS_ROOT}/Reflex', '/repos/reflex'"
196
+ end
197
+ end
198
+
199
+ def test_podfile_with_pods_config()
200
+ yaml = <<~YML
201
+ pods:
202
+ cruby: {git: https://example.com/cruby, branch: dev}
203
+ YML
204
+ packager yaml do |pkg, dir|
205
+ pkg.generate
206
+ line = read(dir, 'Podfile').lines.grep(/pod 'CRuby'/).first
207
+ assert_match %r{git: 'https://example.com/cruby'}, line
208
+ assert_match %r{branch: 'dev'}, line
209
+ end
210
+ end
211
+
212
+ # --- icon_commands -----------------------------------------------------
213
+
214
+ def test_icon_commands()
215
+ packager do |pkg, _|
216
+ cmds = pkg.icon_commands 'icon.png', 'AppIcon.iconset'
217
+ assert_equal 10, cmds.size
218
+ assert_include cmds,
219
+ %w[sips -z 16 16 icon.png --out AppIcon.iconset/icon_16x16.png]
220
+ assert_include cmds,
221
+ %w[sips -z 1024 1024 icon.png --out AppIcon.iconset/icon_512x512@2x.png]
222
+ end
223
+ end
224
+
225
+ end# TestPackagerMacOS