Rails app with examples of how to test with RSpec and other testing gems.
- Testing Rake Tasks with RSpec
- Pry-rescue debugging
- Time Travel Examples
- Database Cleaner Examples
- Factory Girl Examples
- Capybara Examples
- Shoulda-Matchers Examples
- Email-Spec Examples
- Devise Examples
- RSpec-Expectations Docs
- RSpec-Mocks Specs & Docs
- RSpec-Rails
- Contributors
RSpec testing Rake task example:
pry-rescue can be used to debug failing specs, by opening pry's debugger whenever a test failure is encountered. For setup and usage see pry-rescue's README.
ActiveSupport::Testing::TimeHelpers
provides helpers for manipulating and freezing the current time reported within tests. These methods are often enough to replace the time-related testing methods that the timecop
gem is used for.
TimeHelpers
configuration how-to and examples:
- spec/support/time_helpers.rb
- spec/models/subscription_spec.rb
- spec/tasks/subscription_tasks_spec.rb
travel_to
example: spec/models/subscription_spec.rbActiveSupport::Testing::TimeHelpers
API documentation
Database Cleaner is a set of strategies for cleaning your database in Ruby, to ensure a consistent environment for each test run.
Database Cleaner configuration how-to:
Factory Girl is a library to help setup test data. factory_girl_rails integrates Factory Girl with Rails.
Factory Girl configuration how-to and examples:
- spec/support/factory_girl.rb
- spec/factories
- spec/factories/users.rb
- spec/models/subscription_spec.rb
- spec/tasks/subscription_tasks_spec.rb
- spec/features/user_login_and_logout_spec.rb
Capybara helps you write feature specs that interact with your app's UI as a user does with a browser.
Capybara configuration how-to and examples:
- spec/support/capybara.rb
- spec/features/home_page_spec.rb
- spec/features/subscribe_to_newsletter_spec.rb
- spec/features/user_login_and_logout_spec.rb
- spec/features/user_registers_spec.rb
- Capybara cheatsheet
- Capybara matchers
Shoulda-matchers make light work of model specs.
shoulda-matchers configuration how-to and examples:
The "Subscribe to newsletter" feature was developed with help from email_spec
email_spec configuration how-to and examples:
- spec/support/email_spec.rb
- spec/mailers/subscription_mailer_spec.rb
- spec/features/subscribe_to_newsletter_spec.rb
- spec/features/user_registers_spec.rb
Specs testing registration, sign-in, and other user authentication features provided by Devise:
- spec/controllers/subscriptions_controller_spec.rb
- spec/mailers/subscription_mailer_spec.rb
- spec/models/subscription_spec.rb
- RSpec Mocks API
See RSpec Rails for installation instructions.
- Eliot Sykes https://eliotsykes.com/
- Your name here, contributions are welcome and easy! Just fork the GitHub repo, make your changes, then submit your pull request!