diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2015-09-27 15:51:03 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2015-09-27 15:51:03 +0300 |
commit | ab2a21db3f3b1b3b12b58f15a9ac701888592f6f (patch) | |
tree | 47acc7922622983c5be208049266b84f2decffa6 | |
parent | fdf1c797d4fb2e91d8645f02a5b96a85b37208fb (diff) |
Test with Rails HEAD
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | Rakefile | 30 | ||||
-rw-r--r-- | test/dummy_rails/config/application.rb | 2 | ||||
-rw-r--r-- | test/gemfiles/rails_head.gemfile | 17 | ||||
-rw-r--r-- | test/support/reporting.rb | 10 |
5 files changed, 60 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml index 62b8e778..9638724b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: ruby rvm: - 2.1.5 gemfile: + - test/gemfiles/rails_head.gemfile - test/gemfiles/sass_3_3.gemfile - test/gemfiles/sass_3_4.gemfile - test/gemfiles/sass_head.gemfile @@ -9,6 +10,7 @@ before_install: - "npm install" matrix: allow_failures: + - gemfile: test/gemfiles/rails_head.gemfile - gemfile: test/gemfiles/sass_head.gemfile notifications: slack: heybb:3n88HHilXn76ji9vV4gL819Y @@ -10,6 +10,36 @@ Rake::TestTask.new do |t| t.verbose = true end +desc 'Test all Gemfiles from test/*.gemfile' +task :test_all_gemfiles do + require 'term/ansicolor' + require 'pty' + require 'shellwords' + cmd = 'bundle install --quiet && bundle exec rake --trace' + statuses = Dir.glob('./test/gemfiles/*{[!.lock]}').map do |gemfile| + env = {'BUNDLE_GEMFILE' => gemfile} + cmd_with_env = " (#{env.map { |k, v| "export #{k}=#{Shellwords.escape v}" } * ' '}; #{cmd})" + $stderr.puts Term::ANSIColor.cyan("Testing\n#{cmd_with_env}") + 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, cmd_with_env] + end + failed_cmds = statuses.reject(&:first).map { |(_status, cmd_with_env)| cmd_with_env } + if failed_cmds.empty? + $stderr.puts Term::ANSIColor.green('Tests pass with all gemfiles') + else + $stderr.puts Term::ANSIColor.red("Failing (#{failed_cmds.size} / #{statuses.size})\n#{failed_cmds * "\n"}") + exit 1 + end +end + desc 'Dumps output to a CSS file for testing' task :debug do require 'sass' diff --git a/test/dummy_rails/config/application.rb b/test/dummy_rails/config/application.rb index e990bdd7..be706363 100644 --- a/test/dummy_rails/config/application.rb +++ b/test/dummy_rails/config/application.rb @@ -12,13 +12,13 @@ end require 'slim-rails' require 'jquery-rails' -require 'compass' require 'bootstrap-sass' require 'uglifier' module Dummy class Application < Rails::Application config.assets.enabled = true if config.assets.respond_to?(:enabled) + config.assets.precompile += %w( application.css application.js ) config.to_prepare do if ENV['VERBOSE'] STDERR.puts "Loaded Rails #{Rails::VERSION::STRING}, Sprockets #{Sprockets::VERSION}", diff --git a/test/gemfiles/rails_head.gemfile b/test/gemfiles/rails_head.gemfile new file mode 100644 index 00000000..72f908ea --- /dev/null +++ b/test/gemfiles/rails_head.gemfile @@ -0,0 +1,17 @@ +source "https://rubygems.org" + +gem 'actionpack', github: 'rails/rails' +gem 'activesupport', github: 'rails/rails' + +# Required git dependencies as per https://github.com/rails/rails/blob/51211a94bd7a34d80f2412a7f94fefe7366647a5/Gemfile: +gem 'rack', github: 'rack/rack' +gem 'sprockets', github: 'rails/sprockets' +gem 'sprockets-rails', github: 'rails/sprockets-rails' +gem 'sass-rails', github: 'rails/sass-rails', branch: 'master' + +gem 'autoprefixer-rails', github: 'ai/autoprefixer-rails' + +gem 'compass', '~> 1.0.1', require: false + +gemspec path: '../../' + diff --git a/test/support/reporting.rb b/test/support/reporting.rb index 1d473634..efaf8368 100644 --- a/test/support/reporting.rb +++ b/test/support/reporting.rb @@ -14,4 +14,14 @@ module Kernel run.call end end + + def silence_stream(stream) + old_stream = stream.dup + stream.reopen(File::NULL) + stream.sync = true + yield + ensure + stream.reopen(old_stream) + old_stream.close + end unless method_defined?(:silence_stream) end |