summaryrefslogtreecommitdiff
path: root/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/net-http/httpheader/set_form_data_spec.rb')
-rw-r--r--spec/ruby/library/net-http/httpheader/set_form_data_spec.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb b/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb
index 7aac19f045..093dc100d5 100644
--- a/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb
@@ -1,8 +1,31 @@
require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
-require_relative 'shared/set_form_data'
describe "Net::HTTPHeader#set_form_data" do
- it_behaves_like :net_httpheader_set_form_data, :set_form_data
+ before :each do
+ @headers = NetHTTPHeaderSpecs::Example.new
+ end
+
+ describe "when passed params" do
+ it "automatically set the 'Content-Type' to 'application/x-www-form-urlencoded'" do
+ @headers.set_form_data("cmd" => "search", "q" => "ruby", "max" => "50")
+ @headers["Content-Type"].should == "application/x-www-form-urlencoded"
+ end
+
+ it "sets self's body based on the passed form parameters" do
+ @headers.set_form_data("cmd" => "search", "q" => "ruby", "max" => "50")
+ @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"]
+ end
+ end
+
+ describe "when passed params, separator" do
+ it "sets self's body based on the passed form parameters and the passed separator" do
+ @headers.set_form_data({"cmd" => "search", "q" => "ruby", "max" => "50"}, "&")
+ @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"]
+
+ @headers.set_form_data({"cmd" => "search", "q" => "ruby", "max" => "50"}, ";")
+ @headers.body.split(";").sort.should == ["cmd=search", "max=50", "q=ruby"]
+ end
+ end
end