rubysl-cgi 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/cgi.rb +1 -0
- data/lib/rubysl/cgi.rb +2 -0
- data/lib/rubysl/cgi/cgi.rb +2333 -0
- data/lib/rubysl/cgi/version.rb +5 -0
- data/rubysl-cgi.gemspec +23 -0
- data/spec/cookie/domain_spec.rb +22 -0
- data/spec/cookie/expires_spec.rb +22 -0
- data/spec/cookie/initialize_spec.rb +146 -0
- data/spec/cookie/name_spec.rb +22 -0
- data/spec/cookie/parse_spec.rb +17 -0
- data/spec/cookie/path_spec.rb +22 -0
- data/spec/cookie/secure_spec.rb +69 -0
- data/spec/cookie/to_s_spec.rb +28 -0
- data/spec/cookie/value_spec.rb +79 -0
- data/spec/escapeElement_spec.rb +19 -0
- data/spec/escapeHTML_spec.rb +25 -0
- data/spec/escape_spec.rb +13 -0
- data/spec/header_spec.rb +7 -0
- data/spec/htmlextension/a_spec.rb +48 -0
- data/spec/htmlextension/base_spec.rb +32 -0
- data/spec/htmlextension/blockquote_spec.rb +32 -0
- data/spec/htmlextension/br_spec.rb +21 -0
- data/spec/htmlextension/caption_spec.rb +32 -0
- data/spec/htmlextension/checkbox_group_spec.rb +77 -0
- data/spec/htmlextension/checkbox_spec.rb +76 -0
- data/spec/htmlextension/doctype_spec.rb +26 -0
- data/spec/htmlextension/file_field_spec.rb +73 -0
- data/spec/htmlextension/fixtures/common.rb +16 -0
- data/spec/htmlextension/form_spec.rb +57 -0
- data/spec/htmlextension/frame_spec.rb +13 -0
- data/spec/htmlextension/frameset_spec.rb +13 -0
- data/spec/htmlextension/hidden_spec.rb +58 -0
- data/spec/htmlextension/html_spec.rb +65 -0
- data/spec/htmlextension/image_button_spec.rb +68 -0
- data/spec/htmlextension/img_spec.rb +84 -0
- data/spec/htmlextension/multipart_form_spec.rb +63 -0
- data/spec/htmlextension/password_field_spec.rb +83 -0
- data/spec/htmlextension/popup_menu_spec.rb +7 -0
- data/spec/htmlextension/radio_button_spec.rb +76 -0
- data/spec/htmlextension/radio_group_spec.rb +78 -0
- data/spec/htmlextension/reset_spec.rb +56 -0
- data/spec/htmlextension/scrolling_list_spec.rb +7 -0
- data/spec/htmlextension/shared/popup_menu.rb +94 -0
- data/spec/htmlextension/submit_spec.rb +56 -0
- data/spec/htmlextension/text_field_spec.rb +83 -0
- data/spec/htmlextension/textarea_spec.rb +72 -0
- data/spec/http_header_spec.rb +9 -0
- data/spec/initialize_spec.rb +171 -0
- data/spec/out_spec.rb +50 -0
- data/spec/parse_spec.rb +23 -0
- data/spec/pretty_spec.rb +23 -0
- data/spec/print_spec.rb +25 -0
- data/spec/queryextension/accept_charset_spec.rb +21 -0
- data/spec/queryextension/accept_encoding_spec.rb +21 -0
- data/spec/queryextension/accept_language_spec.rb +21 -0
- data/spec/queryextension/accept_spec.rb +21 -0
- data/spec/queryextension/auth_type_spec.rb +21 -0
- data/spec/queryextension/cache_control_spec.rb +21 -0
- data/spec/queryextension/content_length_spec.rb +25 -0
- data/spec/queryextension/content_type_spec.rb +21 -0
- data/spec/queryextension/cookies_spec.rb +9 -0
- data/spec/queryextension/element_reference_spec.rb +33 -0
- data/spec/queryextension/from_spec.rb +21 -0
- data/spec/queryextension/gateway_interface_spec.rb +21 -0
- data/spec/queryextension/has_key_spec.rb +6 -0
- data/spec/queryextension/host_spec.rb +21 -0
- data/spec/queryextension/include_spec.rb +6 -0
- data/spec/queryextension/key_spec.rb +6 -0
- data/spec/queryextension/keys_spec.rb +19 -0
- data/spec/queryextension/multipart_spec.rb +39 -0
- data/spec/queryextension/negotiate_spec.rb +21 -0
- data/spec/queryextension/params_spec.rb +44 -0
- data/spec/queryextension/path_info_spec.rb +21 -0
- data/spec/queryextension/path_translated_spec.rb +21 -0
- data/spec/queryextension/pragma_spec.rb +21 -0
- data/spec/queryextension/query_string_spec.rb +21 -0
- data/spec/queryextension/raw_cookie2_spec.rb +21 -0
- data/spec/queryextension/raw_cookie_spec.rb +21 -0
- data/spec/queryextension/referer_spec.rb +21 -0
- data/spec/queryextension/remote_addr_spec.rb +21 -0
- data/spec/queryextension/remote_host_spec.rb +21 -0
- data/spec/queryextension/remote_ident_spec.rb +21 -0
- data/spec/queryextension/remote_user_spec.rb +21 -0
- data/spec/queryextension/request_method_spec.rb +21 -0
- data/spec/queryextension/script_name_spec.rb +21 -0
- data/spec/queryextension/server_name_spec.rb +21 -0
- data/spec/queryextension/server_port_spec.rb +25 -0
- data/spec/queryextension/server_protocol_spec.rb +21 -0
- data/spec/queryextension/server_software_spec.rb +21 -0
- data/spec/queryextension/shared/has_key.rb +19 -0
- data/spec/queryextension/user_agent_spec.rb +21 -0
- data/spec/rfc1123_date_spec.rb +9 -0
- data/spec/shared/http_header.rb +111 -0
- data/spec/unescapeElement_spec.rb +19 -0
- data/spec/unescapeHTML_spec.rb +33 -0
- data/spec/unescape_spec.rb +14 -0
- metadata +293 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#accept_charset" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_ACCEPT_CHARSET']" do
|
14
|
+
old_value, ENV['HTTP_ACCEPT_CHARSET'] = ENV['HTTP_ACCEPT_CHARSET'], "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
|
15
|
+
begin
|
16
|
+
@cgi.accept_charset.should == "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_ACCEPT_CHARSET'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#accept_encoding" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_ACCEPT_ENCODING']" do
|
14
|
+
old_value, ENV['HTTP_ACCEPT_ENCODING'] = ENV['HTTP_ACCEPT_ENCODING'], "gzip,deflate"
|
15
|
+
begin
|
16
|
+
@cgi.accept_encoding.should == "gzip,deflate"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_ACCEPT_ENCODING'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#accept_language" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_ACCEPT_LANGUAGE']" do
|
14
|
+
old_value, ENV['HTTP_ACCEPT_LANGUAGE'] = ENV['HTTP_ACCEPT_LANGUAGE'], "en-us,en;q=0.5"
|
15
|
+
begin
|
16
|
+
@cgi.accept_language.should == "en-us,en;q=0.5"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_ACCEPT_LANGUAGE'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#accept" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_ACCEPT']" do
|
14
|
+
old_value, ENV['HTTP_ACCEPT'] = ENV['HTTP_ACCEPT'], "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
|
15
|
+
begin
|
16
|
+
@cgi.accept.should == "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_ACCEPT'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#auth_type" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['AUTH_TYPE']" do
|
14
|
+
old_value, ENV['AUTH_TYPE'] = ENV['AUTH_TYPE'], "Basic"
|
15
|
+
begin
|
16
|
+
@cgi.auth_type.should == "Basic"
|
17
|
+
ensure
|
18
|
+
ENV['AUTH_TYPE'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#cache_control" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_CACHE_CONTROL']" do
|
14
|
+
old_value, ENV['HTTP_CACHE_CONTROL'] = ENV['HTTP_CACHE_CONTROL'], "no-cache"
|
15
|
+
begin
|
16
|
+
@cgi.cache_control.should == "no-cache"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_CACHE_CONTROL'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#content_length" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['CONTENT_LENGTH'] as Integer" do
|
14
|
+
old_value = ENV['CONTENT_LENGTH']
|
15
|
+
begin
|
16
|
+
ENV['CONTENT_LENGTH'] = nil
|
17
|
+
@cgi.content_length.should be_nil
|
18
|
+
|
19
|
+
ENV['CONTENT_LENGTH'] = "100"
|
20
|
+
@cgi.content_length.should eql(100)
|
21
|
+
ensure
|
22
|
+
ENV['CONTENT_LENGTH'] = old_value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#content_type" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['CONTENT_TYPE']" do
|
14
|
+
old_value, ENV['CONTENT_TYPE'] = ENV['CONTENT_TYPE'], "text/html"
|
15
|
+
begin
|
16
|
+
@cgi.content_type.should == "text/html"
|
17
|
+
ensure
|
18
|
+
ENV['CONTENT_TYPE'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#[]" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b&two=c", ENV['QUERY_STRING']
|
7
|
+
@cgi = CGI.new
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
12
|
+
ENV['QUERY_STRING'] = @old_query_string
|
13
|
+
end
|
14
|
+
|
15
|
+
it "it returns the value for the parameter with the given key" do
|
16
|
+
@cgi["one"].should == "a"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "only returns the first value for parameters with multiple values" do
|
20
|
+
@cgi["two"].should == "b"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a String" do
|
24
|
+
@cgi["one"].should be_kind_of(String)
|
25
|
+
end
|
26
|
+
|
27
|
+
ruby_version_is "" ... "1.9" do
|
28
|
+
it "sets the other values in the returned value" do
|
29
|
+
@cgi["one"].to_a.should == ["a"]
|
30
|
+
@cgi["two"].to_a.should == ["b", "c"]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#from" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_FROM']" do
|
14
|
+
old_value, ENV['HTTP_FROM'] = ENV['HTTP_FROM'], "googlebot(at)googlebot.com"
|
15
|
+
begin
|
16
|
+
@cgi.from.should == "googlebot(at)googlebot.com"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_FROM'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#gateway_interface" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['GATEWAY_INTERFACE']" do
|
14
|
+
old_value, ENV['GATEWAY_INTERFACE'] = ENV['GATEWAY_INTERFACE'], "CGI/1.1"
|
15
|
+
begin
|
16
|
+
@cgi.gateway_interface.should == "CGI/1.1"
|
17
|
+
ensure
|
18
|
+
ENV['GATEWAY_INTERFACE'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#host" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_HOST']" do
|
14
|
+
old_value, ENV['HTTP_HOST'] = ENV['HTTP_HOST'], "localhost"
|
15
|
+
begin
|
16
|
+
@cgi.host.should == "localhost"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_HOST'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#keys" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b", ENV['QUERY_STRING']
|
7
|
+
|
8
|
+
@cgi = CGI.new
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:each) do
|
12
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
13
|
+
ENV['QUERY_STRING'] = @old_query_string
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns all parameter keys as an Array" do
|
17
|
+
@cgi.keys.sort.should == ["one", "two"]
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require "stringio"
|
3
|
+
|
4
|
+
describe "CGI::QueryExtension#multipart?" do
|
5
|
+
before(:each) do
|
6
|
+
@old_stdin = $stdin
|
7
|
+
|
8
|
+
@old_request_method = ENV['REQUEST_METHOD']
|
9
|
+
@old_content_type = ENV['CONTENT_TYPE']
|
10
|
+
@old_content_length = ENV['CONTENT_LENGTH']
|
11
|
+
|
12
|
+
ENV['REQUEST_METHOD'] = "POST"
|
13
|
+
ENV["CONTENT_TYPE"] = "multipart/form-data; boundary=---------------------------1137522503144128232716531729"
|
14
|
+
ENV["CONTENT_LENGTH"] = "222"
|
15
|
+
|
16
|
+
$stdin = StringIO.new <<-EOS
|
17
|
+
-----------------------------1137522503144128232716531729\r
|
18
|
+
Content-Disposition: form-data; name="file"; filename=""\r
|
19
|
+
Content-Type: application/octet-stream\r
|
20
|
+
\r
|
21
|
+
\r
|
22
|
+
-----------------------------1137522503144128232716531729--\r
|
23
|
+
EOS
|
24
|
+
|
25
|
+
@cgi = CGI.new
|
26
|
+
end
|
27
|
+
|
28
|
+
after(:each) do
|
29
|
+
$stdin = @old_stdin
|
30
|
+
|
31
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
32
|
+
ENV['CONTENT_TYPE'] = @old_content_type
|
33
|
+
ENV['CONTENT_LENGTH'] = @old_content_length
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns true if the current Request is a multipart request" do
|
37
|
+
@cgi.multipart?.should be_true
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#negotiate" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
@cgi = CGI.new
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns ENV['HTTP_NEGOTIATE']" do
|
14
|
+
old_value, ENV['HTTP_NEGOTIATE'] = ENV['HTTP_NEGOTIATE'], "trans"
|
15
|
+
begin
|
16
|
+
@cgi.negotiate.should == "trans"
|
17
|
+
ensure
|
18
|
+
ENV['HTTP_NEGOTIATE'] = old_value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
describe "CGI::QueryExtension#params" do
|
4
|
+
before(:each) do
|
5
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
6
|
+
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b&two=c&three", ENV['QUERY_STRING']
|
7
|
+
@cgi = CGI.new
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ENV['QUERY_STRING'] = @old_query_string
|
12
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
13
|
+
end
|
14
|
+
|
15
|
+
ruby_version_is "" ... "1.9" do
|
16
|
+
it "returns the parsed HTTP Query Params" do
|
17
|
+
@cgi.params.should == {"three"=>[nil], "two"=>["b", "c"], "one"=>["a"]}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ruby_version_is "1.9" do
|
22
|
+
it "returns the parsed HTTP Query Params" do
|
23
|
+
@cgi.params.should == {"three"=>[], "two"=>["b", "c"], "one"=>["a"]}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "CGI::QueryExtension#params=" do
|
29
|
+
before(:each) do
|
30
|
+
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
31
|
+
@cgi = CGI.new
|
32
|
+
end
|
33
|
+
|
34
|
+
after(:each) do
|
35
|
+
ENV['REQUEST_METHOD'] = @old_request_method
|
36
|
+
end
|
37
|
+
|
38
|
+
it "sets the HTTP Query Params to the passed argument" do
|
39
|
+
@cgi.params.should == {}
|
40
|
+
|
41
|
+
@cgi.params = {"one"=>["a"], "two"=>["b", "c"]}
|
42
|
+
@cgi.params.should == {"one"=>["a"], "two"=>["b", "c"]}
|
43
|
+
end
|
44
|
+
end
|