Guard CGI examples with Ruby 3.5 and use cgi/escape for related examples
This commit is contained in:
parent
600c616507
commit
ce6c1778fb
Notes:
git
2025-05-09 05:27:42 +00:00
@ -1,23 +1,26 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#domain" do
|
||||
it "returns self's domain" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.domain.should be_nil
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "domain" => "example.com")
|
||||
cookie.domain.should == "example.com"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#domain=" do
|
||||
it "sets self's domain" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.domain = "test.com"
|
||||
cookie.domain.should == "test.com"
|
||||
|
||||
cookie.domain = "example.com"
|
||||
cookie.domain.should == "example.com"
|
||||
describe "CGI::Cookie#domain" do
|
||||
it "returns self's domain" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.domain.should be_nil
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "domain" => "example.com")
|
||||
cookie.domain.should == "example.com"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#domain=" do
|
||||
it "sets self's domain" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.domain = "test.com"
|
||||
cookie.domain.should == "test.com"
|
||||
|
||||
cookie.domain = "example.com"
|
||||
cookie.domain.should == "example.com"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,23 +1,26 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#expires" do
|
||||
it "returns self's expiration date" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.expires.should be_nil
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "expires" => Time.at(1196524602))
|
||||
cookie.expires.should == Time.at(1196524602)
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#expires=" do
|
||||
it "sets self's expiration date" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.expires = Time.at(1196524602)
|
||||
cookie.expires.should == Time.at(1196524602)
|
||||
|
||||
cookie.expires = Time.at(1196525000)
|
||||
cookie.expires.should == Time.at(1196525000)
|
||||
describe "CGI::Cookie#expires" do
|
||||
it "returns self's expiration date" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.expires.should be_nil
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "expires" => Time.at(1196524602))
|
||||
cookie.expires.should == Time.at(1196524602)
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#expires=" do
|
||||
it "sets self's expiration date" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.expires = Time.at(1196524602)
|
||||
cookie.expires.should == Time.at(1196524602)
|
||||
|
||||
cookie.expires = Time.at(1196525000)
|
||||
cookie.expires.should == Time.at(1196525000)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,147 +1,150 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#initialize when passed String" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.allocate
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
it "sets the self's name to the passed String" do
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.name.should == "test-cookie"
|
||||
end
|
||||
describe "CGI::Cookie#initialize when passed String" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.allocate
|
||||
end
|
||||
|
||||
it "sets the self's value to an empty Array" do
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.value.should == []
|
||||
end
|
||||
|
||||
it "sets self to a non-secure cookie" do
|
||||
@cookie.send(:initialize, "test")
|
||||
@cookie.secure.should be_false
|
||||
end
|
||||
|
||||
it "does set self's path to an empty String when ENV[\"SCRIPT_NAME\"] is not set" do
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.path.should == ""
|
||||
end
|
||||
|
||||
it "does set self's path based on ENV[\"SCRIPT_NAME\"] when ENV[\"SCRIPT_NAME\"] is set" do
|
||||
old_script_name = ENV["SCRIPT_NAME"]
|
||||
|
||||
begin
|
||||
ENV["SCRIPT_NAME"] = "some/path/script.rb"
|
||||
it "sets the self's name to the passed String" do
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.path.should == "some/path/"
|
||||
@cookie.name.should == "test-cookie"
|
||||
end
|
||||
|
||||
ENV["SCRIPT_NAME"] = "script.rb"
|
||||
it "sets the self's value to an empty Array" do
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.value.should == []
|
||||
end
|
||||
|
||||
it "sets self to a non-secure cookie" do
|
||||
@cookie.send(:initialize, "test")
|
||||
@cookie.secure.should be_false
|
||||
end
|
||||
|
||||
it "does set self's path to an empty String when ENV[\"SCRIPT_NAME\"] is not set" do
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.path.should == ""
|
||||
end
|
||||
|
||||
ENV["SCRIPT_NAME"] = nil
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.path.should == ""
|
||||
ensure
|
||||
ENV["SCRIPT_NAME"] = old_script_name
|
||||
it "does set self's path based on ENV[\"SCRIPT_NAME\"] when ENV[\"SCRIPT_NAME\"] is set" do
|
||||
old_script_name = ENV["SCRIPT_NAME"]
|
||||
|
||||
begin
|
||||
ENV["SCRIPT_NAME"] = "some/path/script.rb"
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.path.should == "some/path/"
|
||||
|
||||
ENV["SCRIPT_NAME"] = "script.rb"
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.path.should == ""
|
||||
|
||||
ENV["SCRIPT_NAME"] = nil
|
||||
@cookie.send(:initialize, "test-cookie")
|
||||
@cookie.path.should == ""
|
||||
ensure
|
||||
ENV["SCRIPT_NAME"] = old_script_name
|
||||
end
|
||||
end
|
||||
|
||||
it "does not set self's expiration date" do
|
||||
@cookie.expires.should be_nil
|
||||
end
|
||||
|
||||
it "does not set self's domain" do
|
||||
@cookie.domain.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
it "does not set self's expiration date" do
|
||||
@cookie.expires.should be_nil
|
||||
end
|
||||
describe "CGI::Cookie#initialize when passed Hash" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.allocate
|
||||
end
|
||||
|
||||
it "does not set self's domain" do
|
||||
@cookie.domain.should be_nil
|
||||
end
|
||||
end
|
||||
it "sets self's contents based on the passed Hash" do
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => ["one", "two", "three"],
|
||||
'path' => 'some/path/',
|
||||
'domain' => 'example.com',
|
||||
'expires' => Time.at(1196524602),
|
||||
'secure' => true)
|
||||
|
||||
describe "CGI::Cookie#initialize when passed Hash" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.allocate
|
||||
end
|
||||
|
||||
it "sets self's contents based on the passed Hash" do
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => ["one", "two", "three"],
|
||||
'path' => 'some/path/',
|
||||
'domain' => 'example.com',
|
||||
'expires' => Time.at(1196524602),
|
||||
'secure' => true)
|
||||
|
||||
@cookie.name.should == "test-cookie"
|
||||
@cookie.value.should == ["one", "two", "three"]
|
||||
@cookie.path.should == "some/path/"
|
||||
@cookie.domain.should == "example.com"
|
||||
@cookie.expires.should == Time.at(1196524602)
|
||||
@cookie.secure.should be_true
|
||||
end
|
||||
|
||||
it "does set self's path based on ENV[\"SCRIPT_NAME\"] when the Hash has no 'path' entry" do
|
||||
old_script_name = ENV["SCRIPT_NAME"]
|
||||
|
||||
begin
|
||||
ENV["SCRIPT_NAME"] = "some/path/script.rb"
|
||||
@cookie.send(:initialize, 'name' => 'test-cookie')
|
||||
@cookie.name.should == "test-cookie"
|
||||
@cookie.value.should == ["one", "two", "three"]
|
||||
@cookie.path.should == "some/path/"
|
||||
@cookie.domain.should == "example.com"
|
||||
@cookie.expires.should == Time.at(1196524602)
|
||||
@cookie.secure.should be_true
|
||||
end
|
||||
|
||||
ENV["SCRIPT_NAME"] = "script.rb"
|
||||
@cookie.send(:initialize, 'name' => 'test-cookie')
|
||||
@cookie.path.should == ""
|
||||
it "does set self's path based on ENV[\"SCRIPT_NAME\"] when the Hash has no 'path' entry" do
|
||||
old_script_name = ENV["SCRIPT_NAME"]
|
||||
|
||||
ENV["SCRIPT_NAME"] = nil
|
||||
@cookie.send(:initialize, 'name' => 'test-cookie')
|
||||
@cookie.path.should == ""
|
||||
ensure
|
||||
ENV["SCRIPT_NAME"] = old_script_name
|
||||
begin
|
||||
ENV["SCRIPT_NAME"] = "some/path/script.rb"
|
||||
@cookie.send(:initialize, 'name' => 'test-cookie')
|
||||
@cookie.path.should == "some/path/"
|
||||
|
||||
ENV["SCRIPT_NAME"] = "script.rb"
|
||||
@cookie.send(:initialize, 'name' => 'test-cookie')
|
||||
@cookie.path.should == ""
|
||||
|
||||
ENV["SCRIPT_NAME"] = nil
|
||||
@cookie.send(:initialize, 'name' => 'test-cookie')
|
||||
@cookie.path.should == ""
|
||||
ensure
|
||||
ENV["SCRIPT_NAME"] = old_script_name
|
||||
end
|
||||
end
|
||||
|
||||
it "tries to convert the Hash's 'value' to an Array using #Array" do
|
||||
obj = mock("Converted To Array")
|
||||
obj.should_receive(:to_ary).and_return(["1", "2", "3"])
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => obj)
|
||||
@cookie.value.should == [ "1", "2", "3" ]
|
||||
|
||||
obj = mock("Converted To Array")
|
||||
obj.should_receive(:to_a).and_return(["one", "two", "three"])
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => obj)
|
||||
@cookie.value.should == [ "one", "two", "three" ]
|
||||
|
||||
obj = mock("Put into an Array")
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => obj)
|
||||
@cookie.value.should == [ obj ]
|
||||
end
|
||||
|
||||
it "raises a ArgumentError when the passed Hash has no 'name' entry" do
|
||||
-> { @cookie.send(:initialize, {}) }.should raise_error(ArgumentError)
|
||||
-> { @cookie.send(:initialize, "value" => "test") }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "tries to convert the Hash's 'value' to an Array using #Array" do
|
||||
obj = mock("Converted To Array")
|
||||
obj.should_receive(:to_ary).and_return(["1", "2", "3"])
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => obj)
|
||||
@cookie.value.should == [ "1", "2", "3" ]
|
||||
describe "CGI::Cookie#initialize when passed String, values ..." do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.allocate
|
||||
end
|
||||
|
||||
obj = mock("Converted To Array")
|
||||
obj.should_receive(:to_a).and_return(["one", "two", "three"])
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => obj)
|
||||
@cookie.value.should == [ "one", "two", "three" ]
|
||||
it "sets the self's name to the passed String" do
|
||||
@cookie.send(:initialize, "test-cookie", "one", "two", "three")
|
||||
@cookie.name.should == "test-cookie"
|
||||
end
|
||||
|
||||
obj = mock("Put into an Array")
|
||||
@cookie.send(:initialize,
|
||||
'name' => 'test-cookie',
|
||||
'value' => obj)
|
||||
@cookie.value.should == [ obj ]
|
||||
end
|
||||
it "sets the self's value to an Array containing all passed values" do
|
||||
@cookie.send(:initialize, "test-cookie", "one", "two", "three")
|
||||
@cookie.value.should == ["one", "two", "three"]
|
||||
end
|
||||
|
||||
it "raises a ArgumentError when the passed Hash has no 'name' entry" do
|
||||
-> { @cookie.send(:initialize, {}) }.should raise_error(ArgumentError)
|
||||
-> { @cookie.send(:initialize, "value" => "test") }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#initialize when passed String, values ..." do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.allocate
|
||||
end
|
||||
|
||||
it "sets the self's name to the passed String" do
|
||||
@cookie.send(:initialize, "test-cookie", "one", "two", "three")
|
||||
@cookie.name.should == "test-cookie"
|
||||
end
|
||||
|
||||
it "sets the self's value to an Array containing all passed values" do
|
||||
@cookie.send(:initialize, "test-cookie", "one", "two", "three")
|
||||
@cookie.value.should == ["one", "two", "three"]
|
||||
end
|
||||
|
||||
it "sets self to a non-secure cookie" do
|
||||
@cookie.send(:initialize, "test", "one", "two", "three")
|
||||
@cookie.secure.should be_false
|
||||
it "sets self to a non-secure cookie" do
|
||||
@cookie.send(:initialize, "test", "one", "two", "three")
|
||||
@cookie.secure.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,23 +1,26 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#name" do
|
||||
it "returns self's name" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.name.should == "test-cookie"
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "another-cookie")
|
||||
cookie.name.should == "another-cookie"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#name=" do
|
||||
it "sets self's expiration date" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.name = "another-name"
|
||||
cookie.name.should == "another-name"
|
||||
|
||||
cookie.name = "and-one-more"
|
||||
cookie.name.should == "and-one-more"
|
||||
describe "CGI::Cookie#name" do
|
||||
it "returns self's name" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.name.should == "test-cookie"
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "another-cookie")
|
||||
cookie.name.should == "another-cookie"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#name=" do
|
||||
it "sets self's expiration date" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.name = "another-name"
|
||||
cookie.name.should == "another-name"
|
||||
|
||||
cookie.name = "and-one-more"
|
||||
cookie.name.should == "and-one-more"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,26 +1,29 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie.parse" do
|
||||
it "parses a raw cookie string into a hash of Cookies" do
|
||||
expected = { "test-cookie" => ["one", "two", "three"] }
|
||||
CGI::Cookie.parse("test-cookie=one&two&three").should == expected
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
expected = { "second-cookie" => ["three", "four"], "first-cookie" => ["one", "two"] }
|
||||
CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four").should == expected
|
||||
end
|
||||
describe "CGI::Cookie.parse" do
|
||||
it "parses a raw cookie string into a hash of Cookies" do
|
||||
expected = { "test-cookie" => ["one", "two", "three"] }
|
||||
CGI::Cookie.parse("test-cookie=one&two&three").should == expected
|
||||
|
||||
it "does not use , for cookie separators" do
|
||||
expected = {
|
||||
"first-cookie" => ["one", "two"],
|
||||
"second-cookie" => ["three", "four,third_cookie=five", "six"]
|
||||
}
|
||||
CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four,third_cookie=five&six").should == expected
|
||||
end
|
||||
expected = { "second-cookie" => ["three", "four"], "first-cookie" => ["one", "two"] }
|
||||
CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four").should == expected
|
||||
end
|
||||
|
||||
it "unescapes the Cookie values" do
|
||||
cookie = "test-cookie=+%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E"
|
||||
expected = { "test-cookie" => [ " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ] }
|
||||
CGI::Cookie.parse(cookie).should == expected
|
||||
it "does not use , for cookie separators" do
|
||||
expected = {
|
||||
"first-cookie" => ["one", "two"],
|
||||
"second-cookie" => ["three", "four,third_cookie=five", "six"]
|
||||
}
|
||||
CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four,third_cookie=five&six").should == expected
|
||||
end
|
||||
|
||||
it "unescapes the Cookie values" do
|
||||
cookie = "test-cookie=+%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E"
|
||||
expected = { "test-cookie" => [ " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ] }
|
||||
CGI::Cookie.parse(cookie).should == expected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,23 +1,26 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#path" do
|
||||
it "returns self's path" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.path.should == ""
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "path" => "/some/path/")
|
||||
cookie.path.should == "/some/path/"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#path=" do
|
||||
it "sets self's path" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.path = "/some/path/"
|
||||
cookie.path.should == "/some/path/"
|
||||
|
||||
cookie.path = "/another/path/"
|
||||
cookie.path.should == "/another/path/"
|
||||
describe "CGI::Cookie#path" do
|
||||
it "returns self's path" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.path.should == ""
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "path" => "/some/path/")
|
||||
cookie.path.should == "/some/path/"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#path=" do
|
||||
it "sets self's path" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.path = "/some/path/"
|
||||
cookie.path.should == "/some/path/"
|
||||
|
||||
cookie.path = "/another/path/"
|
||||
cookie.path.should == "/another/path/"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,70 +1,73 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#secure" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#secure" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "returns whether self is a secure cookie or not" do
|
||||
@cookie.secure = true
|
||||
@cookie.secure.should be_true
|
||||
|
||||
@cookie.secure = false
|
||||
@cookie.secure.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
it "returns whether self is a secure cookie or not" do
|
||||
@cookie.secure = true
|
||||
@cookie.secure.should be_true
|
||||
describe "CGI::Cookie#secure= when passed true" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
@cookie.secure = false
|
||||
@cookie.secure.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#secure= when passed true" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "returns true" do
|
||||
(@cookie.secure = true).should be_true
|
||||
end
|
||||
|
||||
it "sets self to a secure cookie" do
|
||||
@cookie.secure = true
|
||||
@cookie.secure.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#secure= when passed false" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "returns false" do
|
||||
(@cookie.secure = false).should be_false
|
||||
end
|
||||
|
||||
it "sets self to a non-secure cookie" do
|
||||
@cookie.secure = false
|
||||
@cookie.secure.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#secure= when passed Object" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "does not change self's secure value" do
|
||||
@cookie.secure = false
|
||||
|
||||
@cookie.secure = Object.new
|
||||
@cookie.secure.should be_false
|
||||
|
||||
@cookie.secure = "Test"
|
||||
@cookie.secure.should be_false
|
||||
|
||||
@cookie.secure = true
|
||||
|
||||
@cookie.secure = Object.new
|
||||
@cookie.secure.should be_true
|
||||
|
||||
@cookie.secure = "Test"
|
||||
@cookie.secure.should be_true
|
||||
it "returns true" do
|
||||
(@cookie.secure = true).should be_true
|
||||
end
|
||||
|
||||
it "sets self to a secure cookie" do
|
||||
@cookie.secure = true
|
||||
@cookie.secure.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#secure= when passed false" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "returns false" do
|
||||
(@cookie.secure = false).should be_false
|
||||
end
|
||||
|
||||
it "sets self to a non-secure cookie" do
|
||||
@cookie.secure = false
|
||||
@cookie.secure.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#secure= when passed Object" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "does not change self's secure value" do
|
||||
@cookie.secure = false
|
||||
|
||||
@cookie.secure = Object.new
|
||||
@cookie.secure.should be_false
|
||||
|
||||
@cookie.secure = "Test"
|
||||
@cookie.secure.should be_false
|
||||
|
||||
@cookie.secure = true
|
||||
|
||||
@cookie.secure = Object.new
|
||||
@cookie.secure.should be_true
|
||||
|
||||
@cookie.secure = "Test"
|
||||
@cookie.secure.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,33 +1,36 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#to_s" do
|
||||
it "returns a String representation of self" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.to_s.should == "test-cookie=; path="
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
cookie = CGI::Cookie.new("test-cookie", "value")
|
||||
cookie.to_s.should == "test-cookie=value; path="
|
||||
describe "CGI::Cookie#to_s" do
|
||||
it "returns a String representation of self" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.to_s.should == "test-cookie=; path="
|
||||
|
||||
cookie = CGI::Cookie.new("test-cookie", "one", "two", "three")
|
||||
cookie.to_s.should == "test-cookie=one&two&three; path="
|
||||
cookie = CGI::Cookie.new("test-cookie", "value")
|
||||
cookie.to_s.should == "test-cookie=value; path="
|
||||
|
||||
cookie = CGI::Cookie.new(
|
||||
'name' => 'test-cookie',
|
||||
'value' => ["one", "two", "three"],
|
||||
'path' => 'some/path/',
|
||||
'domain' => 'example.com',
|
||||
'expires' => Time.at(1196524602),
|
||||
'secure' => true)
|
||||
cookie.to_s.should == "test-cookie=one&two&three; domain=example.com; path=some/path/; expires=Sat, 01 Dec 2007 15:56:42 GMT; secure"
|
||||
end
|
||||
cookie = CGI::Cookie.new("test-cookie", "one", "two", "three")
|
||||
cookie.to_s.should == "test-cookie=one&two&three; path="
|
||||
|
||||
it "escapes the self's values" do
|
||||
cookie = CGI::Cookie.new("test-cookie", " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}")
|
||||
cookie.to_s.should == "test-cookie=+%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D; path="
|
||||
end
|
||||
cookie = CGI::Cookie.new(
|
||||
'name' => 'test-cookie',
|
||||
'value' => ["one", "two", "three"],
|
||||
'path' => 'some/path/',
|
||||
'domain' => 'example.com',
|
||||
'expires' => Time.at(1196524602),
|
||||
'secure' => true)
|
||||
cookie.to_s.should == "test-cookie=one&two&three; domain=example.com; path=some/path/; expires=Sat, 01 Dec 2007 15:56:42 GMT; secure"
|
||||
end
|
||||
|
||||
it "does not escape tilde" do
|
||||
cookie = CGI::Cookie.new("test-cookie", "~").to_s.should == "test-cookie=~; path="
|
||||
it "escapes the self's values" do
|
||||
cookie = CGI::Cookie.new("test-cookie", " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}")
|
||||
cookie.to_s.should == "test-cookie=+%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D; path="
|
||||
end
|
||||
|
||||
it "does not escape tilde" do
|
||||
cookie = CGI::Cookie.new("test-cookie", "~").to_s.should == "test-cookie=~; path="
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,76 +1,79 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::Cookie#value" do
|
||||
it "returns self's value" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.value.should == []
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
cookie = CGI::Cookie.new("test-cookie", "one")
|
||||
cookie.value.should == ["one"]
|
||||
describe "CGI::Cookie#value" do
|
||||
it "returns self's value" do
|
||||
cookie = CGI::Cookie.new("test-cookie")
|
||||
cookie.value.should == []
|
||||
|
||||
cookie = CGI::Cookie.new("test-cookie", "one", "two", "three")
|
||||
cookie.value.should == ["one", "two", "three"]
|
||||
cookie = CGI::Cookie.new("test-cookie", "one")
|
||||
cookie.value.should == ["one"]
|
||||
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "value" => ["one", "two", "three"])
|
||||
cookie.value.should == ["one", "two", "three"]
|
||||
end
|
||||
cookie = CGI::Cookie.new("test-cookie", "one", "two", "three")
|
||||
cookie.value.should == ["one", "two", "three"]
|
||||
|
||||
it "is in synch with self" do
|
||||
fail = []
|
||||
[
|
||||
:pop,
|
||||
:shift,
|
||||
[:<<, "Hello"],
|
||||
[:push, "Hello"],
|
||||
[:unshift, "World"],
|
||||
[:replace, ["A", "B"]],
|
||||
[:[]=, 1, "Set"],
|
||||
[:delete, "first"],
|
||||
[:delete_at, 0],
|
||||
].each do |method, *args|
|
||||
cookie1 = CGI::Cookie.new("test-cookie", "first", "second")
|
||||
cookie2 = CGI::Cookie.new("test-cookie", "first", "second")
|
||||
cookie1.send(method, *args)
|
||||
cookie2.value.send(method, *args)
|
||||
fail << method unless cookie1.value == cookie2.value
|
||||
cookie = CGI::Cookie.new("name" => "test-cookie", "value" => ["one", "two", "three"])
|
||||
cookie.value.should == ["one", "two", "three"]
|
||||
end
|
||||
|
||||
it "is in synch with self" do
|
||||
fail = []
|
||||
[
|
||||
:pop,
|
||||
:shift,
|
||||
[:<<, "Hello"],
|
||||
[:push, "Hello"],
|
||||
[:unshift, "World"],
|
||||
[:replace, ["A", "B"]],
|
||||
[:[]=, 1, "Set"],
|
||||
[:delete, "first"],
|
||||
[:delete_at, 0],
|
||||
].each do |method, *args|
|
||||
cookie1 = CGI::Cookie.new("test-cookie", "first", "second")
|
||||
cookie2 = CGI::Cookie.new("test-cookie", "first", "second")
|
||||
cookie1.send(method, *args)
|
||||
cookie2.value.send(method, *args)
|
||||
fail << method unless cookie1.value == cookie2.value
|
||||
end
|
||||
fail.should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#value=" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "sets self's value" do
|
||||
@cookie.value = ["one"]
|
||||
@cookie.value.should == ["one"]
|
||||
|
||||
@cookie.value = ["one", "two", "three"]
|
||||
@cookie.value.should == ["one", "two", "three"]
|
||||
end
|
||||
|
||||
it "automatically converts the passed Object to an Array using #Array" do
|
||||
@cookie.value = "test"
|
||||
@cookie.value.should == ["test"]
|
||||
|
||||
obj = mock("to_a")
|
||||
obj.should_receive(:to_a).and_return(["1", "2"])
|
||||
@cookie.value = obj
|
||||
@cookie.value.should == ["1", "2"]
|
||||
|
||||
obj = mock("to_ary")
|
||||
obj.should_receive(:to_ary).and_return(["1", "2"])
|
||||
@cookie.value = obj
|
||||
@cookie.value.should == ["1", "2"]
|
||||
end
|
||||
|
||||
it "does keep self and the values in sync" do
|
||||
@cookie.value = ["one", "two", "three"]
|
||||
@cookie[0].should == "one"
|
||||
@cookie[1].should == "two"
|
||||
@cookie[2].should == "three"
|
||||
end
|
||||
fail.should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::Cookie#value=" do
|
||||
before :each do
|
||||
@cookie = CGI::Cookie.new("test-cookie")
|
||||
end
|
||||
|
||||
it "sets self's value" do
|
||||
@cookie.value = ["one"]
|
||||
@cookie.value.should == ["one"]
|
||||
|
||||
@cookie.value = ["one", "two", "three"]
|
||||
@cookie.value.should == ["one", "two", "three"]
|
||||
end
|
||||
|
||||
it "automatically converts the passed Object to an Array using #Array" do
|
||||
@cookie.value = "test"
|
||||
@cookie.value.should == ["test"]
|
||||
|
||||
obj = mock("to_a")
|
||||
obj.should_receive(:to_a).and_return(["1", "2"])
|
||||
@cookie.value = obj
|
||||
@cookie.value.should == ["1", "2"]
|
||||
|
||||
obj = mock("to_ary")
|
||||
obj.should_receive(:to_ary).and_return(["1", "2"])
|
||||
@cookie.value = obj
|
||||
@cookie.value.should == ["1", "2"]
|
||||
end
|
||||
|
||||
it "does keep self and the values in sync" do
|
||||
@cookie.value = ["one", "two", "three"]
|
||||
@cookie[0].should == "one"
|
||||
@cookie[1].should == "two"
|
||||
@cookie[2].should == "three"
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,9 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
begin
|
||||
require 'cgi/escape'
|
||||
rescue LoadError
|
||||
require 'cgi'
|
||||
end
|
||||
|
||||
describe "CGI.escapeElement when passed String, elements, ..." do
|
||||
it "escapes only the tags of the passed elements in the passed String" do
|
||||
|
@ -1,5 +1,9 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
begin
|
||||
require 'cgi/escape'
|
||||
rescue LoadError
|
||||
require 'cgi'
|
||||
end
|
||||
|
||||
describe "CGI.escapeHTML" do
|
||||
it "escapes special HTML characters (&\"<>') in the passed argument" do
|
||||
|
@ -1,5 +1,9 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
begin
|
||||
require 'cgi/escape'
|
||||
rescue LoadError
|
||||
require 'cgi'
|
||||
end
|
||||
|
||||
ruby_version_is "3.2" do
|
||||
describe "CGI.escapeURIComponent" do
|
||||
|
@ -1,5 +1,9 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
begin
|
||||
require 'cgi/escape'
|
||||
rescue LoadError
|
||||
require 'cgi'
|
||||
end
|
||||
|
||||
describe "CGI.escape" do
|
||||
it "url-encodes the passed argument" do
|
||||
|
@ -1,49 +1,52 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#a" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed a String" do
|
||||
it "returns an 'a'-element, using the passed String as the 'href'-attribute" do
|
||||
output = @html.a("http://www.example.com")
|
||||
output.should equal_element("A", "HREF" => "http://www.example.com")
|
||||
describe "CGI::HtmlExtension#a" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.a("http://www.example.com") { "Example" }
|
||||
output.should equal_element("A", { "HREF" => "http://www.example.com" }, "Example")
|
||||
end
|
||||
end
|
||||
describe "when passed a String" do
|
||||
it "returns an 'a'-element, using the passed String as the 'href'-attribute" do
|
||||
output = @html.a("http://www.example.com")
|
||||
output.should equal_element("A", "HREF" => "http://www.example.com")
|
||||
end
|
||||
|
||||
describe "when passed a Hash" do
|
||||
it "returns an 'a'-element, using the passed Hash for attributes" do
|
||||
attributes = {"HREF" => "http://www.example.com", "TARGET" => "_top"}
|
||||
@html.a(attributes).should equal_element("A", attributes)
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.a("http://www.example.com") { "Example" }
|
||||
output.should equal_element("A", { "HREF" => "http://www.example.com" }, "Example")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
attributes = {"HREF" => "http://www.example.com", "TARGET" => "_top"}
|
||||
@html.a(attributes) { "Example" }.should equal_element("A", attributes, "Example")
|
||||
end
|
||||
end
|
||||
describe "when passed a Hash" do
|
||||
it "returns an 'a'-element, using the passed Hash for attributes" do
|
||||
attributes = {"HREF" => "http://www.example.com", "TARGET" => "_top"}
|
||||
@html.a(attributes).should equal_element("A", attributes)
|
||||
end
|
||||
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
CGISpecs.cgi_new("html3").a.should == %(<A HREF=""></A>)
|
||||
CGISpecs.cgi_new("html3").a { "link text" }.should == %(<A HREF="">link text</A>)
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
attributes = {"HREF" => "http://www.example.com", "TARGET" => "_top"}
|
||||
@html.a(attributes) { "Example" }.should equal_element("A", attributes, "Example")
|
||||
end
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
CGISpecs.cgi_new("html4").a.should == %(<A HREF=""></A>)
|
||||
CGISpecs.cgi_new("html4").a { "link text" }.should == %(<A HREF="">link text</A>)
|
||||
end
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
CGISpecs.cgi_new("html4Tr").a.should == %(<A HREF=""></A>)
|
||||
CGISpecs.cgi_new("html4Tr").a { "link text" }.should == %(<A HREF="">link text</A>)
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
CGISpecs.cgi_new("html3").a.should == %(<A HREF=""></A>)
|
||||
CGISpecs.cgi_new("html3").a { "link text" }.should == %(<A HREF="">link text</A>)
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
CGISpecs.cgi_new("html4").a.should == %(<A HREF=""></A>)
|
||||
CGISpecs.cgi_new("html4").a { "link text" }.should == %(<A HREF="">link text</A>)
|
||||
end
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
CGISpecs.cgi_new("html4Tr").a.should == %(<A HREF=""></A>)
|
||||
CGISpecs.cgi_new("html4Tr").a { "link text" }.should == %(<A HREF="">link text</A>)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,33 +1,36 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#base" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when bassed a String" do
|
||||
it "returns a 'base'-element, using the passed String as the 'href'-attribute" do
|
||||
output = @html.base("http://www.example.com")
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com"}, nil, not_closed: true)
|
||||
describe "CGI::HtmlExtension#base" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.base("http://www.example.com") { "Example" }
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com"}, nil, not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when bassed a String" do
|
||||
it "returns a 'base'-element, using the passed String as the 'href'-attribute" do
|
||||
output = @html.base("http://www.example.com")
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com"}, nil, not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed a Hash" do
|
||||
it "returns a 'base'-element, using the passed Hash for attributes" do
|
||||
output = @html.base("HREF" => "http://www.example.com", "ID" => "test")
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com", "ID" => "test"}, nil, not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.base("http://www.example.com") { "Example" }
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com"}, nil, not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.base("HREF" => "http://www.example.com", "ID" => "test") { "Example" }
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com", "ID" => "test"}, nil, not_closed: true)
|
||||
describe "when passed a Hash" do
|
||||
it "returns a 'base'-element, using the passed Hash for attributes" do
|
||||
output = @html.base("HREF" => "http://www.example.com", "ID" => "test")
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com", "ID" => "test"}, nil, not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.base("HREF" => "http://www.example.com", "ID" => "test") { "Example" }
|
||||
output.should equal_element("BASE", {"HREF" => "http://www.example.com", "ID" => "test"}, nil, not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,33 +1,36 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#blockquote" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed a String" do
|
||||
it "returns a 'blockquote'-element, using the passed String for the 'cite'-attribute" do
|
||||
output = @html.blockquote("http://www.example.com/quotes/foo.html")
|
||||
output.should equal_element("BLOCKQUOTE", "CITE" => "http://www.example.com/quotes/foo.html")
|
||||
describe "CGI::HtmlExtension#blockquote" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.blockquote("http://www.example.com/quotes/foo.html") { "Foo!" }
|
||||
output.should equal_element("BLOCKQUOTE", { "CITE" => "http://www.example.com/quotes/foo.html" }, "Foo!")
|
||||
end
|
||||
end
|
||||
describe "when passed a String" do
|
||||
it "returns a 'blockquote'-element, using the passed String for the 'cite'-attribute" do
|
||||
output = @html.blockquote("http://www.example.com/quotes/foo.html")
|
||||
output.should equal_element("BLOCKQUOTE", "CITE" => "http://www.example.com/quotes/foo.html")
|
||||
end
|
||||
|
||||
describe "when passed a Hash" do
|
||||
it "returns a 'blockquote'-element, using the passed Hash for attributes" do
|
||||
output = @html.blockquote("CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test")
|
||||
output.should equal_element("BLOCKQUOTE", "CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test")
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.blockquote("http://www.example.com/quotes/foo.html") { "Foo!" }
|
||||
output.should equal_element("BLOCKQUOTE", { "CITE" => "http://www.example.com/quotes/foo.html" }, "Foo!")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.blockquote("CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test") { "Foo!" }
|
||||
output.should equal_element("BLOCKQUOTE", {"CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test"}, "Foo!")
|
||||
describe "when passed a Hash" do
|
||||
it "returns a 'blockquote'-element, using the passed Hash for attributes" do
|
||||
output = @html.blockquote("CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test")
|
||||
output.should equal_element("BLOCKQUOTE", "CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test")
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.blockquote("CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test") { "Foo!" }
|
||||
output.should equal_element("BLOCKQUOTE", {"CITE" => "http://www.example.com/quotes/foo.html", "ID" => "test"}, "Foo!")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#br" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
CGISpecs.cgi_new("html3").br.should == "<BR>"
|
||||
describe "CGI::HtmlExtension#br" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
CGISpecs.cgi_new("html4").br.should == "<BR>"
|
||||
end
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
CGISpecs.cgi_new("html4Tr").br.should == "<BR>"
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
CGISpecs.cgi_new("html3").br.should == "<BR>"
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
CGISpecs.cgi_new("html4").br.should == "<BR>"
|
||||
end
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
CGISpecs.cgi_new("html4Tr").br.should == "<BR>"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,33 +1,36 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#caption" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed a String" do
|
||||
it "returns a 'caption'-element, using the passed String for the 'align'-attribute" do
|
||||
output = @html.caption("left")
|
||||
output.should equal_element("CAPTION", "ALIGN" => "left")
|
||||
describe "CGI::HtmlExtension#caption" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.caption("left") { "Capital Cities" }
|
||||
output.should equal_element("CAPTION", {"ALIGN" => "left"}, "Capital Cities")
|
||||
end
|
||||
end
|
||||
describe "when passed a String" do
|
||||
it "returns a 'caption'-element, using the passed String for the 'align'-attribute" do
|
||||
output = @html.caption("left")
|
||||
output.should equal_element("CAPTION", "ALIGN" => "left")
|
||||
end
|
||||
|
||||
describe "when passed a Hash" do
|
||||
it "returns a 'caption'-element, using the passed Hash for attributes" do
|
||||
output = @html.caption("ALIGN" => "left", "ID" => "test")
|
||||
output.should equal_element("CAPTION", "ALIGN" => "left", "ID" => "test")
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.caption("left") { "Capital Cities" }
|
||||
output.should equal_element("CAPTION", {"ALIGN" => "left"}, "Capital Cities")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.caption("ALIGN" => "left", "ID" => "test") { "Capital Cities" }
|
||||
output.should equal_element("CAPTION", {"ALIGN" => "left", "ID" => "test"}, "Capital Cities")
|
||||
describe "when passed a Hash" do
|
||||
it "returns a 'caption'-element, using the passed Hash for attributes" do
|
||||
output = @html.caption("ALIGN" => "left", "ID" => "test")
|
||||
output.should equal_element("CAPTION", "ALIGN" => "left", "ID" => "test")
|
||||
end
|
||||
|
||||
it "includes the passed block's return value when passed a block" do
|
||||
output = @html.caption("ALIGN" => "left", "ID" => "test") { "Capital Cities" }
|
||||
output.should equal_element("CAPTION", {"ALIGN" => "left", "ID" => "test"}, "Capital Cities")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,76 +1,79 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#checkbox_group" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed name, values ..." do
|
||||
it "returns a sequence of 'checkbox'-elements with the passed name and the passed values" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", "foo", "bar", "baz"))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
describe "CGI::HtmlExtension#checkbox_group" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "allows passing a value inside an Array" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", ["foo"], "bar", ["baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
describe "when passed name, values ..." do
|
||||
it "returns a sequence of 'checkbox'-elements with the passed name and the passed values" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", "foo", "bar", "baz"))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "allows passing a value inside an Array" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", ["foo"], "bar", ["baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "allows passing a value as an Array containing the value and the checked state or a label" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", ["foo"], ["bar", true], ["baz", "label for baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "allows passing a value as an Array containing the value, a label and the checked state" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", ["foo", "label for foo", true], ["bar", "label for bar", false], ["baz", "label for baz", true]))
|
||||
output[0].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "label for foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "label for bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "returns an empty String when passed no values" do
|
||||
@html.checkbox_group("test").should == ""
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", "foo", "bar", "baz") { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "allows passing a value as an Array containing the value and the checked state or a label" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", ["foo"], ["bar", true], ["baz", "label for baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
describe "when passed Hash" do
|
||||
it "uses the passed Hash to generate the checkbox sequence" do
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
it "allows passing a value as an Array containing the value, a label and the checked state" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", ["foo", "label for foo", true], ["bar", "label for bar", false], ["baz", "label for baz", true]))
|
||||
output[0].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "label for foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "label for bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => [["foo"], ["bar", true], "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
it "returns an empty String when passed no values" do
|
||||
@html.checkbox_group("test").should == ""
|
||||
end
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "1"}, "Foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "checkbox", "VALUE" => "2"}, "Bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "Baz"}, "Baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.checkbox_group("test", "foo", "bar", "baz") { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "uses the passed Hash to generate the checkbox sequence" do
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => [["foo"], ["bar", true], "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "1"}, "Foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "checkbox", "VALUE" => "2"}, "Bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "Baz"}, "Baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]) { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.checkbox_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]) { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "checkbox", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,77 +1,80 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#checkbox" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a checkbox-'input'-element without a name" do
|
||||
output = @html.checkbox
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#checkbox" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a checkbox-'input'-element without a name" do
|
||||
output = @html.checkbox
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name" do
|
||||
it "returns a checkbox-'input'-element with the passed name" do
|
||||
output = @html.checkbox("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name" do
|
||||
it "returns a checkbox-'input'-element with the passed name" do
|
||||
output = @html.checkbox("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "CGI::HtmlExtension#checkbox when passed name, value" do
|
||||
it "returns a checkbox-'input'-element with the passed name and value" do
|
||||
output = @html.checkbox("test", "test-value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox("test", "test-value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "CGI::HtmlExtension#checkbox when passed name, value" do
|
||||
it "returns a checkbox-'input'-element with the passed name and value" do
|
||||
output = @html.checkbox("test", "test-value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value, checked" do
|
||||
it "returns a checked checkbox-'input'-element with the passed name and value when checked is true" do
|
||||
output = @html.checkbox("test", "test-value", true)
|
||||
output.should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
output = @html.checkbox("test", "test-value", false)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
output = @html.checkbox("test", "test-value", nil)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox("test", "test-value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox("test", "test-value", nil) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value, checked" do
|
||||
it "returns a checked checkbox-'input'-element with the passed name and value when checked is true" do
|
||||
output = @html.checkbox("test", "test-value", true)
|
||||
output.should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.checkbox(attributes)
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
output = @html.checkbox("test", "test-value", false)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
output = @html.checkbox("test", "test-value", nil)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.checkbox("test", "test-value", nil) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "checkbox", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.checkbox(attributes) { "test" }
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.checkbox(attributes)
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.checkbox(attributes) { "test" }
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,27 +1,30 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#doctype" do
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
|
||||
CGISpecs.cgi_new("html3").doctype.should == expect
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
|
||||
CGISpecs.cgi_new("html4").doctype.should == expect
|
||||
end
|
||||
describe "CGI::HtmlExtension#doctype" do
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
|
||||
CGISpecs.cgi_new("html3").doctype.should == expect
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for the Frameset version of HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
|
||||
CGISpecs.cgi_new("html4Fr").doctype.should == expect
|
||||
end
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
|
||||
CGISpecs.cgi_new("html4").doctype.should == expect
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
|
||||
CGISpecs.cgi_new("html4Tr").doctype.should == expect
|
||||
it "returns the doctype declaration for the Frameset version of HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
|
||||
CGISpecs.cgi_new("html4Fr").doctype.should == expect
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
|
||||
CGISpecs.cgi_new("html4Tr").doctype.should == expect
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,72 +1,75 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#file_field" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a file-'input'-element without a name and a size of 20" do
|
||||
output = @html.file_field
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "", "TYPE" => "file"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#file_field" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a file-'input'-element without a name and a size of 20" do
|
||||
output = @html.file_field
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name" do
|
||||
it "returns a checkbox-'input'-element with the passed name" do
|
||||
output = @html.file_field("Example")
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name" do
|
||||
it "returns a checkbox-'input'-element with the passed name" do
|
||||
output = @html.file_field("Example")
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, size" do
|
||||
it "returns a checkbox-'input'-element with the passed name and size" do
|
||||
output = @html.file_field("Example", 40)
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 20, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("Example", 40) { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, size" do
|
||||
it "returns a checkbox-'input'-element with the passed name and size" do
|
||||
output = @html.file_field("Example", 40)
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, size, maxlength" do
|
||||
it "returns a checkbox-'input'-element with the passed name, size and maxlength" do
|
||||
output = @html.file_field("Example", 40, 100)
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file", "MAXLENGTH" => 100}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("Example", 40) { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("Example", 40, 100) { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file", "MAXLENGTH" => 100}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, size, maxlength" do
|
||||
it "returns a checkbox-'input'-element with the passed name, size and maxlength" do
|
||||
output = @html.file_field("Example", 40, 100)
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file", "MAXLENGTH" => 100}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed a Hash" do
|
||||
it "returns a file-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.file_field("NAME" => "test", "SIZE" => 40)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "SIZE" => 40}, "", not_closed: true)
|
||||
|
||||
output = @html.file_field("NAME" => "test", "MAXLENGTH" => 100)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "MAXLENGTH" => 100}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("Example", 40, 100) { "test" }
|
||||
output.should equal_element("INPUT", {"SIZE" => 40, "NAME" => "Example", "TYPE" => "file", "MAXLENGTH" => 100}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("NAME" => "test", "SIZE" => 40) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "SIZE" => 40}, "", not_closed: true)
|
||||
describe "when passed a Hash" do
|
||||
it "returns a file-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.file_field("NAME" => "test", "SIZE" => 40)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "SIZE" => 40}, "", not_closed: true)
|
||||
|
||||
output = @html.file_field("NAME" => "test", "MAXLENGTH" => 100)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "MAXLENGTH" => 100}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.file_field("NAME" => "test", "SIZE" => 40) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "SIZE" => 40}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,58 +1,61 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#form" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
@html.stub!(:script_name).and_return("/path/to/some/script")
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a 'form'-element" do
|
||||
output = @html.form
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/path/to/some/script"}, "")
|
||||
describe "CGI::HtmlExtension#form" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
@html.stub!(:script_name).and_return("/path/to/some/script")
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/path/to/some/script"}, "test")
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a 'form'-element" do
|
||||
output = @html.form
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/path/to/some/script"}, "")
|
||||
end
|
||||
|
||||
describe "when passed method" do
|
||||
it "returns a 'form'-element with the passed method" do
|
||||
output = @html.form("get")
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/path/to/some/script"}, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/path/to/some/script"}, "test")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form("get") { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/path/to/some/script"}, "test")
|
||||
end
|
||||
end
|
||||
describe "when passed method" do
|
||||
it "returns a 'form'-element with the passed method" do
|
||||
output = @html.form("get")
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/path/to/some/script"}, "")
|
||||
end
|
||||
|
||||
describe "when passed method, action" do
|
||||
it "returns a 'form'-element with the passed method and the passed action" do
|
||||
output = @html.form("get", "/some/other/script")
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/some/other/script"}, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form("get") { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/path/to/some/script"}, "test")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form("get", "/some/other/script") { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/some/other/script"}, "test")
|
||||
end
|
||||
end
|
||||
describe "when passed method, action" do
|
||||
it "returns a 'form'-element with the passed method and the passed action" do
|
||||
output = @html.form("get", "/some/other/script")
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/some/other/script"}, "")
|
||||
end
|
||||
|
||||
describe "when passed method, action, enctype" do
|
||||
it "returns a 'form'-element with the passed method, action and enctype" do
|
||||
output = @html.form("get", "/some/other/script", "multipart/form-data")
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "multipart/form-data", "METHOD" => "get", "ACTION" => "/some/other/script"}, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form("get", "/some/other/script") { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ACTION" => "/some/other/script"}, "test")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form("get", "/some/other/script", "multipart/form-data") { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "multipart/form-data", "METHOD" => "get", "ACTION" => "/some/other/script"}, "test")
|
||||
describe "when passed method, action, enctype" do
|
||||
it "returns a 'form'-element with the passed method, action and enctype" do
|
||||
output = @html.form("get", "/some/other/script", "multipart/form-data")
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "multipart/form-data", "METHOD" => "get", "ACTION" => "/some/other/script"}, "")
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.form("get", "/some/other/script", "multipart/form-data") { "test" }
|
||||
output.should equal_element("FORM", {"ENCTYPE" => "multipart/form-data", "METHOD" => "get", "ACTION" => "/some/other/script"}, "test")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,14 +1,17 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require_relative 'fixtures/common'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::HtmlExtension#frame" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new("html4Fr")
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require_relative 'fixtures/common'
|
||||
require 'cgi'
|
||||
|
||||
it "initializes the HTML Generation methods for the Frameset version of HTML4" do
|
||||
@html.frameset.should == "<FRAMESET></FRAMESET>"
|
||||
@html.frameset { "link text" }.should == "<FRAMESET>link text</FRAMESET>"
|
||||
describe "CGI::HtmlExtension#frame" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new("html4Fr")
|
||||
end
|
||||
|
||||
it "initializes the HTML Generation methods for the Frameset version of HTML4" do
|
||||
@html.frameset.should == "<FRAMESET></FRAMESET>"
|
||||
@html.frameset { "link text" }.should == "<FRAMESET>link text</FRAMESET>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,14 +1,17 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require_relative 'fixtures/common'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::HtmlExtension#frameset" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new("html4Fr")
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require_relative 'fixtures/common'
|
||||
require 'cgi'
|
||||
|
||||
it "initializes the HTML Generation methods for the Frameset version of HTML4" do
|
||||
@html.frameset.should == "<FRAMESET></FRAMESET>"
|
||||
@html.frameset { "link text" }.should == "<FRAMESET>link text</FRAMESET>"
|
||||
describe "CGI::HtmlExtension#frameset" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new("html4Fr")
|
||||
end
|
||||
|
||||
it "initializes the HTML Generation methods for the Frameset version of HTML4" do
|
||||
@html.frameset.should == "<FRAMESET></FRAMESET>"
|
||||
@html.frameset { "link text" }.should == "<FRAMESET>link text</FRAMESET>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,59 +1,62 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#hidden" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns an hidden-'input'-element without a name" do
|
||||
output = @html.hidden
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#hidden" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.hidden { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns an hidden-'input'-element without a name" do
|
||||
output = @html.hidden
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name" do
|
||||
it "returns an hidden-'input'-element with the passed name" do
|
||||
output = @html.hidden("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.hidden { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.hidden("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name" do
|
||||
it "returns an hidden-'input'-element with the passed name" do
|
||||
output = @html.hidden("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value" do
|
||||
it "returns an hidden-'input'-element with the passed name and value" do
|
||||
output = @html.hidden("test", "some value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden", "VALUE" => "some value"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.hidden("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.hidden("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden", "VALUE" => "some value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value" do
|
||||
it "returns an hidden-'input'-element with the passed name and value" do
|
||||
output = @html.hidden("test", "some value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden", "VALUE" => "some value"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
attributes = { "NAME" => "test", "VALUE" => "some value" }
|
||||
output = @html.hidden("test", "some value")
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.hidden("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "hidden", "VALUE" => "some value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = { "NAME" => "test", "VALUE" => "some value" }
|
||||
output = @html.hidden("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
attributes = { "NAME" => "test", "VALUE" => "some value" }
|
||||
output = @html.hidden("test", "some value")
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = { "NAME" => "test", "VALUE" => "some value" }
|
||||
output = @html.hidden("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,66 +1,69 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#html" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
@html.stub!(:doctype).and_return("<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE>")
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a self's doctype and an 'html'-element" do
|
||||
expected = '<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE><HTML>'
|
||||
@html.html.should == expected
|
||||
describe "CGI::HtmlExtension#html" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
@html.stub!(:doctype).and_return("<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE>")
|
||||
end
|
||||
|
||||
it "includes the passed block when passed a block" do
|
||||
expected = '<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE><HTML>test</HTML>'
|
||||
@html.html { "test" }.should == expected
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a self's doctype and an 'html'-element" do
|
||||
expected = '<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE><HTML>'
|
||||
@html.html.should == expected
|
||||
end
|
||||
|
||||
describe "when passed 'PRETTY'" do
|
||||
it "returns pretty output when the passed String is 'PRETTY" do
|
||||
expected = "<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE>\n<HTML>\n"
|
||||
@html.html("PRETTY").should == expected
|
||||
it "includes the passed block when passed a block" do
|
||||
expected = '<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE><HTML>test</HTML>'
|
||||
@html.html { "test" }.should == expected
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the passed block when passed a block" do
|
||||
expected = "<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE>\n<HTML>\n test\n</HTML>\n"
|
||||
@html.html("PRETTY") { "test" }.should == expected
|
||||
end
|
||||
end
|
||||
describe "when passed 'PRETTY'" do
|
||||
it "returns pretty output when the passed String is 'PRETTY" do
|
||||
expected = "<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE>\n<HTML>\n"
|
||||
@html.html("PRETTY").should == expected
|
||||
end
|
||||
|
||||
describe "when passed a Hash" do
|
||||
it "returns an 'html'-element using the passed Hash for attributes" do
|
||||
expected = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML BLA="TEST">'
|
||||
@html.html("DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', "BLA" => "TEST").should == expected
|
||||
it "includes the passed block when passed a block" do
|
||||
expected = "<!DOCTYPE SUPA-FUNKAY-RUBYSPEC-DOCTYPE>\n<HTML>\n test\n</HTML>\n"
|
||||
@html.html("PRETTY") { "test" }.should == expected
|
||||
end
|
||||
end
|
||||
|
||||
it "omits the doctype when the Hash contains a 'DOCTYPE' entry that's false or nil" do
|
||||
@html.html("DOCTYPE" => false).should == "<HTML>"
|
||||
@html.html("DOCTYPE" => nil).should == "<HTML>"
|
||||
end
|
||||
end
|
||||
describe "when passed a Hash" do
|
||||
it "returns an 'html'-element using the passed Hash for attributes" do
|
||||
expected = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML BLA="TEST">'
|
||||
@html.html("DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', "BLA" => "TEST").should == expected
|
||||
end
|
||||
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
|
||||
CGISpecs.cgi_new("html3").html.should == expect + "<HTML>"
|
||||
CGISpecs.cgi_new("html3").html { "html body" }.should == expect + "<HTML>html body</HTML>"
|
||||
it "omits the doctype when the Hash contains a 'DOCTYPE' entry that's false or nil" do
|
||||
@html.html("DOCTYPE" => false).should == "<HTML>"
|
||||
@html.html("DOCTYPE" => nil).should == "<HTML>"
|
||||
end
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
|
||||
CGISpecs.cgi_new("html4").html.should == expect + "<HTML>"
|
||||
CGISpecs.cgi_new("html4").html { "html body" }.should == expect + "<HTML>html body</HTML>"
|
||||
end
|
||||
describe "when each HTML generation" do
|
||||
it "returns the doctype declaration for HTML3" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
|
||||
CGISpecs.cgi_new("html3").html.should == expect + "<HTML>"
|
||||
CGISpecs.cgi_new("html3").html { "html body" }.should == expect + "<HTML>html body</HTML>"
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
|
||||
CGISpecs.cgi_new("html4Tr").html.should == expect + "<HTML>"
|
||||
CGISpecs.cgi_new("html4Tr").html { "html body" }.should == expect + "<HTML>html body</HTML>"
|
||||
it "returns the doctype declaration for HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
|
||||
CGISpecs.cgi_new("html4").html.should == expect + "<HTML>"
|
||||
CGISpecs.cgi_new("html4").html { "html body" }.should == expect + "<HTML>html body</HTML>"
|
||||
end
|
||||
|
||||
it "returns the doctype declaration for the Transitional version of HTML4" do
|
||||
expect = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
|
||||
CGISpecs.cgi_new("html4Tr").html.should == expect + "<HTML>"
|
||||
CGISpecs.cgi_new("html4Tr").html { "html body" }.should == expect + "<HTML>html body</HTML>"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,69 +1,72 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#image_button" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns an image-'input'-element without a source image" do
|
||||
output = @html.image_button
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#image_button" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns an image-'input'-element without a source image" do
|
||||
output = @html.image_button
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed src" do
|
||||
it "returns an image-'input'-element with the passed src" do
|
||||
output = @html.image_button("/path/to/image.png")
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("/path/to/image.png") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed src" do
|
||||
it "returns an image-'input'-element with the passed src" do
|
||||
output = @html.image_button("/path/to/image.png")
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed src, name" do
|
||||
it "returns an image-'input'-element with the passed src and name" do
|
||||
output = @html.image_button("/path/to/image.png", "test")
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("/path/to/image.png") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("/path/to/image.png", "test") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed src, name" do
|
||||
it "returns an image-'input'-element with the passed src and name" do
|
||||
output = @html.image_button("/path/to/image.png", "test")
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed src, name, alt" do
|
||||
it "returns an image-'input'-element with the passed src, name and alt" do
|
||||
output = @html.image_button("/path/to/image.png", "test", "alternative")
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test", "ALT" => "alternative"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("/path/to/image.png", "test") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("/path/to/image.png", "test", "alternative") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test", "ALT" => "alternative"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed src, name, alt" do
|
||||
it "returns an image-'input'-element with the passed src, name and alt" do
|
||||
output = @html.image_button("/path/to/image.png", "test", "alternative")
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test", "ALT" => "alternative"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a image-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.image_button("NAME" => "test", "VALUE" => "test-value")
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image", "NAME" => "test", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("/path/to/image.png", "test", "alternative") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "/path/to/image.png", "TYPE" => "image", "NAME" => "test", "ALT" => "alternative"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("NAME" => "test", "VALUE" => "test-value") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image", "NAME" => "test", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a image-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.image_button("NAME" => "test", "VALUE" => "test-value")
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image", "NAME" => "test", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.image_button("NAME" => "test", "VALUE" => "test-value") { "test" }
|
||||
output.should equal_element("INPUT", {"SRC" => "", "TYPE" => "image", "NAME" => "test", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,83 +1,86 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#img" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns an 'img'-element without an src-url or alt-text" do
|
||||
output = @html.img
|
||||
output.should equal_element("IMG", { "SRC" => "", "ALT" => "" }, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#img" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.img { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns an 'img'-element without an src-url or alt-text" do
|
||||
output = @html.img
|
||||
output.should equal_element("IMG", { "SRC" => "", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed src" do
|
||||
it "returns an 'img'-element with the passed src-url" do
|
||||
output = @html.img("/path/to/some/image.png")
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "" }, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.img { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.img("/path/to/some/image.png")
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed src" do
|
||||
it "returns an 'img'-element with the passed src-url" do
|
||||
output = @html.img("/path/to/some/image.png")
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed src, alt" do
|
||||
it "returns an 'img'-element with the passed src-url and the passed alt-text" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative")
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative" }, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.img("/path/to/some/image.png")
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative") { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed src, alt" do
|
||||
it "returns an 'img'-element with the passed src-url and the passed alt-text" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative")
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative" }, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed src, alt, width" do
|
||||
it "returns an 'img'-element with the passed src-url, the passed alt-text and the passed width" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative", 40)
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative", "WIDTH" => "40" }, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative") { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative", 40) { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative", "WIDTH" => "40" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed src, alt, width" do
|
||||
it "returns an 'img'-element with the passed src-url, the passed alt-text and the passed width" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative", 40)
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative", "WIDTH" => "40" }, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed src, alt, width, height" do
|
||||
it "returns an 'img'-element with the passed src-url, the passed alt-text, the passed width and the passed height" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative", 40, 60)
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative", "WIDTH" => "40", "HEIGHT" => "60" }, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative", 40) { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative", "WIDTH" => "40" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.img { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed src, alt, width, height" do
|
||||
it "returns an 'img'-element with the passed src-url, the passed alt-text, the passed width and the passed height" do
|
||||
output = @html.img("/path/to/some/image.png", "Alternative", 40, 60)
|
||||
output.should equal_element("IMG", { "SRC" => "/path/to/some/image.png", "ALT" => "Alternative", "WIDTH" => "40", "HEIGHT" => "60" }, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns an 'img'-element with the passed Hash as attributes" do
|
||||
attributes = { "SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50 }
|
||||
output = @html.img(attributes)
|
||||
output.should equal_element("IMG", attributes, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.img { "test" }
|
||||
output.should equal_element("IMG", { "SRC" => "", "ALT" => "" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = { "SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50 }
|
||||
output = @html.img(attributes) { "test" }
|
||||
output.should equal_element("IMG", attributes, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns an 'img'-element with the passed Hash as attributes" do
|
||||
attributes = { "SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50 }
|
||||
output = @html.img(attributes)
|
||||
output.should equal_element("IMG", attributes, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = { "SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50 }
|
||||
output = @html.img(attributes) { "test" }
|
||||
output.should equal_element("IMG", attributes, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,64 +1,67 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#multipart_form" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
@html.stub!(:script_name).and_return("/path/to/some/script.rb")
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a 'form'-element with it's enctype set to multipart" do
|
||||
output = @html.multipart_form
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post" }, "")
|
||||
describe "CGI::HtmlExtension#multipart_form" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
@html.stub!(:script_name).and_return("/path/to/some/script.rb")
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post" }, "test")
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a 'form'-element with it's enctype set to multipart" do
|
||||
output = @html.multipart_form
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post" }, "")
|
||||
end
|
||||
|
||||
describe "when passed action" do
|
||||
it "returns a 'form'-element with the passed action" do
|
||||
output = @html.multipart_form("/some/other/script.rb")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post" }, "test")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form("/some/other/script.rb") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "test")
|
||||
end
|
||||
end
|
||||
describe "when passed action" do
|
||||
it "returns a 'form'-element with the passed action" do
|
||||
output = @html.multipart_form("/some/other/script.rb")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "")
|
||||
end
|
||||
|
||||
describe "when passed action, enctype" do
|
||||
it "returns a 'form'-element with the passed action and enctype" do
|
||||
output = @html.multipart_form("/some/other/script.rb", "application/x-www-form-urlencoded")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form("/some/other/script.rb") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "test")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form("/some/other/script.rb", "application/x-www-form-urlencoded") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "test")
|
||||
end
|
||||
end
|
||||
describe "when passed action, enctype" do
|
||||
it "returns a 'form'-element with the passed action and enctype" do
|
||||
output = @html.multipart_form("/some/other/script.rb", "application/x-www-form-urlencoded")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "")
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a 'form'-element with the passed Hash as attributes" do
|
||||
output = @html.multipart_form("ID" => "test")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ID" => "test" }, "")
|
||||
|
||||
output = @html.multipart_form("ID" => "test", "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ID" => "test" }, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form("/some/other/script.rb", "application/x-www-form-urlencoded") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "post", "ACTION" => "/some/other/script.rb" }, "test")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form("ID" => "test") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ID" => "test" }, "test")
|
||||
describe "when passed Hash" do
|
||||
it "returns a 'form'-element with the passed Hash as attributes" do
|
||||
output = @html.multipart_form("ID" => "test")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ID" => "test" }, "")
|
||||
|
||||
output = @html.multipart_form("ID" => "test", "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ID" => "test" }, "test")
|
||||
output = @html.multipart_form("ID" => "test", "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get")
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ID" => "test" }, "")
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.multipart_form("ID" => "test") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "multipart/form-data", "METHOD" => "post", "ID" => "test" }, "test")
|
||||
|
||||
output = @html.multipart_form("ID" => "test", "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get") { "test" }
|
||||
output.should equal_element("FORM", { "ENCTYPE" => "application/x-www-form-urlencoded", "METHOD" => "get", "ID" => "test" }, "test")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,84 +1,87 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#password_field" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns an password-'input'-element without a name" do
|
||||
output = @html.password_field
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#password_field" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns an password-'input'-element without a name" do
|
||||
output = @html.password_field
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name" do
|
||||
it "returns an password-'input'-element with the passed name" do
|
||||
output = @html.password_field("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name" do
|
||||
it "returns an password-'input'-element with the passed name" do
|
||||
output = @html.password_field("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value" do
|
||||
it "returns an password-'input'-element with the passed name and value" do
|
||||
output = @html.password_field("test", "some value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value" do
|
||||
it "returns an password-'input'-element with the passed name and value" do
|
||||
output = @html.password_field("test", "some value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value, size" do
|
||||
it "returns an password-'input'-element with the passed name, value and size" do
|
||||
output = @html.password_field("test", "some value", 60)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test", "some value", 60) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value, size" do
|
||||
it "returns an password-'input'-element with the passed name, value and size" do
|
||||
output = @html.password_field("test", "some value", 60)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value, size, maxlength" do
|
||||
it "returns an password-'input'-element with the passed name, value, size and maxlength" do
|
||||
output = @html.password_field("test", "some value", 60, 12)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test", "some value", 60) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test", "some value", 60, 12) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value, size, maxlength" do
|
||||
it "returns an password-'input'-element with the passed name, value, size and maxlength" do
|
||||
output = @html.password_field("test", "some value", 60, 12)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.password_field("NAME" => "test", "VALUE" => "some value")
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "password" }, "", not_closed: true)
|
||||
|
||||
output = @html.password_field("TYPE" => "hidden")
|
||||
output.should equal_element("INPUT", {"TYPE" => "password"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("test", "some value", 60, 12) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("NAME" => "test", "VALUE" => "some value") { "test" }
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "password" }, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.password_field("NAME" => "test", "VALUE" => "some value")
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "password" }, "", not_closed: true)
|
||||
|
||||
output = @html.password_field("TYPE" => "hidden")
|
||||
output.should equal_element("INPUT", {"TYPE" => "password"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.password_field("NAME" => "test", "VALUE" => "some value") { "test" }
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "password" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,11 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
require_relative 'shared/popup_menu'
|
||||
|
||||
describe "CGI::HtmlExtension#popup_menu" do
|
||||
it_behaves_like :cgi_htmlextension_popup_menu, :popup_menu
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
require_relative 'shared/popup_menu'
|
||||
|
||||
describe "CGI::HtmlExtension#popup_menu" do
|
||||
it_behaves_like :cgi_htmlextension_popup_menu, :popup_menu
|
||||
end
|
||||
end
|
||||
|
@ -1,77 +1,80 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#radio_button" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a radio-'input'-element without a name" do
|
||||
output = @html.radio_button
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "radio"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#radio_button" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "radio"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a radio-'input'-element without a name" do
|
||||
output = @html.radio_button
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "radio"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name" do
|
||||
it "returns a radio-'input'-element with the passed name" do
|
||||
output = @html.radio_button("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "radio"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name" do
|
||||
it "returns a radio-'input'-element with the passed name" do
|
||||
output = @html.radio_button("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "CGI::HtmlExtension#checkbox when passed name, value" do
|
||||
it "returns a radio-'input'-element with the passed name and value" do
|
||||
output = @html.radio_button("test", "test-value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button("test", "test-value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "CGI::HtmlExtension#checkbox when passed name, value" do
|
||||
it "returns a radio-'input'-element with the passed name and value" do
|
||||
output = @html.radio_button("test", "test-value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value, checked" do
|
||||
it "returns a checked radio-'input'-element with the passed name and value when checked is true" do
|
||||
output = @html.radio_button("test", "test-value", true)
|
||||
output.should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
output = @html.radio_button("test", "test-value", false)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
output = @html.radio_button("test", "test-value", nil)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button("test", "test-value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button("test", "test-value", nil) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value, checked" do
|
||||
it "returns a checked radio-'input'-element with the passed name and value when checked is true" do
|
||||
output = @html.radio_button("test", "test-value", true)
|
||||
output.should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a radio-'input'-element using the passed Hash for attributes" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.radio_button(attributes)
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
output = @html.radio_button("test", "test-value", false)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
|
||||
output = @html.radio_button("test", "test-value", nil)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.radio_button("test", "test-value", nil) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.radio_button(attributes) { "test" }
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a radio-'input'-element using the passed Hash for attributes" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.radio_button(attributes)
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
||||
output = @html.radio_button(attributes) { "test" }
|
||||
output.should equal_element("INPUT", attributes, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,77 +1,80 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#radio_group" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed name, values ..." do
|
||||
it "returns a sequence of 'radio'-elements with the passed name and the passed values" do
|
||||
output = CGISpecs.split(@html.radio_group("test", "foo", "bar", "baz"))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
describe "CGI::HtmlExtension#radio_group" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "allows passing a value inside an Array" do
|
||||
output = CGISpecs.split(@html.radio_group("test", ["foo"], "bar", ["baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
describe "when passed name, values ..." do
|
||||
it "returns a sequence of 'radio'-elements with the passed name and the passed values" do
|
||||
output = CGISpecs.split(@html.radio_group("test", "foo", "bar", "baz"))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "allows passing a value inside an Array" do
|
||||
output = CGISpecs.split(@html.radio_group("test", ["foo"], "bar", ["baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "allows passing a value as an Array containing the value and the checked state or a label" do
|
||||
output = CGISpecs.split(@html.radio_group("test", ["foo"], ["bar", true], ["baz", "label for baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
|
||||
# TODO: CGI does not like passing false instead of true.
|
||||
it "allows passing a value as an Array containing the value, a label and the checked state" do
|
||||
output = CGISpecs.split(@html.radio_group("test", ["foo", "label for foo", true], ["bar", "label for bar", false], ["baz", "label for baz", true]))
|
||||
output[0].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "label for foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "label for bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "returns an empty String when passed no values" do
|
||||
@html.radio_group("test").should == ""
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.radio_group("test", "foo", "bar", "baz") { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "allows passing a value as an Array containing the value and the checked state or a label" do
|
||||
output = CGISpecs.split(@html.radio_group("test", ["foo"], ["bar", true], ["baz", "label for baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
describe "when passed Hash" do
|
||||
it "uses the passed Hash to generate the radio sequence" do
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
# TODO: CGI does not like passing false instead of true.
|
||||
it "allows passing a value as an Array containing the value, a label and the checked state" do
|
||||
output = CGISpecs.split(@html.radio_group("test", ["foo", "label for foo", true], ["bar", "label for bar", false], ["baz", "label for baz", true]))
|
||||
output[0].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "label for foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "label for bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "label for baz", not_closed: true)
|
||||
end
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => [["foo"], ["bar", true], "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
it "returns an empty String when passed no values" do
|
||||
@html.radio_group("test").should == ""
|
||||
end
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "1"}, "Foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "radio", "VALUE" => "2"}, "Bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "Baz"}, "Baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.radio_group("test", "foo", "bar", "baz") { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "uses the passed Hash to generate the radio sequence" do
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => [["foo"], ["bar", true], "baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]))
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "1"}, "Foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "radio", "VALUE" => "2"}, "Bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "Baz"}, "Baz", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]) { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]) { "test" })
|
||||
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", not_closed: true)
|
||||
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", not_closed: true)
|
||||
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,57 +1,60 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#reset" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a reset-'input'-element" do
|
||||
output = @html.reset
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#reset" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a reset-'input'-element" do
|
||||
output = @html.reset
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed value" do
|
||||
it "returns a reset-'input'-element with the passed value" do
|
||||
output = @html.reset("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed value" do
|
||||
it "returns a reset-'input'-element with the passed value" do
|
||||
output = @html.reset("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed value, name" do
|
||||
it "returns a reset-'input'-element with the passed value and the passed name" do
|
||||
output = @html.reset("Example", "test-name")
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset("Example", "test-name") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed value, name" do
|
||||
it "returns a reset-'input'-element with the passed value and the passed name" do
|
||||
output = @html.reset("Example", "test-name")
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a reset-'input'-element with the passed value" do
|
||||
output = @html.reset("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset("Example", "test-name") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a reset-'input'-element with the passed value" do
|
||||
output = @html.reset("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.reset("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,11 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require_relative 'fixtures/common'
|
||||
require 'cgi'
|
||||
require_relative 'shared/popup_menu'
|
||||
|
||||
describe "CGI::HtmlExtension#scrolling_list" do
|
||||
it_behaves_like :cgi_htmlextension_popup_menu, :scrolling_list
|
||||
ruby_version_is ""..."3.5" do
|
||||
require_relative 'fixtures/common'
|
||||
require 'cgi'
|
||||
require_relative 'shared/popup_menu'
|
||||
|
||||
describe "CGI::HtmlExtension#scrolling_list" do
|
||||
it_behaves_like :cgi_htmlextension_popup_menu, :scrolling_list
|
||||
end
|
||||
end
|
||||
|
@ -1,57 +1,60 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#submit" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns a submit-'input'-element" do
|
||||
output = @html.submit
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#submit" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns a submit-'input'-element" do
|
||||
output = @html.submit
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed value" do
|
||||
it "returns a submit-'input'-element with the passed value" do
|
||||
output = @html.submit("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed value" do
|
||||
it "returns a submit-'input'-element with the passed value" do
|
||||
output = @html.submit("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed value, name" do
|
||||
it "returns a submit-'input'-element with the passed value and the passed name" do
|
||||
output = @html.submit("Example", "test-name")
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit("Example", "test-name") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed value, name" do
|
||||
it "returns a submit-'input'-element with the passed value and the passed name" do
|
||||
output = @html.submit("Example", "test-name")
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a submit-'input'-element with the passed value" do
|
||||
output = @html.submit("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit("Example", "test-name") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example", "NAME" => "test-name"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a submit-'input'-element with the passed value" do
|
||||
output = @html.submit("Example")
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.submit("Example") { "test" }
|
||||
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,84 +1,87 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#text_field" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns an text-'input'-element without a name" do
|
||||
output = @html.text_field
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
describe "CGI::HtmlExtension#text_field" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns an text-'input'-element without a name" do
|
||||
output = @html.text_field
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name" do
|
||||
it "returns an text-'input'-element with the passed name" do
|
||||
output = @html.text_field("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name" do
|
||||
it "returns an text-'input'-element with the passed name" do
|
||||
output = @html.text_field("test")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value" do
|
||||
it "returns an text-'input'-element with the passed name and value" do
|
||||
output = @html.text_field("test", "some value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value" do
|
||||
it "returns an text-'input'-element with the passed name and value" do
|
||||
output = @html.text_field("test", "some value")
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value, size" do
|
||||
it "returns an text-'input'-element with the passed name, value and size" do
|
||||
output = @html.text_field("test", "some value", 60)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test", "some value") { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "40"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test", "some value", 60) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value, size" do
|
||||
it "returns an text-'input'-element with the passed name, value and size" do
|
||||
output = @html.text_field("test", "some value", 60)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed name, value, size, maxlength" do
|
||||
it "returns an text-'input'-element with the passed name, value, size and maxlength" do
|
||||
output = @html.text_field("test", "some value", 60, 12)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test", "some value", 60) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60"}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test", "some value", 60, 12) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
describe "when passed name, value, size, maxlength" do
|
||||
it "returns an text-'input'-element with the passed name, value, size and maxlength" do
|
||||
output = @html.text_field("test", "some value", 60, 12)
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.text_field("NAME" => "test", "VALUE" => "some value")
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "text" }, "", not_closed: true)
|
||||
|
||||
output = @html.text_field("TYPE" => "hidden")
|
||||
output.should equal_element("INPUT", {"TYPE" => "text"}, "", not_closed: true)
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("test", "some value", 60, 12) { "test" }
|
||||
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "text", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("NAME" => "test", "VALUE" => "some value") { "test" }
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "text" }, "", not_closed: true)
|
||||
describe "when passed Hash" do
|
||||
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
||||
output = @html.text_field("NAME" => "test", "VALUE" => "some value")
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "text" }, "", not_closed: true)
|
||||
|
||||
output = @html.text_field("TYPE" => "hidden")
|
||||
output.should equal_element("INPUT", {"TYPE" => "text"}, "", not_closed: true)
|
||||
end
|
||||
|
||||
it "ignores a passed block" do
|
||||
output = @html.text_field("NAME" => "test", "VALUE" => "some value") { "test" }
|
||||
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "text" }, "", not_closed: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,73 +1,76 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "CGI::HtmlExtension#textarea" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
describe "when passed no arguments" do
|
||||
it "returns an 'textarea'-element without a name" do
|
||||
output = @html.textarea
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "", "COLS" => "70", "ROWS" => "10"}, "")
|
||||
describe "CGI::HtmlExtension#textarea" do
|
||||
before :each do
|
||||
@html = CGISpecs.cgi_new
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "", "COLS" => "70", "ROWS" => "10"}, "Example")
|
||||
end
|
||||
end
|
||||
describe "when passed no arguments" do
|
||||
it "returns an 'textarea'-element without a name" do
|
||||
output = @html.textarea
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "", "COLS" => "70", "ROWS" => "10"}, "")
|
||||
end
|
||||
|
||||
describe "when passed name" do
|
||||
it "returns an 'textarea'-element with the passed name" do
|
||||
output = @html.textarea("test")
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "70", "ROWS" => "10"}, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "", "COLS" => "70", "ROWS" => "10"}, "Example")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea("test") { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "70", "ROWS" => "10"}, "Example")
|
||||
end
|
||||
end
|
||||
describe "when passed name" do
|
||||
it "returns an 'textarea'-element with the passed name" do
|
||||
output = @html.textarea("test")
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "70", "ROWS" => "10"}, "")
|
||||
end
|
||||
|
||||
describe "when passed name, cols" do
|
||||
it "returns an 'textarea'-element with the passed name and the passed amount of columns" do
|
||||
output = @html.textarea("test", 40)
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "10"}, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea("test") { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "70", "ROWS" => "10"}, "Example")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea("test", 40) { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "10"}, "Example")
|
||||
end
|
||||
end
|
||||
describe "when passed name, cols" do
|
||||
it "returns an 'textarea'-element with the passed name and the passed amount of columns" do
|
||||
output = @html.textarea("test", 40)
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "10"}, "")
|
||||
end
|
||||
|
||||
describe "when passed name, cols, rows" do
|
||||
it "returns an 'textarea'-element with the passed name, the passed amount of columns and the passed number of rows" do
|
||||
output = @html.textarea("test", 40, 5)
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "5"}, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea("test", 40) { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "10"}, "Example")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea("test", 40, 5) { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "5"}, "Example")
|
||||
end
|
||||
end
|
||||
describe "when passed name, cols, rows" do
|
||||
it "returns an 'textarea'-element with the passed name, the passed amount of columns and the passed number of rows" do
|
||||
output = @html.textarea("test", 40, 5)
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "5"}, "")
|
||||
end
|
||||
|
||||
describe "when passed Hash" do
|
||||
it "uses the passed Hash as attributes" do
|
||||
@html.textarea("ID" => "test").should == '<TEXTAREA ID="test"></TEXTAREA>'
|
||||
|
||||
attributes = {"ID" => "test-id", "NAME" => "test-name"}
|
||||
output = @html.textarea(attributes)
|
||||
output.should equal_element("TEXTAREA", attributes, "")
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
output = @html.textarea("test", 40, 5) { "Example" }
|
||||
output.should equal_element("TEXTAREA", {"NAME" => "test", "COLS" => "40", "ROWS" => "5"}, "Example")
|
||||
end
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
attributes = {"ID" => "test-id", "NAME" => "test-name"}
|
||||
output = @html.textarea(attributes) { "test" }
|
||||
output.should equal_element("TEXTAREA", attributes, "test")
|
||||
describe "when passed Hash" do
|
||||
it "uses the passed Hash as attributes" do
|
||||
@html.textarea("ID" => "test").should == '<TEXTAREA ID="test"></TEXTAREA>'
|
||||
|
||||
attributes = {"ID" => "test-id", "NAME" => "test-name"}
|
||||
output = @html.textarea(attributes)
|
||||
output.should equal_element("TEXTAREA", attributes, "")
|
||||
end
|
||||
|
||||
it "includes the return value of the passed block when passed a block" do
|
||||
attributes = {"ID" => "test-id", "NAME" => "test-name"}
|
||||
output = @html.textarea(attributes) { "test" }
|
||||
output.should equal_element("TEXTAREA", attributes, "test")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,11 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
require_relative 'shared/http_header'
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI#http_header" do
|
||||
it_behaves_like :cgi_http_header, :http_header
|
||||
require_relative 'shared/http_header'
|
||||
|
||||
describe "CGI#http_header" do
|
||||
it_behaves_like :cgi_http_header, :http_header
|
||||
end
|
||||
end
|
||||
|
@ -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)
|
||||
end
|
||||
|
||||
it "does not extend self with CGI::HtmlExtension" do
|
||||
@cgi.send(:initialize)
|
||||
@cgi.should_not be_kind_of(CGI::HtmlExtension)
|
||||
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
|
||||
|
||||
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
|
||||
describe "CGI#initialize" do
|
||||
it "is private" do
|
||||
CGI.should have_private_instance_method(:initialize)
|
||||
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"
|
||||
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.params.should == { "test2" => ["b"], "?test" => ["a"] }
|
||||
ensure
|
||||
ENV["QUERY_STRING"] = old_env_query
|
||||
ENV["REQUEST_METHOD"] = old_env_method
|
||||
@cgi.should be_kind_of(CGI::QueryExtension)
|
||||
end
|
||||
|
||||
it "does not extend self with CGI::HtmlExtension" do
|
||||
@cgi.send(:initialize)
|
||||
@cgi.should_not be_kind_of(CGI::HtmlExtension)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
describe "CGI#initialize when passed type" 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, "test")
|
||||
@cgi.should be_kind_of(CGI::QueryExtension)
|
||||
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, 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::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)
|
||||
|
||||
@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
|
||||
|
||||
describe "CGI#initialize when passed type" 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, "test")
|
||||
@cgi.should be_kind_of(CGI::QueryExtension)
|
||||
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, 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::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)
|
||||
|
||||
@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
|
||||
|
@ -1,51 +1,54 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI#out" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
$stdout, @old_stdout = IOStub.new, $stdout
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI#out" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
$stdout, @old_stdout = IOStub.new, $stdout
|
||||
end
|
||||
|
||||
after :each do
|
||||
$stdout = @old_stdout
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "it writes a HTMl header based on the passed argument to $stdout" do
|
||||
@cgi.out { "" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 0\r\n\r\n"
|
||||
end
|
||||
|
||||
it "appends the block's return value to the HTML header" do
|
||||
@cgi.out { "test!" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 5\r\n\r\ntest!"
|
||||
end
|
||||
|
||||
it "automatically sets the Content-Length Header based on the block's return value" do
|
||||
@cgi.out { "0123456789" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 10\r\n\r\n0123456789"
|
||||
end
|
||||
|
||||
it "includes Cookies in the @output_cookies field" do
|
||||
@cgi.instance_variable_set(:@output_cookies, ["multiple", "cookies"])
|
||||
@cgi.out { "" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 0\r\nSet-Cookie: multiple\r\nSet-Cookie: cookies\r\n\r\n"
|
||||
end
|
||||
end
|
||||
|
||||
after :each do
|
||||
$stdout = @old_stdout
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI#out when passed no block" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "it writes a HTMl header based on the passed argument to $stdout" do
|
||||
@cgi.out { "" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 0\r\n\r\n"
|
||||
end
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "appends the block's return value to the HTML header" do
|
||||
@cgi.out { "test!" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 5\r\n\r\ntest!"
|
||||
end
|
||||
|
||||
it "automatically sets the Content-Length Header based on the block's return value" do
|
||||
@cgi.out { "0123456789" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 10\r\n\r\n0123456789"
|
||||
end
|
||||
|
||||
it "includes Cookies in the @output_cookies field" do
|
||||
@cgi.instance_variable_set(:@output_cookies, ["multiple", "cookies"])
|
||||
@cgi.out { "" }
|
||||
$stdout.should == "Content-Type: text/html\r\nContent-Length: 0\r\nSet-Cookie: multiple\r\nSet-Cookie: cookies\r\n\r\n"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI#out when passed no block" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "raises a LocalJumpError" do
|
||||
-> { @cgi.out }.should raise_error(LocalJumpError)
|
||||
it "raises a LocalJumpError" do
|
||||
-> { @cgi.out }.should raise_error(LocalJumpError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,24 +1,27 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI.parse when passed String" do
|
||||
it "parses a HTTP Query String into a Hash" do
|
||||
CGI.parse("test=test&a=b").should == { "a" => ["b"], "test" => ["test"] }
|
||||
CGI.parse("test=1,2,3").should == { "test" => ["1,2,3"] }
|
||||
CGI.parse("test=a&a=&b=").should == { "test" => ["a"], "a" => [""], "b" => [""] }
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
it "parses query strings with semicolons in place of ampersands" do
|
||||
CGI.parse("test=test;a=b").should == { "a" => ["b"], "test" => ["test"] }
|
||||
CGI.parse("test=a;a=;b=").should == { "test" => ["a"], "a" => [""], "b" => [""] }
|
||||
end
|
||||
describe "CGI.parse when passed String" do
|
||||
it "parses a HTTP Query String into a Hash" do
|
||||
CGI.parse("test=test&a=b").should == { "a" => ["b"], "test" => ["test"] }
|
||||
CGI.parse("test=1,2,3").should == { "test" => ["1,2,3"] }
|
||||
CGI.parse("test=a&a=&b=").should == { "test" => ["a"], "a" => [""], "b" => [""] }
|
||||
end
|
||||
|
||||
it "allows passing multiple values for one key" do
|
||||
CGI.parse("test=1&test=2&test=3").should == { "test" => ["1", "2", "3"] }
|
||||
CGI.parse("test[]=1&test[]=2&test[]=3").should == { "test[]" => [ "1", "2", "3" ] }
|
||||
end
|
||||
it "parses query strings with semicolons in place of ampersands" do
|
||||
CGI.parse("test=test;a=b").should == { "a" => ["b"], "test" => ["test"] }
|
||||
CGI.parse("test=a;a=;b=").should == { "test" => ["a"], "a" => [""], "b" => [""] }
|
||||
end
|
||||
|
||||
it "unescapes keys and values" do
|
||||
CGI.parse("hello%3F=hello%21").should == { "hello?" => ["hello!"] }
|
||||
it "allows passing multiple values for one key" do
|
||||
CGI.parse("test=1&test=2&test=3").should == { "test" => ["1", "2", "3"] }
|
||||
CGI.parse("test[]=1&test[]=2&test[]=3").should == { "test[]" => [ "1", "2", "3" ] }
|
||||
end
|
||||
|
||||
it "unescapes keys and values" do
|
||||
CGI.parse("hello%3F=hello%21").should == { "hello?" => ["hello!"] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,24 +1,27 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI.pretty when passed html" do
|
||||
it "indents the passed html String with two spaces" do
|
||||
CGI.pretty("<HTML><BODY></BODY></HTML>").should == <<-EOS
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI.pretty when passed html" do
|
||||
it "indents the passed html String with two spaces" do
|
||||
CGI.pretty("<HTML><BODY></BODY></HTML>").should == <<-EOS
|
||||
<HTML>
|
||||
<BODY>
|
||||
</BODY>
|
||||
</HTML>
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI.pretty when passed html, indentation_unit" do
|
||||
it "indents the passed html String with the passed indentation_unit" do
|
||||
CGI.pretty("<HTML><BODY></BODY></HTML>", "\t").should == <<-EOS
|
||||
describe "CGI.pretty when passed html, indentation_unit" do
|
||||
it "indents the passed html String with the passed indentation_unit" do
|
||||
CGI.pretty("<HTML><BODY></BODY></HTML>", "\t").should == <<-EOS
|
||||
<HTML>
|
||||
\t<BODY>
|
||||
\t</BODY>
|
||||
</HTML>
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,26 +1,29 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI#print" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI#print" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "passes all arguments to $stdout.print" do
|
||||
$stdout.should_receive(:print).with("test")
|
||||
@cgi.print("test")
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
$stdout.should_receive(:print).with("one", "two", "three", ["four", "five"])
|
||||
@cgi.print("one", "two", "three", ["four", "five"])
|
||||
end
|
||||
it "passes all arguments to $stdout.print" do
|
||||
$stdout.should_receive(:print).with("test")
|
||||
@cgi.print("test")
|
||||
|
||||
it "returns the result of calling $stdout.print" do
|
||||
$stdout.should_receive(:print).with("test").and_return(:expected)
|
||||
@cgi.print("test").should == :expected
|
||||
$stdout.should_receive(:print).with("one", "two", "three", ["four", "five"])
|
||||
@cgi.print("one", "two", "three", ["four", "five"])
|
||||
end
|
||||
|
||||
it "returns the result of calling $stdout.print" do
|
||||
$stdout.should_receive(:print).with("test").and_return(:expected)
|
||||
@cgi.print("test").should == :expected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#accept_charset" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#accept_charset" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT_CHARSET']" do
|
||||
old_value, ENV['HTTP_ACCEPT_CHARSET'] = ENV['HTTP_ACCEPT_CHARSET'], "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
|
||||
begin
|
||||
@cgi.accept_charset.should == "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT_CHARSET'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT_CHARSET']" do
|
||||
old_value, ENV['HTTP_ACCEPT_CHARSET'] = ENV['HTTP_ACCEPT_CHARSET'], "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
|
||||
begin
|
||||
@cgi.accept_charset.should == "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT_CHARSET'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#accept_encoding" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#accept_encoding" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT_ENCODING']" do
|
||||
old_value, ENV['HTTP_ACCEPT_ENCODING'] = ENV['HTTP_ACCEPT_ENCODING'], "gzip,deflate"
|
||||
begin
|
||||
@cgi.accept_encoding.should == "gzip,deflate"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT_ENCODING'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT_ENCODING']" do
|
||||
old_value, ENV['HTTP_ACCEPT_ENCODING'] = ENV['HTTP_ACCEPT_ENCODING'], "gzip,deflate"
|
||||
begin
|
||||
@cgi.accept_encoding.should == "gzip,deflate"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT_ENCODING'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#accept_language" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#accept_language" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT_LANGUAGE']" do
|
||||
old_value, ENV['HTTP_ACCEPT_LANGUAGE'] = ENV['HTTP_ACCEPT_LANGUAGE'], "en-us,en;q=0.5"
|
||||
begin
|
||||
@cgi.accept_language.should == "en-us,en;q=0.5"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT_LANGUAGE'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT_LANGUAGE']" do
|
||||
old_value, ENV['HTTP_ACCEPT_LANGUAGE'] = ENV['HTTP_ACCEPT_LANGUAGE'], "en-us,en;q=0.5"
|
||||
begin
|
||||
@cgi.accept_language.should == "en-us,en;q=0.5"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT_LANGUAGE'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#accept" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#accept" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT']" do
|
||||
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"
|
||||
begin
|
||||
@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"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_ACCEPT']" do
|
||||
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"
|
||||
begin
|
||||
@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"
|
||||
ensure
|
||||
ENV['HTTP_ACCEPT'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#auth_type" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#auth_type" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['AUTH_TYPE']" do
|
||||
old_value, ENV['AUTH_TYPE'] = ENV['AUTH_TYPE'], "Basic"
|
||||
begin
|
||||
@cgi.auth_type.should == "Basic"
|
||||
ensure
|
||||
ENV['AUTH_TYPE'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['AUTH_TYPE']" do
|
||||
old_value, ENV['AUTH_TYPE'] = ENV['AUTH_TYPE'], "Basic"
|
||||
begin
|
||||
@cgi.auth_type.should == "Basic"
|
||||
ensure
|
||||
ENV['AUTH_TYPE'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#cache_control" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#cache_control" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_CACHE_CONTROL']" do
|
||||
old_value, ENV['HTTP_CACHE_CONTROL'] = ENV['HTTP_CACHE_CONTROL'], "no-cache"
|
||||
begin
|
||||
@cgi.cache_control.should == "no-cache"
|
||||
ensure
|
||||
ENV['HTTP_CACHE_CONTROL'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_CACHE_CONTROL']" do
|
||||
old_value, ENV['HTTP_CACHE_CONTROL'] = ENV['HTTP_CACHE_CONTROL'], "no-cache"
|
||||
begin
|
||||
@cgi.cache_control.should == "no-cache"
|
||||
ensure
|
||||
ENV['HTTP_CACHE_CONTROL'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,26 +1,29 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#content_length" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#content_length" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['CONTENT_LENGTH'] as Integer" do
|
||||
old_value = ENV['CONTENT_LENGTH']
|
||||
begin
|
||||
ENV['CONTENT_LENGTH'] = nil
|
||||
@cgi.content_length.should be_nil
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
ENV['CONTENT_LENGTH'] = "100"
|
||||
@cgi.content_length.should eql(100)
|
||||
ensure
|
||||
ENV['CONTENT_LENGTH'] = old_value
|
||||
it "returns ENV['CONTENT_LENGTH'] as Integer" do
|
||||
old_value = ENV['CONTENT_LENGTH']
|
||||
begin
|
||||
ENV['CONTENT_LENGTH'] = nil
|
||||
@cgi.content_length.should be_nil
|
||||
|
||||
ENV['CONTENT_LENGTH'] = "100"
|
||||
@cgi.content_length.should eql(100)
|
||||
ensure
|
||||
ENV['CONTENT_LENGTH'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#content_type" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#content_type" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['CONTENT_TYPE']" do
|
||||
old_value, ENV['CONTENT_TYPE'] = ENV['CONTENT_TYPE'], "text/html"
|
||||
begin
|
||||
@cgi.content_type.should == "text/html"
|
||||
ensure
|
||||
ENV['CONTENT_TYPE'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['CONTENT_TYPE']" do
|
||||
old_value, ENV['CONTENT_TYPE'] = ENV['CONTENT_TYPE'], "text/html"
|
||||
begin
|
||||
@cgi.content_type.should == "text/html"
|
||||
ensure
|
||||
ENV['CONTENT_TYPE'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,13 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#cookies" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#cookies=" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
describe "CGI::QueryExtension#cookies" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
end
|
||||
|
||||
describe "CGI::QueryExtension#cookies=" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
end
|
||||
end
|
||||
|
@ -1,27 +1,30 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#[]" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b&two=c", ENV['QUERY_STRING']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
ENV['QUERY_STRING'] = @old_query_string
|
||||
end
|
||||
describe "CGI::QueryExtension#[]" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b&two=c", ENV['QUERY_STRING']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "it returns the value for the parameter with the given key" do
|
||||
@cgi["one"].should == "a"
|
||||
end
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
ENV['QUERY_STRING'] = @old_query_string
|
||||
end
|
||||
|
||||
it "only returns the first value for parameters with multiple values" do
|
||||
@cgi["two"].should == "b"
|
||||
end
|
||||
it "it returns the value for the parameter with the given key" do
|
||||
@cgi["one"].should == "a"
|
||||
end
|
||||
|
||||
it "returns a String" do
|
||||
@cgi["one"].should be_kind_of(String)
|
||||
it "only returns the first value for parameters with multiple values" do
|
||||
@cgi["two"].should == "b"
|
||||
end
|
||||
|
||||
it "returns a String" do
|
||||
@cgi["one"].should be_kind_of(String)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#from" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#from" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_FROM']" do
|
||||
old_value, ENV['HTTP_FROM'] = ENV['HTTP_FROM'], "googlebot(at)googlebot.com"
|
||||
begin
|
||||
@cgi.from.should == "googlebot(at)googlebot.com"
|
||||
ensure
|
||||
ENV['HTTP_FROM'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_FROM']" do
|
||||
old_value, ENV['HTTP_FROM'] = ENV['HTTP_FROM'], "googlebot(at)googlebot.com"
|
||||
begin
|
||||
@cgi.from.should == "googlebot(at)googlebot.com"
|
||||
ensure
|
||||
ENV['HTTP_FROM'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#gateway_interface" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#gateway_interface" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['GATEWAY_INTERFACE']" do
|
||||
old_value, ENV['GATEWAY_INTERFACE'] = ENV['GATEWAY_INTERFACE'], "CGI/1.1"
|
||||
begin
|
||||
@cgi.gateway_interface.should == "CGI/1.1"
|
||||
ensure
|
||||
ENV['GATEWAY_INTERFACE'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['GATEWAY_INTERFACE']" do
|
||||
old_value, ENV['GATEWAY_INTERFACE'] = ENV['GATEWAY_INTERFACE'], "CGI/1.1"
|
||||
begin
|
||||
@cgi.gateway_interface.should == "CGI/1.1"
|
||||
ensure
|
||||
ENV['GATEWAY_INTERFACE'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,10 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'shared/has_key'
|
||||
|
||||
describe "CGI::QueryExtension#has_key?" do
|
||||
it_behaves_like :cgi_query_extension_has_key_p, :has_key?
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'shared/has_key'
|
||||
|
||||
describe "CGI::QueryExtension#has_key?" do
|
||||
it_behaves_like :cgi_query_extension_has_key_p, :has_key?
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#host" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#host" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_HOST']" do
|
||||
old_value, ENV['HTTP_HOST'] = ENV['HTTP_HOST'], "localhost"
|
||||
begin
|
||||
@cgi.host.should == "localhost"
|
||||
ensure
|
||||
ENV['HTTP_HOST'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_HOST']" do
|
||||
old_value, ENV['HTTP_HOST'] = ENV['HTTP_HOST'], "localhost"
|
||||
begin
|
||||
@cgi.host.should == "localhost"
|
||||
ensure
|
||||
ENV['HTTP_HOST'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,10 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'shared/has_key'
|
||||
|
||||
describe "CGI::QueryExtension#include?" do
|
||||
it_behaves_like :cgi_query_extension_has_key_p, :include?
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'shared/has_key'
|
||||
|
||||
describe "CGI::QueryExtension#include?" do
|
||||
it_behaves_like :cgi_query_extension_has_key_p, :include?
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,10 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require_relative 'shared/has_key'
|
||||
|
||||
describe "CGI::QueryExtension#key?" do
|
||||
it_behaves_like :cgi_query_extension_has_key_p, :key?
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require_relative 'shared/has_key'
|
||||
|
||||
describe "CGI::QueryExtension#key?" do
|
||||
it_behaves_like :cgi_query_extension_has_key_p, :key?
|
||||
end
|
||||
end
|
||||
|
@ -1,20 +1,23 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#keys" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b", ENV['QUERY_STRING']
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
@cgi = CGI.new
|
||||
end
|
||||
describe "CGI::QueryExtension#keys" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b", ENV['QUERY_STRING']
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
ENV['QUERY_STRING'] = @old_query_string
|
||||
end
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns all parameter keys as an Array" do
|
||||
@cgi.keys.sort.should == ["one", "two"]
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
ENV['QUERY_STRING'] = @old_query_string
|
||||
end
|
||||
|
||||
it "returns all parameter keys as an Array" do
|
||||
@cgi.keys.sort.should == ["one", "two"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,20 +1,22 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
require "stringio"
|
||||
|
||||
describe "CGI::QueryExtension#multipart?" do
|
||||
before :each do
|
||||
@old_stdin = $stdin
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
require "stringio"
|
||||
|
||||
@old_request_method = ENV['REQUEST_METHOD']
|
||||
@old_content_type = ENV['CONTENT_TYPE']
|
||||
@old_content_length = ENV['CONTENT_LENGTH']
|
||||
describe "CGI::QueryExtension#multipart?" do
|
||||
before :each do
|
||||
@old_stdin = $stdin
|
||||
|
||||
ENV['REQUEST_METHOD'] = "POST"
|
||||
ENV["CONTENT_TYPE"] = "multipart/form-data; boundary=---------------------------1137522503144128232716531729"
|
||||
ENV["CONTENT_LENGTH"] = "222"
|
||||
@old_request_method = ENV['REQUEST_METHOD']
|
||||
@old_content_type = ENV['CONTENT_TYPE']
|
||||
@old_content_length = ENV['CONTENT_LENGTH']
|
||||
|
||||
$stdin = StringIO.new <<-EOS
|
||||
ENV['REQUEST_METHOD'] = "POST"
|
||||
ENV["CONTENT_TYPE"] = "multipart/form-data; boundary=---------------------------1137522503144128232716531729"
|
||||
ENV["CONTENT_LENGTH"] = "222"
|
||||
|
||||
$stdin = StringIO.new <<-EOS
|
||||
-----------------------------1137522503144128232716531729\r
|
||||
Content-Disposition: form-data; name="file"; filename=""\r
|
||||
Content-Type: application/octet-stream\r
|
||||
@ -23,18 +25,19 @@ Content-Type: application/octet-stream\r
|
||||
-----------------------------1137522503144128232716531729--\r
|
||||
EOS
|
||||
|
||||
@cgi = CGI.new
|
||||
end
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
after :each do
|
||||
$stdin = @old_stdin
|
||||
after :each do
|
||||
$stdin = @old_stdin
|
||||
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
ENV['CONTENT_TYPE'] = @old_content_type
|
||||
ENV['CONTENT_LENGTH'] = @old_content_length
|
||||
end
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
ENV['CONTENT_TYPE'] = @old_content_type
|
||||
ENV['CONTENT_LENGTH'] = @old_content_length
|
||||
end
|
||||
|
||||
it "returns true if the current Request is a multipart request" do
|
||||
@cgi.multipart?.should be_true
|
||||
it "returns true if the current Request is a multipart request" do
|
||||
@cgi.multipart?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#negotiate" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#negotiate" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_NEGOTIATE']" do
|
||||
old_value, ENV['HTTP_NEGOTIATE'] = ENV['HTTP_NEGOTIATE'], "trans"
|
||||
begin
|
||||
@cgi.negotiate.should == "trans"
|
||||
ensure
|
||||
ENV['HTTP_NEGOTIATE'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_NEGOTIATE']" do
|
||||
old_value, ENV['HTTP_NEGOTIATE'] = ENV['HTTP_NEGOTIATE'], "trans"
|
||||
begin
|
||||
@cgi.negotiate.should == "trans"
|
||||
ensure
|
||||
ENV['HTTP_NEGOTIATE'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,37 +1,40 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#params" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b&two=c&three", ENV['QUERY_STRING']
|
||||
@cgi = CGI.new
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#params" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
ENV['QUERY_STRING'], @old_query_string = "one=a&two=b&two=c&three", ENV['QUERY_STRING']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
after :each do
|
||||
ENV['QUERY_STRING'] = @old_query_string
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns the parsed HTTP Query Params" do
|
||||
@cgi.params.should == {"three"=>[], "two"=>["b", "c"], "one"=>["a"]}
|
||||
end
|
||||
end
|
||||
|
||||
after :each do
|
||||
ENV['QUERY_STRING'] = @old_query_string
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#params=" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns the parsed HTTP Query Params" do
|
||||
@cgi.params.should == {"three"=>[], "two"=>["b", "c"], "one"=>["a"]}
|
||||
end
|
||||
end
|
||||
|
||||
describe "CGI::QueryExtension#params=" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "sets the HTTP Query Params to the passed argument" do
|
||||
@cgi.params.should == {}
|
||||
|
||||
@cgi.params = {"one"=>["a"], "two"=>["b", "c"]}
|
||||
@cgi.params.should == {"one"=>["a"], "two"=>["b", "c"]}
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "sets the HTTP Query Params to the passed argument" do
|
||||
@cgi.params.should == {}
|
||||
|
||||
@cgi.params = {"one"=>["a"], "two"=>["b", "c"]}
|
||||
@cgi.params.should == {"one"=>["a"], "two"=>["b", "c"]}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#path_info" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#path_info" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['PATH_INFO']" do
|
||||
old_value, ENV['PATH_INFO'] = ENV['PATH_INFO'], "/test/path"
|
||||
begin
|
||||
@cgi.path_info.should == "/test/path"
|
||||
ensure
|
||||
ENV['PATH_INFO'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['PATH_INFO']" do
|
||||
old_value, ENV['PATH_INFO'] = ENV['PATH_INFO'], "/test/path"
|
||||
begin
|
||||
@cgi.path_info.should == "/test/path"
|
||||
ensure
|
||||
ENV['PATH_INFO'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#path_translated" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#path_translated" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['PATH_TRANSLATED']" do
|
||||
old_value, ENV['PATH_TRANSLATED'] = ENV['PATH_TRANSLATED'], "/full/path/to/dir"
|
||||
begin
|
||||
@cgi.path_translated.should == "/full/path/to/dir"
|
||||
ensure
|
||||
ENV['PATH_TRANSLATED'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['PATH_TRANSLATED']" do
|
||||
old_value, ENV['PATH_TRANSLATED'] = ENV['PATH_TRANSLATED'], "/full/path/to/dir"
|
||||
begin
|
||||
@cgi.path_translated.should == "/full/path/to/dir"
|
||||
ensure
|
||||
ENV['PATH_TRANSLATED'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#pragma" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#pragma" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_PRAGMA']" do
|
||||
old_value, ENV['HTTP_PRAGMA'] = ENV['HTTP_PRAGMA'], "no-cache"
|
||||
begin
|
||||
@cgi.pragma.should == "no-cache"
|
||||
ensure
|
||||
ENV['HTTP_PRAGMA'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_PRAGMA']" do
|
||||
old_value, ENV['HTTP_PRAGMA'] = ENV['HTTP_PRAGMA'], "no-cache"
|
||||
begin
|
||||
@cgi.pragma.should == "no-cache"
|
||||
ensure
|
||||
ENV['HTTP_PRAGMA'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#query_string" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#query_string" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['QUERY_STRING']" do
|
||||
old_value, ENV['QUERY_STRING'] = ENV['QUERY_STRING'], "one=a&two=b"
|
||||
begin
|
||||
@cgi.query_string.should == "one=a&two=b"
|
||||
ensure
|
||||
ENV['QUERY_STRING'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['QUERY_STRING']" do
|
||||
old_value, ENV['QUERY_STRING'] = ENV['QUERY_STRING'], "one=a&two=b"
|
||||
begin
|
||||
@cgi.query_string.should == "one=a&two=b"
|
||||
ensure
|
||||
ENV['QUERY_STRING'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#raw_cookie2" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#raw_cookie2" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_COOKIE2']" do
|
||||
old_value, ENV['HTTP_COOKIE2'] = ENV['HTTP_COOKIE2'], "some_cookie=data"
|
||||
begin
|
||||
@cgi.raw_cookie2.should == "some_cookie=data"
|
||||
ensure
|
||||
ENV['HTTP_COOKIE2'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_COOKIE2']" do
|
||||
old_value, ENV['HTTP_COOKIE2'] = ENV['HTTP_COOKIE2'], "some_cookie=data"
|
||||
begin
|
||||
@cgi.raw_cookie2.should == "some_cookie=data"
|
||||
ensure
|
||||
ENV['HTTP_COOKIE2'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#raw_cookie" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#raw_cookie" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_COOKIE']" do
|
||||
old_value, ENV['HTTP_COOKIE'] = ENV['HTTP_COOKIE'], "some_cookie=data"
|
||||
begin
|
||||
@cgi.raw_cookie.should == "some_cookie=data"
|
||||
ensure
|
||||
ENV['HTTP_COOKIE'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_COOKIE']" do
|
||||
old_value, ENV['HTTP_COOKIE'] = ENV['HTTP_COOKIE'], "some_cookie=data"
|
||||
begin
|
||||
@cgi.raw_cookie.should == "some_cookie=data"
|
||||
ensure
|
||||
ENV['HTTP_COOKIE'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#referer" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#referer" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_REFERER']" do
|
||||
old_value, ENV['HTTP_REFERER'] = ENV['HTTP_REFERER'], "example.com"
|
||||
begin
|
||||
@cgi.referer.should == "example.com"
|
||||
ensure
|
||||
ENV['HTTP_REFERER'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_REFERER']" do
|
||||
old_value, ENV['HTTP_REFERER'] = ENV['HTTP_REFERER'], "example.com"
|
||||
begin
|
||||
@cgi.referer.should == "example.com"
|
||||
ensure
|
||||
ENV['HTTP_REFERER'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#remote_addr" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#remote_addr" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_ADDR']" do
|
||||
old_value, ENV['REMOTE_ADDR'] = ENV['REMOTE_ADDR'], "127.0.0.1"
|
||||
begin
|
||||
@cgi.remote_addr.should == "127.0.0.1"
|
||||
ensure
|
||||
ENV['REMOTE_ADDR'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_ADDR']" do
|
||||
old_value, ENV['REMOTE_ADDR'] = ENV['REMOTE_ADDR'], "127.0.0.1"
|
||||
begin
|
||||
@cgi.remote_addr.should == "127.0.0.1"
|
||||
ensure
|
||||
ENV['REMOTE_ADDR'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#remote_host" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#remote_host" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_HOST']" do
|
||||
old_value, ENV['REMOTE_HOST'] = ENV['REMOTE_HOST'], "test.host"
|
||||
begin
|
||||
@cgi.remote_host.should == "test.host"
|
||||
ensure
|
||||
ENV['REMOTE_HOST'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_HOST']" do
|
||||
old_value, ENV['REMOTE_HOST'] = ENV['REMOTE_HOST'], "test.host"
|
||||
begin
|
||||
@cgi.remote_host.should == "test.host"
|
||||
ensure
|
||||
ENV['REMOTE_HOST'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#remote_ident" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#remote_ident" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_IDENT']" do
|
||||
old_value, ENV['REMOTE_IDENT'] = ENV['REMOTE_IDENT'], "no-idea-what-this-is-for"
|
||||
begin
|
||||
@cgi.remote_ident.should == "no-idea-what-this-is-for"
|
||||
ensure
|
||||
ENV['REMOTE_IDENT'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_IDENT']" do
|
||||
old_value, ENV['REMOTE_IDENT'] = ENV['REMOTE_IDENT'], "no-idea-what-this-is-for"
|
||||
begin
|
||||
@cgi.remote_ident.should == "no-idea-what-this-is-for"
|
||||
ensure
|
||||
ENV['REMOTE_IDENT'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#remote_user" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#remote_user" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_USER']" do
|
||||
old_value, ENV['REMOTE_USER'] = ENV['REMOTE_USER'], "username"
|
||||
begin
|
||||
@cgi.remote_user.should == "username"
|
||||
ensure
|
||||
ENV['REMOTE_USER'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['REMOTE_USER']" do
|
||||
old_value, ENV['REMOTE_USER'] = ENV['REMOTE_USER'], "username"
|
||||
begin
|
||||
@cgi.remote_user.should == "username"
|
||||
ensure
|
||||
ENV['REMOTE_USER'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#request_method" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#request_method" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['REQUEST_METHOD']" do
|
||||
old_value, ENV['REQUEST_METHOD'] = ENV['REQUEST_METHOD'], "GET"
|
||||
begin
|
||||
@cgi.request_method.should == "GET"
|
||||
ensure
|
||||
ENV['REQUEST_METHOD'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['REQUEST_METHOD']" do
|
||||
old_value, ENV['REQUEST_METHOD'] = ENV['REQUEST_METHOD'], "GET"
|
||||
begin
|
||||
@cgi.request_method.should == "GET"
|
||||
ensure
|
||||
ENV['REQUEST_METHOD'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#script_name" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#script_name" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['SCRIPT_NAME']" do
|
||||
old_value, ENV['SCRIPT_NAME'] = ENV['SCRIPT_NAME'], "/path/to/script.rb"
|
||||
begin
|
||||
@cgi.script_name.should == "/path/to/script.rb"
|
||||
ensure
|
||||
ENV['SCRIPT_NAME'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['SCRIPT_NAME']" do
|
||||
old_value, ENV['SCRIPT_NAME'] = ENV['SCRIPT_NAME'], "/path/to/script.rb"
|
||||
begin
|
||||
@cgi.script_name.should == "/path/to/script.rb"
|
||||
ensure
|
||||
ENV['SCRIPT_NAME'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#server_name" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#server_name" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['SERVER_NAME']" do
|
||||
old_value, ENV['SERVER_NAME'] = ENV['SERVER_NAME'], "localhost"
|
||||
begin
|
||||
@cgi.server_name.should == "localhost"
|
||||
ensure
|
||||
ENV['SERVER_NAME'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['SERVER_NAME']" do
|
||||
old_value, ENV['SERVER_NAME'] = ENV['SERVER_NAME'], "localhost"
|
||||
begin
|
||||
@cgi.server_name.should == "localhost"
|
||||
ensure
|
||||
ENV['SERVER_NAME'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,26 +1,29 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#server_port" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#server_port" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['SERVER_PORT'] as Integer" do
|
||||
old_value = ENV['SERVER_PORT']
|
||||
begin
|
||||
ENV['SERVER_PORT'] = nil
|
||||
@cgi.server_port.should be_nil
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
ENV['SERVER_PORT'] = "3000"
|
||||
@cgi.server_port.should eql(3000)
|
||||
ensure
|
||||
ENV['SERVER_PORT'] = old_value
|
||||
it "returns ENV['SERVER_PORT'] as Integer" do
|
||||
old_value = ENV['SERVER_PORT']
|
||||
begin
|
||||
ENV['SERVER_PORT'] = nil
|
||||
@cgi.server_port.should be_nil
|
||||
|
||||
ENV['SERVER_PORT'] = "3000"
|
||||
@cgi.server_port.should eql(3000)
|
||||
ensure
|
||||
ENV['SERVER_PORT'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#server_protocol" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#server_protocol" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['SERVER_PROTOCOL']" do
|
||||
old_value, ENV['SERVER_PROTOCOL'] = ENV['SERVER_PROTOCOL'], "HTTP/1.1"
|
||||
begin
|
||||
@cgi.server_protocol.should == "HTTP/1.1"
|
||||
ensure
|
||||
ENV['SERVER_PROTOCOL'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['SERVER_PROTOCOL']" do
|
||||
old_value, ENV['SERVER_PROTOCOL'] = ENV['SERVER_PROTOCOL'], "HTTP/1.1"
|
||||
begin
|
||||
@cgi.server_protocol.should == "HTTP/1.1"
|
||||
ensure
|
||||
ENV['SERVER_PROTOCOL'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#server_software" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#server_software" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['SERVER_SOFTWARE']" do
|
||||
old_value, ENV['SERVER_SOFTWARE'] = ENV['SERVER_SOFTWARE'], "Server/1.0.0"
|
||||
begin
|
||||
@cgi.server_software.should == "Server/1.0.0"
|
||||
ensure
|
||||
ENV['SERVER_SOFTWARE'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['SERVER_SOFTWARE']" do
|
||||
old_value, ENV['SERVER_SOFTWARE'] = ENV['SERVER_SOFTWARE'], "Server/1.0.0"
|
||||
begin
|
||||
@cgi.server_software.should == "Server/1.0.0"
|
||||
ensure
|
||||
ENV['SERVER_SOFTWARE'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,22 +1,25 @@
|
||||
require_relative '../../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI::QueryExtension#user_agent" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
describe "CGI::QueryExtension#user_agent" do
|
||||
before :each do
|
||||
ENV['REQUEST_METHOD'], @old_request_method = "GET", ENV['REQUEST_METHOD']
|
||||
@cgi = CGI.new
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_USER_AGENT']" do
|
||||
old_value, ENV['HTTP_USER_AGENT'] = ENV['HTTP_USER_AGENT'], "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; de-de) AppleWebKit/527+ (KHTML, like Gecko) Version/3.1 Safari/525.13"
|
||||
begin
|
||||
@cgi.user_agent.should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; de-de) AppleWebKit/527+ (KHTML, like Gecko) Version/3.1 Safari/525.13"
|
||||
ensure
|
||||
ENV['HTTP_USER_AGENT'] = old_value
|
||||
after :each do
|
||||
ENV['REQUEST_METHOD'] = @old_request_method
|
||||
end
|
||||
|
||||
it "returns ENV['HTTP_USER_AGENT']" do
|
||||
old_value, ENV['HTTP_USER_AGENT'] = ENV['HTTP_USER_AGENT'], "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; de-de) AppleWebKit/527+ (KHTML, like Gecko) Version/3.1 Safari/525.13"
|
||||
begin
|
||||
@cgi.user_agent.should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; de-de) AppleWebKit/527+ (KHTML, like Gecko) Version/3.1 Safari/525.13"
|
||||
ensure
|
||||
ENV['HTTP_USER_AGENT'] = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,13 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI.rfc1123_date when passed Time" do
|
||||
it "returns the passed Time formatted in RFC1123 ('Sat, 01 Dec 2007 15:56:42 GMT')" do
|
||||
input = Time.at(1196524602)
|
||||
expected = 'Sat, 01 Dec 2007 15:56:42 GMT'
|
||||
CGI.rfc1123_date(input).should == expected
|
||||
ruby_version_is ""..."3.5" do
|
||||
require 'cgi'
|
||||
|
||||
describe "CGI.rfc1123_date when passed Time" do
|
||||
it "returns the passed Time formatted in RFC1123 ('Sat, 01 Dec 2007 15:56:42 GMT')" do
|
||||
input = Time.at(1196524602)
|
||||
expected = 'Sat, 01 Dec 2007 15:56:42 GMT'
|
||||
CGI.rfc1123_date(input).should == expected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,9 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
begin
|
||||
require 'cgi/escape'
|
||||
rescue LoadError
|
||||
require 'cgi'
|
||||
end
|
||||
|
||||
describe "CGI.unescapeElement when passed String, elements, ..." do
|
||||
it "unescapes only the tags of the passed elements in the passed String" do
|
||||
|
@ -1,5 +1,9 @@
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
begin
|
||||
require 'cgi/escape'
|
||||
rescue LoadError
|
||||
require 'cgi'
|
||||
end
|
||||
|
||||
describe "CGI.unescapeHTML" do
|
||||
it "unescapes '& < > "' to '& < > \"'" do
|
||||
|
@ -1,6 +1,10 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
require_relative '../../spec_helper'
|
||||
require 'cgi'
|
||||
begin
|
||||
require 'cgi/escape'
|
||||
rescue LoadError
|
||||
require 'cgi'
|
||||
end
|
||||
|
||||
describe "CGI.unescape" do
|
||||
it "url-decodes the passed argument" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user