teamcapybara--capybara/Rakefile

94 lines
2.4 KiB
Ruby
Raw Normal View History

# 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'
2014-03-31 22:10:27 +00:00
2018-04-24 22:47:53 +00:00
rspec_opts = %w[--color]
RSpec::Core::RakeTask.new(:spec_firefox) do |t|
2018-04-24 22:47:53 +00:00
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|
RSpec::Core::RakeTask.new(:"spec_#{driver}") do |t|
2018-04-24 22:47:53 +00:00
t.rspec_opts = rspec_opts
t.pattern = "./spec/{selenium_spec_#{driver}.rb}"
end
2015-05-21 18:00:36 +00:00
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|
2018-04-24 22:47:53 +00:00
t.rspec_opts = rspec_opts
t.pattern = './spec{,/*/**}/*{_spec.rb}'
end
task spec: [:spec_firefox]
2017-03-07 21:19:03 +00:00
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', 'features']
end
2017-11-13 21:04:47 +00:00
task :travis do
2018-06-26 20:55:17 +00:00
if ENV['CAPYBARA_REMOTE'] && ENV['CAPYBARA_FF']
Rake::Task[:spec_firefox_remote].invoke
elsif ENV['CAPYBARA_FF']
Rake::Task[:spec_firefox].invoke
elsif ENV['CAPYBARA_IE']
Rake::Task[:spec_ie].invoke
elsif ENV['CAPYBARA_EDGE']
Rake::Task[:spec_edge].invoke
2018-06-26 20:55:17 +00:00
elsif ENV['CAPYBARA_REMOTE']
2018-04-24 22:47:53 +00:00
Rake::Task[:spec_chrome_remote].invoke
2015-05-21 18:00:36 +00:00
else
Rake::Task[:spec_chrome].invoke
2015-05-21 18:00:36 +00:00
end
2018-01-08 20:23:54 +00:00
Rake::Task[:cucumber].invoke
2015-05-21 18:00:36 +00:00
end
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
2016-10-19 17:35:11 +00:00
task :release do
2018-01-03 22:31:56 +00:00
version = Capybara::VERSION
2016-10-19 17:35:11 +00:00
puts "Releasing #{version}, y/n?"
2020-09-05 19:24:43 +00:00
exit(1) unless $stdin.gets.chomp == 'y'
2016-10-19 17:35:11 +00: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 22:05:50 +00:00
task default: %i[spec cucumber]