Rakefile in active_model_serializers-0.10.0.rc4 vs Rakefile in active_model_serializers-0.10.0.rc5
- old
+ new
@@ -1,12 +1,37 @@
begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+begin
require 'simplecov'
rescue LoadError
end
-require 'bundler/gem_tasks'
+Bundler::GemHelper.install_tasks
+require 'yard'
+
+namespace :yard do
+ YARD::Rake::YardocTask.new(:doc) do |t|
+ t.stats_options = ['--list-undoc']
+ end
+
+ desc 'start a gem server'
+ task :server do
+ sh 'bundle exec yard server --gems'
+ end
+
+ desc 'use Graphviz to generate dot graph'
+ task :graph do
+ output_file = 'doc/erd.dot'
+ sh "bundle exec yard graph --protected --full --dependencies > #{output_file}"
+ puts 'open doc/erd.dot if you have graphviz installed'
+ end
+end
+
begin
require 'rubocop'
require 'rubocop/rake_task'
rescue LoadError
else
@@ -35,33 +60,36 @@
end
end
require 'rake/testtask'
-Rake::TestTask.new do |t|
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
t.libs << 'test'
- t.test_files = FileList['test/**/*_test.rb']
+ t.pattern = 'test/**/*_test.rb'
t.ruby_opts = ['-r./test/test_helper.rb']
+ t.ruby_opts << ' -w' unless ENV['NO_WARN'] == 'true'
t.verbose = true
end
desc 'Run isolated tests'
-task isolated: ['test:isolated:railtie']
+task isolated: ['test:isolated']
namespace :test do
- namespace :isolated do
+ task :isolated do
desc 'Run isolated tests for Railtie'
- task :railtie do
- dir = File.dirname(__FILE__)
- file = "#{dir}/test/active_model_serializers/railtie_test_isolated.rb"
-
- # https://github.com/rails/rails/blob/3d590add45/railties/lib/rails/generators/app_base.rb#L345-L363
- _bundle_command = Gem.bin_path('bundler', 'bundle')
- require 'bundler'
- Bundler.with_clean_env do
- command = "-w -I#{dir}/lib -I#{dir}/test #{file}"
+ require 'shellwords'
+ dir = File.dirname(__FILE__)
+ dir = Shellwords.shellescape(dir)
+ isolated_test_files = FileList['test/**/*_test_isolated.rb']
+ # https://github.com/rails/rails/blob/3d590add45/railties/lib/rails/generators/app_base.rb#L345-L363
+ _bundle_command = Gem.bin_path('bundler', 'bundle')
+ require 'bundler'
+ Bundler.with_clean_env do
+ isolated_test_files.all? do |test_file|
+ command = "-w -I#{dir}/lib -I#{dir}/test #{Shellwords.shellescape(test_file)}"
full_command = %("#{Gem.ruby}" #{command})
- system(full_command) or fail 'Failures' # rubocop:disable Style/AndOr
- end
+ system(full_command)
+ end or fail 'Failures' # rubocop:disable Style/AndOr
end
end
end
if ENV['RAILS_VERSION'].to_s > '4.0' && RUBY_ENGINE == 'ruby'