summaryrefslogtreecommitdiff
path: root/spec/ruby/library/net/http/http/post_form_spec.rb
blob: 4a5d7ec731f6a05f3e30286850180b4c8c6fbe48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require File.expand_path('../fixtures/http_server', __FILE__)

describe "Net::HTTP.post_form when passed URI" do
  before :each do
    NetHTTPSpecs.start_server
    @port = NetHTTPSpecs.port
  end

  after :each do
    NetHTTPSpecs.stop_server
  end

  it "POSTs the passed form data to the given uri" do
    uri = URI.parse("http://localhost:#{@port}/request/body")
    data = { test: :data }

    res = Net::HTTP.post_form(uri, data)
    res.body.should == "test=data"
  end
end