RSpec: What is the difference between a feature and a request spec?

The conceptual difference is that you’re usually testing a user story, and all interaction should be driven via the user interface. That’s where Capybara comes in. A request spec is still testing the behavior of your application and doesn’t have the expectation of readability that an acceptance test would have. So, feature is there for the improved syntax for acceptance tests.

Technical differences include request specs wrap Rails integration tests, whereas feature specs don’t. This means with request specs you can use methods get, post, put, delete and assert against response. With feature specs you should drive all interaction through the browser and use methods like visit and assert against the page.

I’d recommend reading the feature_spec.feature in the rspec-rails source code on github. I hope this helps.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)