Skip to content

Commit c640f9e

Browse files
committed
Add documentation about http headers into controller spec
1 parent e33e417 commit c640f9e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: features/controller_specs/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,21 @@ To specify outcomes, you can use:
6060
* by default, views are not rendered. See
6161
[views are stubbed by default](controller-specs/views-are-stubbed-by-default) and
6262
[render_views](controller-specs/render-views) for details.
63+
64+
## Headers
65+
66+
We encourage you to use [request specs](https://relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec) if you want
67+
to set headers in your call. If you still want to use a controller specs with custom http headers
68+
you could use `request.headers`:
69+
70+
require "rails_helper"
71+
72+
RSpec.describe TeamsController, :type => :controller do
73+
describe "GET index"
74+
it "returns a 200" do
75+
request.headers["Authorization"] = "foo"
76+
get :show
77+
expect(response).to have_http_status(:ok)
78+
end
79+
end
80+
end

0 commit comments

Comments
 (0)