Sha256: f89b7c8ac7d42240190c5f669df23dbab7ce0a41ca1df051762bb803e4163c24

Contents?: true

Size: 1.52 KB

Versions: 27

Compression:

Stored size: 1.52 KB

Contents

ENV["RAILS_ROOT"] ||= 'spec/internal'

GEM_ROOT= File.expand_path(File.join(File.dirname(__FILE__),".."))

desc "Run specs"
task spec: :generate do |t|
  focused_spec = ENV['SPEC'] ? " SPEC=#{File.join(GEM_ROOT, ENV['SPEC'])}" : ''
  within_test_app do
    system "rake myspec#{focused_spec}"
    abort "Error running hydra-core" unless $?.success?
  end
end


desc "Create the test rails app"
task :generate do
  unless File.exists?('spec/internal/Rakefile')
    puts "Generating rails app"
    `rails new spec/internal`
    puts "Updating gemfile"
    `echo " gem 'hydra-access-controls', :path=>'../../../hydra-access-controls'" >> spec/internal/Gemfile`
    `echo " gem 'hydra-core', :path=>'../../', :require=>'hydra-core'" >> spec/internal/Gemfile`
    `echo " eval File.read('../test_app_templates/Gemfile.extra'), nil, '../test_app_templates/Gemfile.extra'" >> spec/internal/Gemfile`
    `echo " gem 'factory_girl_rails'" >> spec/internal/Gemfile`
    puts "Copying generator"
    `cp -r spec/support/lib/generators spec/internal/lib`
    within_test_app do
      puts "Bundle install"
      `bundle install`
      puts "running test_app_generator"
      system "rails generate test_app"

      puts "running migrations"
      puts `rake db:migrate db:test:prepare`
    end
  end
  puts "Running specs"
end

desc "Clean out the test rails app"
task :clean do
  puts "Removing sample rails app"
  `rm -rf spec/internal`
end

def within_test_app
  FileUtils.cd('spec/internal')
  Bundler.with_clean_env do
    yield
  end
  FileUtils.cd('../..')
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
hydra-core-9.10.0 tasks/rspec.rake
hydra-core-9.9.0 tasks/rspec.rake
hydra-core-9.8.1 tasks/rspec.rake
hydra-core-9.8.0 tasks/rspec.rake
hydra-core-9.7.1 tasks/rspec.rake
hydra-core-9.7.0 tasks/rspec.rake
hydra-core-9.6.0 tasks/rspec.rake
hydra-core-9.5.0 tasks/rspec.rake
hydra-core-9.4.1 tasks/rspec.rake
hydra-core-9.4.0 tasks/rspec.rake
hydra-core-9.3.0 tasks/rspec.rake
hydra-core-9.2.2 tasks/rspec.rake
hydra-core-9.2.1 tasks/rspec.rake
hydra-core-9.2.0 tasks/rspec.rake
hydra-core-9.2.0.rc1 tasks/rspec.rake
hydra-core-9.1.4 tasks/rspec.rake
hydra-core-9.1.3 tasks/rspec.rake
hydra-core-9.1.2 tasks/rspec.rake
hydra-core-9.1.1 tasks/rspec.rake
hydra-core-9.1.0 tasks/rspec.rake