2018-04-18 16:45:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2010-09-17 19:56:32 -04:00
|
|
|
require 'rubygems'
|
2010-09-17 20:23:13 -04:00
|
|
|
require 'rspec/core/rake_task'
|
2012-01-26 08:58:25 -05:00
|
|
|
require 'cucumber/rake/task'
|
2010-09-17 19:56:32 -04:00
|
|
|
require 'yard'
|
2019-03-27 13:43:43 -04:00
|
|
|
require 'rubocop/rake_task'
|
|
|
|
|
|
|
|
RuboCop::RakeTask.new
|
2010-09-17 19:56:32 -04:00
|
|
|
|
2018-11-18 16:27:00 -05:00
|
|
|
desc 'Run all examples with Firefox'
|
2014-03-31 18:10:27 -04:00
|
|
|
|
2018-04-24 18:47:53 -04:00
|
|
|
rspec_opts = %w[--color]
|
|
|
|
|
2018-11-18 16:27:00 -05:00
|
|
|
RSpec::Core::RakeTask.new(:spec_firefox) do |t|
|
2018-04-24 18:47:53 -04:00
|
|
|
t.rspec_opts = rspec_opts
|
2018-11-18 16:27:00 -05:00
|
|
|
t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_firefox.rb}'
|
2013-02-25 14:13:03 -05:00
|
|
|
end
|
2010-09-17 19:56:32 -04:00
|
|
|
|
2019-03-13 21:21:53 -04:00
|
|
|
%w[chrome ie edge chrome_remote firefox_remote safari].each do |driver|
|
2020-12-28 12:55:56 -05:00
|
|
|
desc "Run tests using #{driver} driver"
|
2018-03-17 07:55:00 -04:00
|
|
|
RSpec::Core::RakeTask.new(:"spec_#{driver}") do |t|
|
2018-04-24 18:47:53 -04:00
|
|
|
t.rspec_opts = rspec_opts
|
2019-03-28 14:08:35 -04:00
|
|
|
t.pattern = "./spec/{selenium_spec_#{driver}.rb}"
|
2018-03-17 07:55:00 -04:00
|
|
|
end
|
2015-05-21 14:00:36 -04:00
|
|
|
end
|
|
|
|
|
2019-03-28 14:08:35 -04:00
|
|
|
RSpec::Core::RakeTask.new(:spec_sauce) do |t|
|
|
|
|
t.rspec_opts = rspec_opts
|
|
|
|
t.pattern = './spec/sauce_spec_chrome.rb'
|
|
|
|
end
|
|
|
|
|
2019-04-13 13:06:11 -04:00
|
|
|
# RSpec::Core::RakeTask.new(:spec_rack, [] => :rubocop) do |t|
|
|
|
|
RSpec::Core::RakeTask.new(:spec_rack) do |t|
|
2018-04-24 18:47:53 -04:00
|
|
|
t.rspec_opts = rspec_opts
|
2017-07-26 15:26:45 -04:00
|
|
|
t.pattern = './spec{,/*/**}/*{_spec.rb}'
|
|
|
|
end
|
|
|
|
|
2020-12-28 12:55:56 -05:00
|
|
|
desc 'Run specs with Firefox'
|
2018-11-18 16:27:00 -05:00
|
|
|
task spec: [:spec_firefox]
|
2017-03-07 16:19:03 -05:00
|
|
|
|
2020-12-28 12:55:56 -05:00
|
|
|
desc 'Run basic smoke tests (rack test and rubocop)'
|
2019-04-13 13:06:11 -04:00
|
|
|
task rack_smoke: %i[rubocop spec_rack]
|
|
|
|
|
2010-09-17 19:56:32 -04:00
|
|
|
YARD::Rake::YardocTask.new do |t|
|
2012-01-06 13:15:33 -05:00
|
|
|
t.files = ['lib/**/*.rb']
|
2010-09-17 19:56:32 -04:00
|
|
|
end
|
|
|
|
|
2012-01-26 08:58:25 -05:00
|
|
|
Cucumber::Rake::Task.new(:cucumber) do |task|
|
|
|
|
task.cucumber_opts = ['--format=progress', 'features']
|
|
|
|
end
|
|
|
|
|
2020-12-28 12:55:56 -05:00
|
|
|
desc 'Task for running CI'
|
2017-11-13 16:04:47 -05:00
|
|
|
task :travis do
|
2018-06-26 16:55:17 -04:00
|
|
|
if ENV['CAPYBARA_REMOTE'] && ENV['CAPYBARA_FF']
|
|
|
|
Rake::Task[:spec_firefox_remote].invoke
|
|
|
|
elsif ENV['CAPYBARA_FF']
|
2018-11-18 16:27:00 -05:00
|
|
|
Rake::Task[:spec_firefox].invoke
|
2018-03-17 07:55:00 -04:00
|
|
|
elsif ENV['CAPYBARA_IE']
|
|
|
|
Rake::Task[:spec_ie].invoke
|
|
|
|
elsif ENV['CAPYBARA_EDGE']
|
|
|
|
Rake::Task[:spec_edge].invoke
|
2018-06-26 16:55:17 -04:00
|
|
|
elsif ENV['CAPYBARA_REMOTE']
|
2018-04-24 18:47:53 -04:00
|
|
|
Rake::Task[:spec_chrome_remote].invoke
|
2015-05-21 14:00:36 -04:00
|
|
|
else
|
2017-08-02 15:10:56 -04:00
|
|
|
Rake::Task[:spec_chrome].invoke
|
2015-05-21 14:00:36 -04:00
|
|
|
end
|
2018-01-08 15:23:54 -05:00
|
|
|
Rake::Task[:cucumber].invoke
|
2015-05-21 14:00:36 -04:00
|
|
|
end
|
2013-02-25 14:13:03 -05:00
|
|
|
|
2020-12-28 12:55:56 -05:00
|
|
|
desc 'Build updated JS replacements for Selenium atoms'
|
2019-05-02 21:57:14 -04:00
|
|
|
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
|
|
|
|
|
2020-12-28 12:55:56 -05:00
|
|
|
desc 'Release new version'
|
2016-10-19 13:35:11 -04:00
|
|
|
task :release do
|
2018-01-03 17:31:56 -05:00
|
|
|
version = Capybara::VERSION
|
2016-10-19 13:35:11 -04:00
|
|
|
puts "Releasing #{version}, y/n?"
|
2020-09-05 15:24:43 -04:00
|
|
|
exit(1) unless $stdin.gets.chomp == 'y'
|
2016-10-19 13:35:11 -04:00
|
|
|
sh "git commit -am 'tagged #{version}' && " \
|
|
|
|
"git tag #{version} && " \
|
|
|
|
'gem build capybara.gemspec && ' \
|
|
|
|
"gem push capybara-#{version}.gem && " \
|
|
|
|
'git push && ' \
|
|
|
|
'git push --tags'
|
|
|
|
end
|
|
|
|
|
2018-01-09 17:05:50 -05:00
|
|
|
task default: %i[spec cucumber]
|