Module: Mack::Testing::Helpers

Defined in:
lib/mack-javascript/helpers/testing_helpers.rb

Instance Method Summary collapse

Instance Method Details

#xhr(method, uri, options = {}) ⇒ Object

simulates an ajax request



5
6
7
8
# File 'lib/mack-javascript/helpers/testing_helpers.rb', line 5

def xhr(method, uri, options = {})
  options = {:input => options.to_params} if method == :post || method == :put
  build_response(request.send(method, uri, build_request_options(options.merge({"HTTP_X_REQUESTED_WITH" => 'XMLHttpRequest', "HTTP_ACCEPT" => 'text/javascript, text/html, application/xml, text/xml, */*'}))))
end