You can treat each RSpec repo as an independent project. Please see the following files:. For more information, see cucumber scenarios for model specs. For more information, see cucumber scenarios for controller specs. Note: To encourage more isolated testing, views are not rendered by default in controller specs. If you are verifying discrete view logic, use a view spec. If you are verifying the behaviour of a controller and view together, consider a request spec. Request specs mix in behavior from ActionDispatch::Integration::Runner , which is the basis for Rails' integration tests.
FactoryGirl decouples this example from changes to validation requirements, which can be encoded into the underlying factory definition without requiring changes to this example. Among other benefits, Capybara binds the form post to the generated HTML, which means we don't need to specify them separately. For more information, see the Capybara integration docs. There are several other Ruby libs that implement the factory pattern or provide a DSL for request specs a.
Whether you choose these or other libs, we strongly recommend using something for each of these roles. Feature specs test your application from the outside by simulating a browser. Feature specs mix in functionality from the capybara gem, thus they require capybara to use. To use feature specs, add capybara to the Gemfile :. That could be why your rails 2. You don't have to follow my versions exactly, I'm not a fan at all of putting specific versions in a Gemfile but we ended up doing it here way back when because a we didn't fully understand bundler, and b We needed to make sure we were getting rails 2.
The reason the generators don't exist is that when you run rails generate Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How do I setup rspec with rails 2. Ask Question. Asked 9 years, 10 months ago. Active 3 years, 10 months ago. Viewed 2k times. A lot of the guides I've been finding don't use bundler. So, anyone have any guides for setting up rspec with bundler with rails 2.
Add a comment. To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here! Browse documentation Keyword search. There are several other Ruby libs that implement the factory pattern or provide a DSL for request specs a. Whether you choose these or other libs, we strongly recommend using something for each of these roles. Feature specs test your application from the outside by simulating a browser.
Feature specs mix in functionality from the capybara gem, thus they require capybara to use. To use feature specs, add capybara to the Gemfile :. For more information, see the cucumber scenarios for feature specs. For more information, see the cucumber scenarios for mailer specs. For more information, see the cucumber scenarios for job specs. View specs infer the controller name and path from the path to the view template.
This means that most of the time you don't need to set these values. When spec'ing a partial that is included across different controllers, you may need to override these values before rendering the view. To provide a layout for the render, you'll need to specify both the template and the layout explicitly. For example:. The code above assigns Widget. Note that because view specs mix in ActionView::TestCase behavior, any instance variables you set will be transparently propagated into your views similar to how instance variables you set in controller actions are made available in views.
RSpec doesn't officially support this pattern, which only works as a side-effect of the inclusion of ActionView::TestCase. Be aware that it may be made unavailable in the future.
0コメント