-
Notifications
You must be signed in to change notification settings - Fork 1
Run Test Suite
- Set up the application for RSpec
- Run the local test suite
If you are completing the lessons in order during the workshop, your system should be all ready. If you're completing this lesson on it's own, please complete the same Lesson Setup as the previous lesson.
Once you have your docker containers setup and running, make sure you have the necessary code checked out. The new code includes additional dependencies, so you'll need to run bundler again:
git checkout rspec_setup
bundle install
In this workshop, we're going to follow the practices recommended by Test Driven Development. That means we're going to be writing automated tests for each new feature we develop, and ideally, we write our tests before we write our code. In order to do that, we first need to set up an automated test suite.
The Samvera community tends to use RSpec for testing rails applications. When we generated a new Hyrax work type, we also auto-generated some RSpec tests for that new work type. However, we need to do some setup before those tests will run.
-
Ensure the RSpec-required gems are included in your
Gemfile
. The file is found in the root of your Rails application. Look for a block beginning withgroup :development, :test do
. Note thatrspec-rails
andcapybara
are installed. These are the main testing libraries we'll be working with. -
Setup database cleanup for Fedora/Solr and the relational database: Open
spec/rails_helper.rb
. Around line 69 notice the cleanup tasks that we've added to this application. Why do we need to clean Fedora and our database before each test suite? -
Look at the
rake ci
task. Look at the file inlib/tasks/ci.rake
. What is it doing? What does CI mean?
- We generally set up a rake task to make it to integrate (CI) services like TravisCI*
- Run the CI task. You should see a passing test suite:
rake ci
- Compare the structure of our
/spec
directory to ourapp
directory - What is a rake task? What kinds of jobs make good tasks?
- What are the advantages of having the CI task launch Solr and Fedora test instances vs. leaving them running?
- What does "pending" mean in the context of our test suite?
- What does that
Randomized with seed
line mean? What are we randomizing and why?