I\'m writing RSpec tests and I have come to a point where I am not reading the same opinions on different websites. The directory structure for RSpec is clear when we are d
Check the dates of the books and the versions of RSpec for which they were written. The naming structure has changed slightly over time.
According to the docs for rspec-rails, request specs can go in spec/requests, spec/api, or spec/integration. I prefer to put request specs in spec/requests.
To make things more interesting, if you are using Capybara with rspec-rails, it will work with spec/requests for Capybara 1.x, and spec/features for Capybara 2.
As to individual spec file names, when there is a specific class under test, like a Rails model, you should use an analogous spec file name:
app/models/user.rb -> spec/models/user_spec.rb
View specs should use the template name:
app/views/users/index.html.erb -> spec/views/users/index.html.erb_spec.rb
Namespaced models should include the namespace in the spec file path:
app/models/admin/user.rb -> spec/models/admin/user_spec.rb
The RSpec scaffold generator is a good guide for showing where these specs belong.
When there is no specific class under test, as is the case with request specs, IMHO you should feel free to use a name that describes the thing being tested. E.g. spec/requests/place_an_order_spec.rb.