Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec helpers: dont cache request headers between specs #343

Merged
merged 1 commit into from Aug 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/jets/spec_helpers/controllers.rb
Expand Up @@ -2,12 +2,11 @@ module Jets::SpecHelpers
module Controllers
include Jets::Router::Helpers # must be at the top because response is overridden later

attr_reader :request, :response

def initialize(*)
super
@request = Request.new(:get, '/', {}, Params.new)
@response = nil # will be set after http_call
attr_reader :response
# Note: caching it like this instead of within the initialize results in the headers not being cached
# See: https://community.rubyonjets.com/t/is-jets-spechelpers-controllers-request-being-cached/244/2
def request
@request ||= Request.new(:get, '/', {}, Params.new)
end

rest_methods = %w[get post put patch delete]
Expand Down