-
Notifications
You must be signed in to change notification settings - Fork 2
Run Test Suite
Mark Bussey edited this page Sep 6, 2017
·
2 revisions
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. In order to do that, we first need to set up an automated test suite.
Hydra software uses rspec for testing. 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.
- Add rspec required gems to your
Gemfile
found in the root of your application, in one of thegroup :development, :test
blocks:group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platform: :mri gem 'capybara' gem 'database_cleaner' gem 'rspec', "~> 3.5" gem 'rspec-rails', "~> 3.5" gem 'shoulda-matchers' end
- Run
bundle install
to make sure those gems are installed - Add this
rails_helper.rb
file to thespec
folder - Add this
spec_helper.rb
file to thespec
folder - Edit
config/solr_wrapper_test.yml
andconfig/fcrepo_wrapper_test.yml
to add this line (so they will use our already downloaded version of the software):download_dir: /var/tmp
- Add this
ci.rake
file tolib/tasks
- Run
rake ci
. You should see a passing test suite.
Note: You can see everything we just changed, compared to our base application, here. You can check out a version of our test application with a working test suite here.
For discussion:
- Compare the structure of our
/spec
directory to ourapp
directory - What is a rake task? What kinds of jobs make good rake tasks?
- Let's read through the
ci.rake
file together. What is it doing? - CI stands for "continuous integration". What does that mean? How might we run this automatically? (e.g., travis-ci)
- 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?
Next: Add a metadata field