Skip to content

Instantly share code, notes, and snippets.

@adambeynon
Last active December 28, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adambeynon/7564695 to your computer and use it in GitHub Desktop.
Save adambeynon/7564695 to your computer and use it in GitHub Desktop.
module JqueryRspecHelpers
def stub_http(action, url, result)
expect(HTTP).to receive(action).with(url).and_yield(result)
end
end
describe User do
describe ".current" do
it "should make an http request for user details" do
stub_http(:get, '/current_user', { "name" => "Fred", "admin" => true })
current = User.current
expect(current.name).to eq("Fred")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment