Skip to content
This repository
..
Octocat-spinner-32 controller_specs Adds a bit more clarifying details
Octocat-spinner-32 feature_specs We can only test rspec-rails 3 with capybara on 1.9.3 and above
Octocat-spinner-32 helper_specs A widget needs an ID for widget_path to work correctly
Octocat-spinner-32 mailer_specs Identify ruby code for syntax highlighting
Octocat-spinner-32 matchers Update generators and tests to use doubles/actual models
Octocat-spinner-32 model_specs this relies on order, order is now defined not default
Octocat-spinner-32 request_specs Fixes typo in link href
Octocat-spinner-32 routing_specs Update README to use expect syntax
Octocat-spinner-32 step_definitions Use Cucumber's 'step' method to remove deprecation warnings.
Octocat-spinner-32 support We can only test rspec-rails 3 with capybara on 1.9.3 and above
Octocat-spinner-32 view_specs Doc: "infers controller action" heading
Octocat-spinner-32 .nav Allows metadata to override the type of Rails spec
Octocat-spinner-32 Generators.md Add feature generator and include in list of available generators
Octocat-spinner-32 GettingStarted.md doc update
Octocat-spinner-32 README.md Bumps Gemfile line to 3.0
Octocat-spinner-32 RailsVersions.md add page on rspec/rails version compatibility
Octocat-spinner-32 Transactions.md Change a few more places to use `expect`
Octocat-spinner-32 Upgrade.md Change a few more places to use `expect`
Octocat-spinner-32 directory_structure.feature Allows metadata to override the type of Rails spec
README.md

rspec-rails extends Rails' built-in testing framework to support rspec examples for requests, controllers, models, views, helpers, mailers and routing.

Rails

rspec-rails 3 supports Rails 3.x and 4.x. For earlier versions of Rails, you need rspec-rails 1.

Install

gem install rspec-rails

This installs the following gems:

rspec
rspec-core
rspec-expectations
rspec-mocks
rspec-rails

Configure

Add rspec-rails to the :test and :development groups in the Gemfile:

group :test, :development do
  gem 'rspec-rails', '~> 3.0.0.beta'
end

It needs to be in the :development group to expose generators and rake tasks without having to type RAILS_ENV=test.

Now you can run:

script/rails generate rspec:install

This adds the spec directory and some skeleton files, including a .rspec file.

Issues

The documentation for rspec-rails is a work in progress. We'll be adding Cucumber features over time, and clarifying existing ones. If you have specific features you'd like to see added, find the existing documentation incomplete or confusing, or, better yet, wish to write a missing Cucumber feature yourself, please submit an issue or a pull request.

Something went wrong with that request. Please try again.