diff options
Diffstat (limited to 'spec/ruby/library/cgi/initialize_spec.rb')
-rw-r--r-- | spec/ruby/library/cgi/initialize_spec.rb | 209 |
1 files changed, 106 insertions, 103 deletions
diff --git a/spec/ruby/library/cgi/initialize_spec.rb b/spec/ruby/library/cgi/initialize_spec.rb index 61bc971d49..d46b5a3564 100644 --- a/spec/ruby/library/cgi/initialize_spec.rb +++ b/spec/ruby/library/cgi/initialize_spec.rb @@ -1,133 +1,136 @@ require_relative '../../spec_helper' -require 'cgi' -describe "CGI#initialize" do - it "is private" do - CGI.should have_private_instance_method(:initialize) - end -end +ruby_version_is ""..."3.5" do + require 'cgi' -describe "CGI#initialize when passed no arguments" do - before :each do - ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD'] - @cgi = CGI.allocate - end - - after :each do - ENV['REQUEST_METHOD'] = @old_request_method - end - - it "extends self with CGI::QueryExtension" do - @cgi.send(:initialize) - @cgi.should be_kind_of(CGI::QueryExtension) + describe "CGI#initialize" do + it "is private" do + CGI.should have_private_instance_method(:initialize) + end end - it "does not extend self with CGI::HtmlExtension" do - @cgi.send(:initialize) - @cgi.should_not be_kind_of(CGI::HtmlExtension) - end + describe "CGI#initialize when passed no arguments" do + before :each do + ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD'] + @cgi = CGI.allocate + end - it "does not extend self with any of the other HTML modules" do - @cgi.send(:initialize) - @cgi.should_not be_kind_of(CGI::HtmlExtension) - @cgi.should_not be_kind_of(CGI::Html3) - @cgi.should_not be_kind_of(CGI::Html4) - @cgi.should_not be_kind_of(CGI::Html4Tr) - @cgi.should_not be_kind_of(CGI::Html4Fr) - end + after :each do + ENV['REQUEST_METHOD'] = @old_request_method + end - it "sets #cookies based on ENV['HTTP_COOKIE']" do - begin - old_env, ENV["HTTP_COOKIE"] = ENV["HTTP_COOKIE"], "test=test yay" + it "extends self with CGI::QueryExtension" do @cgi.send(:initialize) - @cgi.cookies.should == { "test"=>[ "test yay" ] } - ensure - ENV["HTTP_COOKIE"] = old_env + @cgi.should be_kind_of(CGI::QueryExtension) end - end - it "sets #params based on ENV['QUERY_STRING'] when ENV['REQUEST_METHOD'] is GET" do - begin - old_env_query, ENV["QUERY_STRING"] = ENV["QUERY_STRING"], "?test=a&test2=b" - old_env_method, ENV["REQUEST_METHOD"] = ENV["REQUEST_METHOD"], "GET" + it "does not extend self with CGI::HtmlExtension" do @cgi.send(:initialize) - @cgi.params.should == { "test2" => ["b"], "?test" => ["a"] } - ensure - ENV["QUERY_STRING"] = old_env_query - ENV["REQUEST_METHOD"] = old_env_method + @cgi.should_not be_kind_of(CGI::HtmlExtension) end - end - it "sets #params based on ENV['QUERY_STRING'] when ENV['REQUEST_METHOD'] is HEAD" do - begin - old_env_query, ENV["QUERY_STRING"] = ENV["QUERY_STRING"], "?test=a&test2=b" - old_env_method, ENV["REQUEST_METHOD"] = ENV["REQUEST_METHOD"], "HEAD" + it "does not extend self with any of the other HTML modules" do @cgi.send(:initialize) - @cgi.params.should == { "test2" => ["b"], "?test" => ["a"] } - ensure - ENV["QUERY_STRING"] = old_env_query - ENV["REQUEST_METHOD"] = old_env_method + @cgi.should_not be_kind_of(CGI::HtmlExtension) + @cgi.should_not be_kind_of(CGI::Html3) + @cgi.should_not be_kind_of(CGI::Html4) + @cgi.should_not be_kind_of(CGI::Html4Tr) + @cgi.should_not be_kind_of(CGI::Html4Fr) end - end -end -describe "CGI#initialize when passed type" do - before :each do - ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD'] - @cgi = CGI.allocate - end + it "sets #cookies based on ENV['HTTP_COOKIE']" do + begin + old_env, ENV["HTTP_COOKIE"] = ENV["HTTP_COOKIE"], "test=test yay" + @cgi.send(:initialize) + @cgi.cookies.should == { "test"=>[ "test yay" ] } + ensure + ENV["HTTP_COOKIE"] = old_env + end + end - after :each do - ENV['REQUEST_METHOD'] = @old_request_method + it "sets #params based on ENV['QUERY_STRING'] when ENV['REQUEST_METHOD'] is GET" do + begin + old_env_query, ENV["QUERY_STRING"] = ENV["QUERY_STRING"], "?test=a&test2=b" + old_env_method, ENV["REQUEST_METHOD"] = ENV["REQUEST_METHOD"], "GET" + @cgi.send(:initialize) + @cgi.params.should == { "test2" => ["b"], "?test" => ["a"] } + ensure + ENV["QUERY_STRING"] = old_env_query + ENV["REQUEST_METHOD"] = old_env_method + end + end + + it "sets #params based on ENV['QUERY_STRING'] when ENV['REQUEST_METHOD'] is HEAD" do + begin + old_env_query, ENV["QUERY_STRING"] = ENV["QUERY_STRING"], "?test=a&test2=b" + old_env_method, ENV["REQUEST_METHOD"] = ENV["REQUEST_METHOD"], "HEAD" + @cgi.send(:initialize) + @cgi.params.should == { "test2" => ["b"], "?test" => ["a"] } + ensure + ENV["QUERY_STRING"] = old_env_query + ENV["REQUEST_METHOD"] = old_env_method + end + end end + describe "CGI#initialize when passed type" do + before :each do + ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD'] + @cgi = CGI.allocate + end - it "extends self with CGI::QueryExtension" do - @cgi.send(:initialize, "test") - @cgi.should be_kind_of(CGI::QueryExtension) - end + after :each do + ENV['REQUEST_METHOD'] = @old_request_method + end - it "extends self with CGI::QueryExtension, CGI::Html3 and CGI::HtmlExtension when the passed type is 'html3'" do - @cgi.send(:initialize, "html3") - @cgi.should be_kind_of(CGI::Html3) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html4) - @cgi.should_not be_kind_of(CGI::Html4Tr) - @cgi.should_not be_kind_of(CGI::Html4Fr) - end + it "extends self with CGI::QueryExtension" do + @cgi.send(:initialize, "test") + @cgi.should be_kind_of(CGI::QueryExtension) + end - it "extends self with CGI::QueryExtension, CGI::Html4 and CGI::HtmlExtension when the passed type is 'html4'" do - @cgi.send(:initialize, "html4") - @cgi.should be_kind_of(CGI::Html4) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) + it "extends self with CGI::QueryExtension, CGI::Html3 and CGI::HtmlExtension when the passed type is 'html3'" do + @cgi.send(:initialize, "html3") + @cgi.should be_kind_of(CGI::Html3) + @cgi.should be_kind_of(CGI::HtmlExtension) + @cgi.should be_kind_of(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html3) - @cgi.should_not be_kind_of(CGI::Html4Tr) - @cgi.should_not be_kind_of(CGI::Html4Fr) - end + @cgi.should_not be_kind_of(CGI::Html4) + @cgi.should_not be_kind_of(CGI::Html4Tr) + @cgi.should_not be_kind_of(CGI::Html4Fr) + end - it "extends self with CGI::QueryExtension, CGI::Html4Tr and CGI::HtmlExtension when the passed type is 'html4Tr'" do - @cgi.send(:initialize, "html4Tr") - @cgi.should be_kind_of(CGI::Html4Tr) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) + it "extends self with CGI::QueryExtension, CGI::Html4 and CGI::HtmlExtension when the passed type is 'html4'" do + @cgi.send(:initialize, "html4") + @cgi.should be_kind_of(CGI::Html4) + @cgi.should be_kind_of(CGI::HtmlExtension) + @cgi.should be_kind_of(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html3) - @cgi.should_not be_kind_of(CGI::Html4) - @cgi.should_not be_kind_of(CGI::Html4Fr) - end + @cgi.should_not be_kind_of(CGI::Html3) + @cgi.should_not be_kind_of(CGI::Html4Tr) + @cgi.should_not be_kind_of(CGI::Html4Fr) + end - it "extends self with CGI::QueryExtension, CGI::Html4Tr, CGI::Html4Fr and CGI::HtmlExtension when the passed type is 'html4Fr'" do - @cgi.send(:initialize, "html4Fr") - @cgi.should be_kind_of(CGI::Html4Tr) - @cgi.should be_kind_of(CGI::Html4Fr) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) + it "extends self with CGI::QueryExtension, CGI::Html4Tr and CGI::HtmlExtension when the passed type is 'html4Tr'" do + @cgi.send(:initialize, "html4Tr") + @cgi.should be_kind_of(CGI::Html4Tr) + @cgi.should be_kind_of(CGI::HtmlExtension) + @cgi.should be_kind_of(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html3) - @cgi.should_not be_kind_of(CGI::Html4) + @cgi.should_not be_kind_of(CGI::Html3) + @cgi.should_not be_kind_of(CGI::Html4) + @cgi.should_not be_kind_of(CGI::Html4Fr) + end + + it "extends self with CGI::QueryExtension, CGI::Html4Tr, CGI::Html4Fr and CGI::HtmlExtension when the passed type is 'html4Fr'" do + @cgi.send(:initialize, "html4Fr") + @cgi.should be_kind_of(CGI::Html4Tr) + @cgi.should be_kind_of(CGI::Html4Fr) + @cgi.should be_kind_of(CGI::HtmlExtension) + @cgi.should be_kind_of(CGI::QueryExtension) + + @cgi.should_not be_kind_of(CGI::Html3) + @cgi.should_not be_kind_of(CGI::Html4) + end end end |