Skip to content

Instantly share code, notes, and snippets.

@michaelrkn
Last active December 15, 2015 02:39
Show Gist options
  • Select an option

  • Save michaelrkn/5189150 to your computer and use it in GitHub Desktop.

Select an option

Save michaelrkn/5189150 to your computer and use it in GitHub Desktop.
webmock stub example
require 'spec_helper'
describe Gist do
context '.create' do
it 'POSTs a new Gist to the user\'s account' do
gist = {:public => 'true',
:description => 'a test gist',
:files => {'test_file.rb' => {:content => 'puts "hello world!"'}}}
stub = stub_request(:post, "https://#{GITHUB_USERNAME}:#{GITHUB_PASSWORD}@api.github.com/gists").with(:body => gist.to_json)
Gist.create(gist)
stub.should have_been_requested
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment