Skip to content

Instantly share code, notes, and snippets.

@cyx
Forked from lucasmazza/xhr.rb
Created October 30, 2011 08:28
Show Gist options
  • Save cyx/1325708 to your computer and use it in GitHub Desktop.
Save cyx/1325708 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