Skip to content

Instantly share code, notes, and snippets.

@DougPuchalski
Created January 17, 2016 23:46
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 DougPuchalski/f6806f4867f688e6f2d1 to your computer and use it in GitHub Desktop.
Save DougPuchalski/f6806f4867f688e6f2d1 to your computer and use it in GitHub Desktop.
require 'rspec'
require 'webmock/rspec'
WebMock.disable_net_connect!
require 'httparty'
class MyClass
include HTTParty
def self.post
super("http://example.com/", body: "hello world")
end
end
describe 'Body test' do
it 'works with body' do
stub_request(:post, "http://example.com/").to_return(:status => 200, :body => "xxx", :headers => {})
response = MyClass.post
expect(response).to_not be_nil
end
it 'works with blank body' do
stub_request(:post, "http://example.com/").to_return(:status => 200, :body => "", :headers => {})
response = MyClass.post
expect(response).to_not be_nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment