-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
70 lines (58 loc) · 1.74 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
class ExampleAppCommand
class << self
def run(command)
new(command).run
end
end
def initialize(command)
@command = command
example_app = ENV.fetch('EXAMPLE_APP', 'demo_app')
@example_app_path = File.expand_path("./examples/#{example_app}", __dir__)
@gemfile_path = File.join(@example_app_path, 'Gemfile')
end
def run
print_description
specific_gemfile_env = Bundler.clean_env
specific_gemfile_env['BUNDLE_GEMFILE'] = @gemfile_path
Bundler.send(:with_env, specific_gemfile_env) do
exit_status_was_zero = system("cd #{@example_app_path} && #{@command}")
raise unless exit_status_was_zero
end
end
def print_description
puts '---------------------',
"Gemfile: #{@gemfile_path}",
"Directory: #{@example_app_path}",
"Command: '#{@command}'",
'---------------------'
end
end
namespace :test do
desc 'Run unit tests'
Rake::TestTask.new(:unit) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files =
FileList['test/**/*_test.rb'].exclude('test/integration/**/*')
end
desc 'Run integration tests in example app'
task :integration do
ExampleAppCommand.run('bundle exec rake test')
end
namespace :integration do
desc 'Resolve and install dependencies and build assets in example app'
task :prepare do
bundle_args = ENV.fetch('INTEGRATION_BUNDLE_ARGS', '')
ExampleAppCommand.run(
"bundle check #{bundle_args} || bundle install #{bundle_args}"
)
ExampleAppCommand.run('bin/yarn')
ExampleAppCommand.run('bin/yarn build')
end
end
end
task test: ['test:unit', 'test:integration']
task default: :test