Skip to content

Instantly share code, notes, and snippets.

@lucasmazza
Created November 24, 2010 16:43
Show Gist options
  • Save lucasmazza/713958 to your computer and use it in GitHub Desktop.
Save lucasmazza/713958 to your computer and use it in GitHub Desktop.
Using xhr with rspec + rack/test
module XhrHelpers
def xhr(path, params = {})
verb = params.delete(:as) || :get
send(verb,path, params, "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest")
end
alias_method :ajax, :xhr
end
RSpec.configuration.include XhrHelpers, :type => :controller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment