| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This project started out with close to zero tests. Please help us improve our test coverage by ensuring that any new code you push is well-tested, and by adding additional tests where you see they are needed.
We use RSpec for unit testing, and RSpec with Capybara for integration testing.
You can run the entire Ruby test suite with the following command:
$ bundle exec rspec spec(Using the bundle keyword helps to ensure we're using the rspec executable in the bundled RSpec version).
This test suite relies on Factories, not fixtures. This is preferrable, since fixtures are inserted to the database without running ActiveRecord validations and checks. Factories allow us to run each test on a unique record, whereas fixtures give us only a small set of pre-defined test objects. This allows us to catch more potential bugs.
To learn more about how to use Factories, please read the Getting Started guide
Use the Faker gem to generate dummy data for testing.
Bad
@user = User.new(email: 'foo.bar@example.com')
expect(@user).to be_validGood
@user = User.new(email: Faker::Internet.email)
expect(@user).to be_validRunning the feature specs requires Headless Chrome.
You can check you have the minimum requireqments by running the following bash shell command:
chromedriver --versionThis should be at least ChromeDriver 2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db)
To update your ChromeDriver version, use:
chromedriver-updateThe test suite has SimpleCov installed. This should be used to monitor the quality of code as we progress. We are aiming for a healthy minimum coverage level of 80% to ensure the quality of the code is preserved over time.
UI tests are written in RSpec using the Capyabra gem. Tests are run using Selenium with Headless Chrome.
NOTE: Ensure the :js flag is used in any feature Specs that rely on Javascript to run. For performance, we run feature specs in a lighter driver unless Javascript testing is required. To run a given test in Capybara with Selenium you must explicitly specify the js flag.
Example:
require "rails_helper"
describe "Account creation", type: :feature do
scenario "User creates an account", :js do # <= see the :js flag here?
# Run tests that require Javascript in the browser.
end
endExplanation of npm test and our very spotty coverage coming soon ...
| Back | FazBrowse Home | New Git URL |