forked from teamcapybara/capybara
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
99 lines (83 loc) · 2.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# frozen_string_literal: true
require 'rubygems'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
require 'yard'
require 'rubocop/rake_task'
RuboCop::RakeTask.new
desc 'Run all examples with Firefox'
rspec_opts = %w[--color]
RSpec::Core::RakeTask.new(:spec_firefox) do |t|
t.rspec_opts = rspec_opts
t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_firefox.rb}'
end
%w[chrome ie edge chrome_remote firefox_remote safari].each do |driver|
desc "Run tests using #{driver} driver"
RSpec::Core::RakeTask.new(:"spec_#{driver}") do |t|
t.rspec_opts = rspec_opts
t.pattern = "./spec/{selenium_spec_#{driver}.rb}"
end
end
RSpec::Core::RakeTask.new(:spec_sauce) do |t|
t.rspec_opts = rspec_opts
t.pattern = './spec/sauce_spec_chrome.rb'
end
# RSpec::Core::RakeTask.new(:spec_rack, [] => :rubocop) do |t|
RSpec::Core::RakeTask.new(:spec_rack) do |t|
t.rspec_opts = rspec_opts
t.pattern = './spec{,/*/**}/*{_spec.rb}'
end
desc 'Run specs with Firefox'
task spec: [:spec_firefox]
desc 'Run basic smoke tests (rack test and rubocop)'
task rack_smoke: %i[rubocop spec_rack]
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb']
end
Cucumber::Rake::Task.new(:cucumber) do |task|
task.cucumber_opts = ['--format=progress', '--publish-quiet', 'features']
end
desc 'Task for running CI'
task :travis do
if ENV.fetch('CAPYBARA_REMOTE', nil) && ENV.fetch('CAPYBARA_FF', nil)
Rake::Task[:spec_firefox_remote].invoke
elsif ENV.fetch('CAPYBARA_FF', nil)
Rake::Task[:spec_firefox].invoke
elsif ENV.fetch('CAPYBARA_IE', nil)
Rake::Task[:spec_ie].invoke
elsif ENV.fetch('CAPYBARA_EDGE', nil)
Rake::Task[:spec_edge].invoke
elsif ENV.fetch('CAPYBARA_REMOTE', nil)
Rake::Task[:spec_chrome_remote].invoke
else
Rake::Task[:spec_chrome].invoke
end
Rake::Task[:cucumber].invoke
end
desc 'Build updated JS replacements for Selenium atoms'
task :build_js do
require 'uglifier'
Dir.glob('./lib/capybara/selenium/atoms/src/*.js').each do |fn|
js = Uglifier.compile(
File.read(fn),
compress: {
negate_iife: false, # Negate immediately invoked function expressions to avoid extra parens
side_effects: false # Pass false to disable potentially dropping functions marked as "pure"
}
)[0...-1]
File.write("./lib/capybara/selenium/atoms/#{File.basename(fn).gsub('.js', '.min.js')}", js)
end
end
desc 'Release new version'
task :release do
version = Capybara::VERSION
puts "Releasing #{version}, y/n?"
exit(1) unless $stdin.gets.chomp == 'y'
sh "git commit -am 'tagged #{version}' && " \
"git tag #{version} && " \
'gem build capybara.gemspec && ' \
"gem push capybara-#{version}.gem && " \
'git push && ' \
'git push --tags'
end
task default: %i[spec cucumber]