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!
More about adding a collaboratorController specs
Controller specs live in spec/controllers
or any example group with
:type => :controller
.
A controller spec is an RSpec wrapper for a Rails functional test
(ActionController::TestCase::Behavior).
It allows you to simulate a single http request in each example, and then
specify expected outcomes such as:
- rendered templates
- redirects
- instance variables assigned in the controller to be shared with the view
- cookies sent back with the response
To specify outcomes, you can use:
- standard rspec matchers (
expect(response.status).to eq(200)
) - standard test/unit assertions (
assert_equal 200, response.status
) - rails assertions (
assert_response 200
) - rails-specific matchers:
expect(response).to render_template(wraps assert_template)
expect(response).to redirect_to(wraps assert_redirected_to)
expect(assigns(:widget)).to be_a_new(Widget)
Examples
describe TeamsController do
describe "GET index" do
it "assigns @teams" do
team = Team.create
get :index
expect(assigns(:teams)).to eq([team])
end
it "renders the index template" do
get :index
expect(response).to render_template("index")
end
end
end
Views
- by default, views are not rendered. See views are stubbed by default and render_views for details.
Topics
- anonymous controller
- bypass rescue
- controller spec
- Cookies
- engine routes for controllers
- render_views
- views are stubbed by default
Last published over 7 years ago by alindeman.