From b052e79b3aa85208fbaf6b02e3dbb38819eac416 Mon Sep 17 00:00:00 2001 From: Stuart Kenny Date: Tue, 19 Sep 2023 19:09:01 +0100 Subject: [PATCH] Use Lando when running spec tests, gh-256 --- .rubocop_todo.yml | 4 ++++ README.md | 19 ++++++++++++++----- Rakefile | 1 + tasks/dev.rake | 23 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tasks/dev.rake diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4c129f4..16e5883 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -45,6 +45,10 @@ RSpec/PredicateMatcher: Exclude: - spec/**/*.rb +Rails/RakeEnvironment: + Exclude: + - 'tasks/dev.rake' + RSpec/ReturnFromStub: Exclude: - spec/processors/jpeg2k_spec.rb diff --git a/README.md b/README.md index 759c9bd..d84df00 100644 --- a/README.md +++ b/README.md @@ -244,14 +244,23 @@ Instead, each directive may contain these arguments: ## Running Tests -1. Run tests with `RAILS_ENV=test bundle exec rake ci` +For ease of development we use Lando to abstract away some complications of +using Docker containers for development. -## Running specific tests +1. Install the latest released > 3.0 version of Lando from [here](https://github.com/lando/lando/releases). +2. `bundle install`(Ruby 2.6+ required) +3. `bundle exec rake server:start` +4. `bundle exec rspec spec` -If you don't want to run the whole suite all at once like CI, do the following: +### Cleaning Data -1. Run the test servers with `rake derivatives:test_server` -2. Run the tests. +1. `bundle exec rake server:clean` + +### Stopping Servers + +1. `bundle exec rake server:stop` + +You can also run `lando poweroff` from anywhere. # Acknowledgments diff --git a/Rakefile b/Rakefile index 7a22c96..bd0b6fa 100644 --- a/Rakefile +++ b/Rakefile @@ -9,6 +9,7 @@ require 'solr_wrapper/rake_task' require 'fcrepo_wrapper' require 'active_fedora/rake_support' require 'rubocop/rake_task' +load 'tasks/dev.rake' namespace :derivatives do desc 'Run style checker' diff --git a/tasks/dev.rake b/tasks/dev.rake new file mode 100644 index 0000000..9e4a811 --- /dev/null +++ b/tasks/dev.rake @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +namespace :server do + desc "Start solr and fedora servers for testing" + task :start do + require 'rails' + `lando start` + puts "Started Solr/Fedora" + end + + desc "Cleanup test servers" + task :clean do + require 'rails' + `lando destroy -y` + `lando start` + puts "Cleaned/Started Solr/Fedora" + end + + desc "Stop test servers" + task :stop do + `lando stop -y` + end +end