Skip to content

Commit ad75a55

Browse files
committed
Merge pull request #631 from projectblacklight/engine-cart
replace custom test app creation code and test-with-the-app code with engine_cart
2 parents fbce668 + 4bd4989 commit ad75a55

File tree

6 files changed

+18
-56
lines changed

6 files changed

+18
-56
lines changed

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ rescue LoadError
77
end
88

99
Bundler::GemHelper.install_tasks
10+
require 'rspec/core/rake_task'
11+
RSpec::Core::RakeTask.new(:spec)
1012

1113
# load rake tasks defined in lib/tasks that are not loaded in lib/active_fedora.rb
1214
load "tasks/blacklight.rake"
1315

1416
task :default => [:ci]
15-
task :spec => ['blacklight:spec']
1617
task :clean => ['blacklight:clean']
1718

blacklight.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ Gem::Specification.new do |s|
3131
s.add_dependency "bootstrap-sass", ">= 2.2.0", "< 2.4"
3232
s.add_development_dependency "jettywrapper", ">= 1.4.1"
3333
s.add_development_dependency "rspec-rails"
34+
s.add_development_dependency 'engine_cart', ">= 0.1.0"
3435
end

gemfiles/rails3.gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ gem 'simplecov-rcov', :platform => :mri
88

99
gem 'rails', "~> 3.2"
1010

11+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
12+
1113
group :test do
1214
gem 'devise'
15+
gem 'devise-guests'
1316
gem "bootstrap-sass"
1417
gem 'turbolinks'
18+
gem 'uglifier'
19+
gem 'poltergeist'
1520
gem "unicode", :platforms => [:mri_18, :mri_19]
1621
end
1722

gemfiles/rails4.gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ gem 'simplecov-rcov', :platform => :mri
88

99
gem 'rails', '~> 4.0.0'
1010

11+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
12+
1113
group :test do
1214
gem 'devise'
15+
gem 'devise-guests'
1316
gem "bootstrap-sass"
1417
gem 'turbolinks'
18+
gem 'poltergeist'
1519
gem "unicode", :platforms => [:mri_18, :mri_19]
1620
end
1721

spec/spec_helper.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
end
1717
end
1818

19-
# version that works with our blacklight:spec stuff that calls specs
20-
# in a remote directory.
21-
require File.expand_path("config/environment", ENV['RAILS_ROOT'] || File.expand_path("../internal", __FILE__))
19+
require 'engine_cart'
20+
EngineCart.load_application!
2221

2322
require 'rspec/rails'
2423
require 'capybara/rspec'

tasks/blacklight.rake

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.0.0.zip"
2-
APP_ROOT = File.expand_path("../..", __FILE__)
3-
4-
TEST_APP_TEMPLATES = 'spec/test_app_templates'
5-
TEST_APP = 'spec/internal'
62

73
require 'jettywrapper'
8-
require 'rspec/core/rake_task'
9-
4+
require 'engine_cart/rake_task'
105

116
task :ci => 'jetty:clean' do
127
ENV['environment'] = "test"
@@ -30,61 +25,18 @@ namespace :blacklight do
3025
end
3126
end
3227

33-
3428
desc "Run tests with coverage"
3529
task :coverage do
3630
ENV['COVERAGE'] = 'true'
37-
Rake::Task["blacklight:spec"].invoke
38-
end
39-
40-
desc "Run specs"
41-
task :spec => [:generate] do |t|
42-
spec_options = ENV['SPEC'] ? " SPEC=#{File.join(GEM_ROOT, ENV['SPEC'])}" : ''
43-
within_test_app do
44-
system "rake blacklight_test_app:spec#{spec_options}"
45-
abort "Error running spec" unless $?.success?
46-
end
31+
Rake::Task["spec"].invoke
4732
end
4833

4934
desc "Clean out the test rails app"
50-
task :clean do
51-
puts "Removing sample rails app"
52-
`rm -rf #{TEST_APP}`
35+
task :clean => ['engine_cart:clean'] do
5336
end
5437

5538
desc "Create the test rails app"
56-
task :generate do
57-
unless File.exists?('spec/internal/Rakefile')
58-
puts "Generating rails app"
59-
`rails new #{TEST_APP}`
60-
puts "Copying gemfile"
61-
open("#{TEST_APP}/Gemfile", 'a') do |f|
62-
f.write File.read(TEST_APP_TEMPLATES + "/Gemfile.extra")
63-
f.write "gem 'blacklight', :path => '../../'"
64-
end
65-
puts "Copying generator"
66-
`cp -r #{TEST_APP_TEMPLATES}/lib/generators #{TEST_APP}/lib`
67-
within_test_app do
68-
puts "Bundle install"
69-
`bundle install`
70-
puts "running test_app_generator"
71-
system "rails generate test_app"
72-
73-
puts "running migrations"
74-
puts `rake db:migrate db:test:prepare`
75-
end
76-
end
77-
puts "Done generating test app"
39+
task :generate => ['engine_cart:generate'] do
7840
end
79-
80-
81-
8241
end
8342

84-
def within_test_app
85-
FileUtils.cd(TEST_APP)
86-
Bundler.with_clean_env do
87-
yield
88-
end
89-
FileUtils.cd(APP_ROOT)
90-
end

0 commit comments

Comments
 (0)