11
votes

I'm using rspec-rails 2.12.0 and capybara 2.0.1 for testing. In capybara 2.x you need to put your specs in spec/features instead of spec/requests. Is there a way so if I were to generate a scaffold ala 'rails g scaffold Model' that rspec would generate the feature specs for me in the correct directory?

1
Yep! I'm wondering the same thing here! Any luck? I need rspec to include those directories as well. Do you know how? - jlstr
@JoseE I haven't figured anything out. At the moment I just turned off the generator for request specs, and am manually adding files to the features folder. - jhummel
Yes, me too. I guess there aren't any generators available so far :( - jlstr

1 Answers

8
votes

"controller" and "request" specs are tied to the inner app mechanism and thus can be auto generated by scaffold generator mimicking the controller structure.

"Feature" specs are completely different conceptually from these specs as they describe end user interactions with the application, they cannot be generated in advance as there is no way to effectively guess what feature you want to test. Feature specs also spread across multiple controllers, you don't want them to be mapped to your controller scaffold. The only thing that could be done is generate an almost empty feature/xyz file for you to fill in, which is pretty useless as chances are you will have to delete/rename it.