| Module | Mack::Testing::Helpers |
| In: |
lib/mack/testing/helpers.rb
|
Clears all the sessions.
# File lib/mack/testing/helpers.rb, line 122
122: def clear_session
123: Mack::SessionStore.expire_all
124: end
create a wrapper object for file upload testing.
# File lib/mack/testing/helpers.rb, line 47
47: def file_for_upload(path)
48: return Mack::Testing::FileWrapper.new(path)
49: end
Used to create a ‘session’ around a block of code. This is great of ‘integration’ tests.
# File lib/mack/testing/helpers.rb, line 111
111: def in_session
112: @_mack_in_session = true
113: clear_session
114: $current_session_id = session.id
115: yield
116: $current_session_id = nil
117: clear_session
118: @_mack_in_session = false
119: end
Performs a ‘post’ request for the specified uri.
# File lib/mack/testing/helpers.rb, line 57
57: def post(uri, options = {})
58: if options[:multipart]
59: form_input = build_multipart_data(options)
60: build_response(request.post(uri, build_request_options({"CONTENT_TYPE" => "multipart/form-data, boundary=Mack-boundary", "CONTENT_LENGTH" => form_input.size, :input => form_input})))
61: else
62: build_response(request.post(uri, build_request_options({:input => options.to_params})))
63: end
64: end
Performs a ‘put’ request for the specified uri.
# File lib/mack/testing/helpers.rb, line 67
67: def put(uri, options = {})
68: if options[:multipart]
69: form_input = build_multipart_data(options)
70: build_response(request.put(uri, build_request_options({"CONTENT_TYPE" => "multipart/form-data, boundary=Mack-boundary", "CONTENT_LENGTH" => form_input.size, :input => form_input})))
71: else
72: build_response(request.put(uri, build_request_options({:input => options.to_params})))
73: end
74: end
Removes a cookie.
# File lib/mack/testing/helpers.rb, line 137
137: def remove_cookie(name)
138: test_cookies.delete(name)
139: end
Returns a Rack::MockRequest. If there isn‘t one, a new one is created.
# File lib/mack/testing/helpers.rb, line 82
82: def request
83: @request ||= Rack::MockRequest.new(mack_app)
84: end
Returns the last Rack::MockResponse that got generated by a call.
# File lib/mack/testing/helpers.rb, line 87
87: def response
88: @testing_response
89: end