-
Notifications
You must be signed in to change notification settings - Fork 53
Testing FromthePage
From the Page has a testing philosophy that involves using features tests to simulate user interaction with the product. We utilize rspec and capybara/capybara-webkit to run these tests.
To run the tests, first clone the From The Page repository.
Create a database called testing on your local mysql server. In config/database.yml, make sure the test database is called testing, and your username and password are correct.
Check the Gemfile and confirm that the following gems are included:
group :test do
gem ‘database_cleaner’
gem ‘capybara’
gem ‘shoulda’
group :development, :test do
gem ‘rspec-rails’
gem ‘launchy’
gem ‘capybara-webkit’
Note: capybara-webkit depends on Qt version 5 or above, see: https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit for installation instructions.
Run bundle-install.
bundle-install
Since the app has a lot of items that depend on each other, we use fixtures with our test suite. The fixtures setup needs to be run every time before we run rspec
. Run the following commands to set up the test database with data:
RAILS_ENV=test rake db:drop db:create db:migrate
RAILS_ENV=test rake db:fixtures:load FIXTURES_PATH=spec/fixtures
To run the tests, run the following command:
rspec spec/features
Please note: there is a 60 second sleep in one of the tests, to make sure the document upload background process has completed, so make sure to give the tests some time to run.
When testing mailers, it is important to keep emails from being sent to customers. We have configuration set up to use MailCatcher to help with this. MailCatcher will intercept email sent from your development environment and display them in the browser for you.
- Install the gem locally on your machine. This gem is not in the project Gemfile because the gem authors recommend only installing it locally.
gem install mailcatcher
- Run the MailCatcher server locally on your machine
mailcatcher
-
Go to
Go to http://localhost:1080/
in your browser -
Send mailers as you normally would, and they'll appear in the browser.
-
When you're finished, exit the server by clicking
Quit
in the browser interface.