-
Notifications
You must be signed in to change notification settings - Fork 36
/
Rakefile
56 lines (47 loc) · 1.36 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
require 'bundler'
Bundler.require
require 'bundler/gem_tasks'
require 'opal/rspec/rake_task'
Opal::RSpec::RakeTask.new(:broken_rspec) do |_, task|
task.default_path = 'spec'
task.pattern = 'spec/**/*_spec.{rb,opal}'
end
task(:nil) {}
%w[chrome edge gecko safari].each do |i|
desc "Run Selenium tests with #{i}"
task :"selenium_#{i}" do
server = Process.spawn("bundle", "exec", "rackup")
at_exit { Process.kill(9, server) rescue nil }
sleep 2
ENV['BROWSER'] = i
load 'spec/runner.rb'
ensure
Process.kill(9, server) rescue nil
end
end
task :default => :selenium_chrome
task :build_gh_pages do
require 'fileutils'
output_dir = __dir__+"/gh-pages/examples/"
FileUtils.mkdir_p output_dir
Dir['examples/*'].reject { |i| i =~ /integrations|svg/ }.each do |example_path|
example = File.basename(example_path)
output_example_dir = output_dir+"/"+example
FileUtils.mkdir_p output_example_dir
Dir.chdir(example_path) do
Bundler.with_unbundled_env do
`bundle install`
`bundle exec opal -qopal-browser -c app/application.rb > #{output_example_dir}/app.js`
end
File.write("#{output_example_dir}/index.html", <<~HTML)
<!DOCTYPE html>
<html>
<head></head>
<body>
<script src="app.js"></script>
</body>
</html>
HTML
end
end
end