Skip to content

Commit

Permalink
Merge pull request #982 from projecthydra/rake_refactor
Browse files Browse the repository at this point in the history
Add a rake task for running spec without rubocop
  • Loading branch information
awead committed Feb 10, 2016
2 parents 4830ed7 + 46a9371 commit 3e2d654
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions lib/tasks/active_fedora_dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,34 @@ namespace :active_fedora do
desc "CI build"
task :ci do
ENV['environment'] = "test"
with_test_server do
Rake::Task['active_fedora:rubocop'].invoke unless ENV['NO_RUBOCOP']
Rake::Task['active_fedora:coverage'].invoke
end
end

desc "Execute specs with coverage"
task :coverage do
# Put spec opts in a file named .rspec in root
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
Rake::Task["active_fedora:spec"].invoke
end

desc "Execute specs with coverage"
task :spec do
with_test_server do
Rake::Task["active_fedora:rspec"].invoke
end
end

# Starts a fedora server and a solr server on a random port and then
# yields the passed block
def with_test_server
return yield if ENV['SERVER_STARTED']

ENV['SERVER_STARTED'] = 'true'

# setting port: nil assigns a random port.
solr_params = { port: nil, verbose: true, managed: true }
fcrepo_params = { port: nil, verbose: true, managed: true,
Expand All @@ -60,18 +88,10 @@ namespace :active_fedora do
solr.with_collection(name: 'hydra-test', dir: File.join(File.expand_path("../..", File.dirname(__FILE__)), "solr", "config")) do
FcrepoWrapper.wrap(fcrepo_params) do |fcrepo|
ENV['FCREPO_TEST_PORT'] = fcrepo.port
Rake::Task['active_fedora:coverage'].invoke
yield
end
end
end
ENV['SERVER_STARTED'] = 'false'
end

desc "Execute specs with coverage"
task coverage: :rubocop do
# Put spec opts in a file named .rspec in root
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
Rake::Task["active_fedora:rspec"].invoke
end

end

0 comments on commit 3e2d654

Please sign in to comment.