Skip to content

Commit

Permalink
Simpler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Mar 15, 2013
1 parent 762de11 commit 64324a6
Show file tree
Hide file tree
Showing 89 changed files with 207 additions and 335 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Expand Up @@ -4,8 +4,7 @@ coverage.data
coverage/
db/*.sqlite3
db/schema.rb
jetty/logs/*.log
jetty/solr/data/*
jetty
log/*
webrat-*
config/SolrMarc/*.log*
Expand All @@ -15,7 +14,7 @@ tmp/*
*.log
.bundle
Gemfile.lock
tmp/test_app
spec/internal
.rvmrc
pkg/*
*.sw[pon]
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -10,13 +10,13 @@ gemfile:
- gemfiles/rails3.gemfile
- gemfiles/rails4.gemfile

script:
- test_support/bin/test.sh
# script:
# - test_support/bin/test.sh

notifications:
irc: "irc.freenode.org#blacklight"
email:
- blacklight-commits@googlegroups.com

before_install:
- gem install bundler
# before_install:
# - gem install bundler
8 changes: 8 additions & 0 deletions Rakefile
Expand Up @@ -8,3 +8,11 @@ end

require 'rake'
Bundler::GemHelper.install_tasks

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

task :default => [:ci]
task :spec => ['blacklight:spec']
task :clean => ['blacklight:clean']

3 changes: 2 additions & 1 deletion blacklight.gemspec
Expand Up @@ -29,5 +29,6 @@ Gem::Specification.new do |s|
s.add_dependency "kaminari", "~> 0.13" # the pagination (page 1,2,3, etc..) of our search results
s.add_dependency "sass-rails"
s.add_dependency "bootstrap-sass", "~> 2.2.0"
s.add_development_dependency "jettywrapper", ">= 1.2.0"
s.add_development_dependency "jettywrapper", ">= 1.4.1"
s.add_development_dependency "rspec-rails"
end
4 changes: 4 additions & 0 deletions config/jetty.yml
@@ -0,0 +1,4 @@
default:
startup_wait: 15
jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
<%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/railties/blacklight_cucumber.rake
Expand Up @@ -10,7 +10,7 @@
ENV['RAILS_ROOT'] = Rails.root.to_s

# blacklight_features, where to find features inside blacklight source?
blacklight_features = File.expand_path("./test_support/features", Blacklight.root)
blacklight_features = File.expand_path("features", Blacklight.root)

unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -20,7 +20,7 @@
context 'root' do

before(:all) do
@blroot = File.expand_path(File.join(__FILE__, '..', '..', '..', '..'))
@blroot = File.expand_path(File.join(__FILE__, '..', '..', '..' ))
end

it 'should return the full path to the BL plugin' do
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions test_support/spec/spec_helper.rb → spec/spec_helper.rb
Expand Up @@ -16,18 +16,17 @@
end
end

#require File.expand_path("../../config/environment", __FILE__)
# version that works with our blacklight:spec stuff that calls specs
# in a remote directory.
require File.expand_path("config/environment", ENV['RAILS_ROOT'] || File.expand_path("../..", __FILE__))
require File.expand_path("config/environment", ENV['RAILS_ROOT'] || File.expand_path("../internal", __FILE__))

require 'rspec/rails'
require 'capybara/rspec'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
# Blacklight, again, make sure we're looking in the right place for em.
# Relative to HERE, NOT to Rails.root, which is off somewhere else.
#Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Dir[Pathname.new(File.expand_path("../support/**/*.rb", __FILE__))].each {|f| require f}


Expand Down
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions spec/test_app_templates/Gemfile.extra
@@ -0,0 +1,38 @@
platforms :jruby do
gem 'jruby-openssl'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jdbc-sqlite3'
gem 'mediashelf-loggable', '>= 0.4.8'
gem 'therubyrhino'
end

platforms :ruby do
gem 'sqlite3'
gem 'execjs'
gem 'therubyracer', '~> 0.10.2'
end

gem 'blacklight', :path => '../../'
gem 'jquery-rails'

# For testing
group :development, :test do
gem 'rspec-rails', '~> 2.12.0'
end

group :test do
gem 'generator_spec'
gem 'cucumber-rails', :require => false
gem 'database_cleaner', '>= 1.0.0.RC1'
if defined? :JRUBY_VERSION
gem 'capybara', '~> 1.0'
else
gem 'capybara'
end
gem 'rcov', :platform => :mri_18
gem 'simplecov', :platform => :mri_19
gem 'simplecov-rcov', :platform => :mri_19
end

gem 'jettywrapper', '>= 1.2.0'

40 changes: 40 additions & 0 deletions spec/test_app_templates/lib/generators/test_app_generator.rb
@@ -0,0 +1,40 @@
require 'rails/generators'

class TestAppGenerator < Rails::Generators::Base
source_root File.expand_path("../../../../test_app_templates", __FILE__)

def fix_travis_rails_4
if ENV['TRAVIS']
insert_into_file 'app/assets/stylesheets/application.css', :before =>'/*' do
"@charset \"UTF-8\";\n"
end
end
end

def copy_rspec_rake_task
copy_file "lib/tasks/rspec.rake"
end

def remove_index
remove_file "public/index.html"
remove_file 'app/assets/images/rails.png'
end

def run_blacklight_generator
say_status("warning", "GENERATING BL", :yellow)

generate 'blacklight', '--devise'
end

def run_cucumber_generator
say_status("warning", "GENERATING cucumber", :yellow)

generate 'cucumber:install'
end

def run_test_support_generator
say_status("warning", "GENERATING test_support", :yellow)

generate 'blacklight:test_support'
end
end
8 changes: 8 additions & 0 deletions spec/test_app_templates/lib/tasks/rspec.rake
@@ -0,0 +1,8 @@
require 'rspec/core/rake_task'
desc "run the blacklight gem spec"
gem_home = File.expand_path('../../../../..', __FILE__)
RSpec::Core::RakeTask.new(:myspec) do |t|
t.pattern = gem_home + '/spec/**/*_spec.rb'
t.rspec_opts = "--colour"
t.ruby_opts = "-I#{gem_home}/spec"
end
File renamed without changes.
97 changes: 97 additions & 0 deletions tasks/blacklight.rake
@@ -0,0 +1,97 @@
ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.0.0.zip"
APP_ROOT = File.expand_path("../..", __FILE__)

TEST_APP_TEMPLATES = 'spec/test_app_templates'
TEST_APP = 'spec/internal'

require 'jettywrapper'
require 'rspec/core/rake_task'


task :ci => 'jetty:clean' do
ENV['environment'] = "test"
jetty_params = Jettywrapper.load_config
jetty_params[:startup_wait]= 60
error = Jettywrapper.wrap(jetty_params) do
Rake::Task["blacklight:fixtures"].invoke
Rake::Task['blacklight:coverage'].invoke
Rake::Task['blacklight:cucumber'].invoke
end
raise "test failures: #{error}" if error
# Only create documentation if the tests have passed
#Rake::Task["active_fedora:doc"].invoke
end

namespace :blacklight do
desc "Load fixtures"
task :fixtures => [:generate] do
within_test_app do
system "rake solr:marc:index_test_data RAILS_ENV=test"
abort "Error running fixtures" unless $?.success?
end
end


desc "Run tests with coverage"
task :coverage do
ENV['COVERAGE'] = 'true'
Rake::Task["blacklight:spec"].invoke
end

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 spec" unless $?.success?
end
end

desc "Run cucumber features"
task :cucumber => [:generate] do |t|
within_test_app do
system "rake blacklight:cucumber"
abort "Error running cucumber" unless $?.success?
end
end


desc "Clean out the test rails app"
task :clean do
puts "Removing sample rails app"
`rm -rf #{TEST_APP}`
end

desc "Create the test rails app"
task :generate do
unless File.exists?('spec/internal/Rakefile')
puts "Generating rails app"
`rails new #{TEST_APP}`
puts "Copying gemfile"
`cat #{TEST_APP_TEMPLATES}/Gemfile.extra >> #{TEST_APP}/Gemfile`
puts "Copying generator"
`cp -r #{TEST_APP_TEMPLATES}/lib/generators #{TEST_APP}/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 "Done generating test app"
end



end

def within_test_app
FileUtils.cd(TEST_APP)
Bundler.with_clean_env do
yield
end
FileUtils.cd(APP_ROOT)
end
56 changes: 0 additions & 56 deletions test_support/bin/run-tests.sh

This file was deleted.

0 comments on commit 64324a6

Please sign in to comment.