Module: Jets::SpecHelpers
- Defined in:
- lib/jets/spec_helpers.rb,
lib/jets/spec_helpers/params.rb,
lib/jets/spec_helpers/request.rb,
lib/jets/spec_helpers/response.rb
Defined Under Namespace
Classes: Params, Request, Response
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #fixture_file(filename) ⇒ Object
- #fixture_path(filename) ⇒ Object
- #http_call(method:, path:, **params) ⇒ Object
- #initialize ⇒ Object
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
7 8 9 |
# File 'lib/jets/spec_helpers.rb', line 7 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/jets/spec_helpers.rb', line 7 def response @response end |
Instance Method Details
#fixture_file(filename) ⇒ Object
45 46 47 |
# File 'lib/jets/spec_helpers.rb', line 45 def fixture_file(filename) File.new(fixture_path(filename)) end |
#fixture_path(filename) ⇒ Object
41 42 43 |
# File 'lib/jets/spec_helpers.rb', line 41 def fixture_path(filename) "#{Jets.root}/spec/fixtures/#{filename}" end |
#http_call(method:, path:, **params) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jets/spec_helpers.rb', line 25 def http_call(method:, path:, **params) request.method = method.to_sym request.path = path request.headers.deep_merge!(params.delete(:headers) || {}) request.params.body_params = params.delete(:params) || params || {} request.params.query_params = params.delete(:query) request.params.query_params ||= params if request.method == :get request.params.query_params ||= {} request.params.path_params = params @response = request.dispatch! end |