forked from glebm/rails_email_preview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
66 lines (60 loc) · 1.82 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
# encoding: UTF-8
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
# Load dummy app tasks
if ENV['DUMMY']
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
load 'rails/tasks/engine.rake'
end
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
desc 'Start development web server'
task :dev do
host = 'localhost'
port = 9292
require 'puma'
require 'rails/commands/server'
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'development'
Dir.chdir 'spec/dummy'
Rack::Server.start(
environment: 'development',
Host: host,
Port: port,
config: 'config.ru',
server: 'puma'
)
end
desc 'Test all Gemfiles from spec/*.gemfile'
task :test_all_gemfiles do
require 'pty'
require 'shellwords'
cmd = 'bundle install --quiet && bundle exec rake --trace'
statuses = Dir.glob('./spec/gemfiles/*{[!.lock]}').map do |gemfile|
Bundler.with_clean_env do
env = {'BUNDLE_GEMFILE' => gemfile}
$stderr.puts "Testing #{File.basename(gemfile)}:\n export #{env.map { |k, v| "#{k}=#{Shellwords.escape v}" } * ' '}; #{cmd}"
PTY.spawn(env, cmd) do |r, _w, pid|
begin
r.each_line { |l| puts l }
rescue Errno::EIO
# Errno:EIO error means that the process has finished giving output.
ensure
::Process.wait pid
end
end
[$? && $?.exitstatus == 0, gemfile]
end
end
failed_gemfiles = statuses.reject(&:first).map { |(_status, gemfile)| gemfile }
if failed_gemfiles.empty?
$stderr.puts "✓ Tests pass with all #{statuses.size} gemfiles"
else
$stderr.puts "❌ FAILING (#{failed_gemfiles.size} / #{statuses.size})\n#{failed_gemfiles * "\n"}"
exit 1
end
end