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?
Capybara is a web-based automation framework that creates certain functional tests in order to simulate how a user may interact with an application. It is a library used on top of a web-based driver that writes the code in Ruby. This Ruby library has an advantage as it interacts with applications from a Rack level.
Feature specs, a kind of acceptance test, are high-level tests that walk through your entire application ensuring that each of the components work together. They're written from the perspective of a user clicking around the application and filling in forms.
Capybara is an acceptance test framework for web applications. It's a common choice for end-to-end, acceptance, or integration testing in Rails applications. It allows developers to simulate a user on a web page and make assertions based on the content and environment of the page.
"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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With