rubysl-cgi 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/cgi.rb +1 -0
- data/lib/rubysl/cgi.rb +2 -0
- data/lib/rubysl/cgi/cgi.rb +2333 -0
- data/lib/rubysl/cgi/version.rb +5 -0
- data/rubysl-cgi.gemspec +23 -0
- data/spec/cookie/domain_spec.rb +22 -0
- data/spec/cookie/expires_spec.rb +22 -0
- data/spec/cookie/initialize_spec.rb +146 -0
- data/spec/cookie/name_spec.rb +22 -0
- data/spec/cookie/parse_spec.rb +17 -0
- data/spec/cookie/path_spec.rb +22 -0
- data/spec/cookie/secure_spec.rb +69 -0
- data/spec/cookie/to_s_spec.rb +28 -0
- data/spec/cookie/value_spec.rb +79 -0
- data/spec/escapeElement_spec.rb +19 -0
- data/spec/escapeHTML_spec.rb +25 -0
- data/spec/escape_spec.rb +13 -0
- data/spec/header_spec.rb +7 -0
- data/spec/htmlextension/a_spec.rb +48 -0
- data/spec/htmlextension/base_spec.rb +32 -0
- data/spec/htmlextension/blockquote_spec.rb +32 -0
- data/spec/htmlextension/br_spec.rb +21 -0
- data/spec/htmlextension/caption_spec.rb +32 -0
- data/spec/htmlextension/checkbox_group_spec.rb +77 -0
- data/spec/htmlextension/checkbox_spec.rb +76 -0
- data/spec/htmlextension/doctype_spec.rb +26 -0
- data/spec/htmlextension/file_field_spec.rb +73 -0
- data/spec/htmlextension/fixtures/common.rb +16 -0
- data/spec/htmlextension/form_spec.rb +57 -0
- data/spec/htmlextension/frame_spec.rb +13 -0
- data/spec/htmlextension/frameset_spec.rb +13 -0
- data/spec/htmlextension/hidden_spec.rb +58 -0
- data/spec/htmlextension/html_spec.rb +65 -0
- data/spec/htmlextension/image_button_spec.rb +68 -0
- data/spec/htmlextension/img_spec.rb +84 -0
- data/spec/htmlextension/multipart_form_spec.rb +63 -0
- data/spec/htmlextension/password_field_spec.rb +83 -0
- data/spec/htmlextension/popup_menu_spec.rb +7 -0
- data/spec/htmlextension/radio_button_spec.rb +76 -0
- data/spec/htmlextension/radio_group_spec.rb +78 -0
- data/spec/htmlextension/reset_spec.rb +56 -0
- data/spec/htmlextension/scrolling_list_spec.rb +7 -0
- data/spec/htmlextension/shared/popup_menu.rb +94 -0
- data/spec/htmlextension/submit_spec.rb +56 -0
- data/spec/htmlextension/text_field_spec.rb +83 -0
- data/spec/htmlextension/textarea_spec.rb +72 -0
- data/spec/http_header_spec.rb +9 -0
- data/spec/initialize_spec.rb +171 -0
- data/spec/out_spec.rb +50 -0
- data/spec/parse_spec.rb +23 -0
- data/spec/pretty_spec.rb +23 -0
- data/spec/print_spec.rb +25 -0
- data/spec/queryextension/accept_charset_spec.rb +21 -0
- data/spec/queryextension/accept_encoding_spec.rb +21 -0
- data/spec/queryextension/accept_language_spec.rb +21 -0
- data/spec/queryextension/accept_spec.rb +21 -0
- data/spec/queryextension/auth_type_spec.rb +21 -0
- data/spec/queryextension/cache_control_spec.rb +21 -0
- data/spec/queryextension/content_length_spec.rb +25 -0
- data/spec/queryextension/content_type_spec.rb +21 -0
- data/spec/queryextension/cookies_spec.rb +9 -0
- data/spec/queryextension/element_reference_spec.rb +33 -0
- data/spec/queryextension/from_spec.rb +21 -0
- data/spec/queryextension/gateway_interface_spec.rb +21 -0
- data/spec/queryextension/has_key_spec.rb +6 -0
- data/spec/queryextension/host_spec.rb +21 -0
- data/spec/queryextension/include_spec.rb +6 -0
- data/spec/queryextension/key_spec.rb +6 -0
- data/spec/queryextension/keys_spec.rb +19 -0
- data/spec/queryextension/multipart_spec.rb +39 -0
- data/spec/queryextension/negotiate_spec.rb +21 -0
- data/spec/queryextension/params_spec.rb +44 -0
- data/spec/queryextension/path_info_spec.rb +21 -0
- data/spec/queryextension/path_translated_spec.rb +21 -0
- data/spec/queryextension/pragma_spec.rb +21 -0
- data/spec/queryextension/query_string_spec.rb +21 -0
- data/spec/queryextension/raw_cookie2_spec.rb +21 -0
- data/spec/queryextension/raw_cookie_spec.rb +21 -0
- data/spec/queryextension/referer_spec.rb +21 -0
- data/spec/queryextension/remote_addr_spec.rb +21 -0
- data/spec/queryextension/remote_host_spec.rb +21 -0
- data/spec/queryextension/remote_ident_spec.rb +21 -0
- data/spec/queryextension/remote_user_spec.rb +21 -0
- data/spec/queryextension/request_method_spec.rb +21 -0
- data/spec/queryextension/script_name_spec.rb +21 -0
- data/spec/queryextension/server_name_spec.rb +21 -0
- data/spec/queryextension/server_port_spec.rb +25 -0
- data/spec/queryextension/server_protocol_spec.rb +21 -0
- data/spec/queryextension/server_software_spec.rb +21 -0
- data/spec/queryextension/shared/has_key.rb +19 -0
- data/spec/queryextension/user_agent_spec.rb +21 -0
- data/spec/rfc1123_date_spec.rb +9 -0
- data/spec/shared/http_header.rb +111 -0
- data/spec/unescapeElement_spec.rb +19 -0
- data/spec/unescapeHTML_spec.rb +33 -0
- data/spec/unescape_spec.rb +14 -0
- metadata +293 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
3
|
+
|
4
|
+
describe "CGI::HtmlExtension#password_field" do
|
5
|
+
before(:each) do
|
6
|
+
@html = CGISpecs.cgi_new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "when passed no arguments" do
|
10
|
+
it "returns an password-'input'-element without a name" do
|
11
|
+
output = @html.password_field
|
12
|
+
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "password", "SIZE" => "40"}, "", :not_closed => true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "ignores a passed block" do
|
16
|
+
output = @html.password_field { "test" }
|
17
|
+
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "password", "SIZE" => "40"}, "", :not_closed => true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when passed name" do
|
22
|
+
it "returns an password-'input'-element with the passed name" do
|
23
|
+
output = @html.password_field("test")
|
24
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "SIZE" => "40"}, "", :not_closed => true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "ignores a passed block" do
|
28
|
+
output = @html.password_field("test") { "test" }
|
29
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "SIZE" => "40"}, "", :not_closed => true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when passed name, value" do
|
34
|
+
it "returns an password-'input'-element with the passed name and value" do
|
35
|
+
output = @html.password_field("test", "some value")
|
36
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "40"}, "", :not_closed => true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "ignores a passed block" do
|
40
|
+
output = @html.password_field("test", "some value") { "test" }
|
41
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "40"}, "", :not_closed => true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when passed name, value, size" do
|
46
|
+
it "returns an password-'input'-element with the passed name, value and size" do
|
47
|
+
output = @html.password_field("test", "some value", 60)
|
48
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60"}, "", :not_closed => true)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "ignores a passed block" do
|
52
|
+
output = @html.password_field("test", "some value", 60) { "test" }
|
53
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60"}, "", :not_closed => true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "when passed name, value, size, maxlength" do
|
58
|
+
it "returns an password-'input'-element with the passed name, value, size and maxlength" do
|
59
|
+
output = @html.password_field("test", "some value", 60, 12)
|
60
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", :not_closed => true)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "ignores a passed block" do
|
64
|
+
output = @html.password_field("test", "some value", 60, 12) { "test" }
|
65
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "password", "VALUE" => "some value", "SIZE" => "60", "MAXLENGTH" => 12}, "", :not_closed => true)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "when passed Hash" do
|
70
|
+
it "returns a checkbox-'input'-element using the passed Hash for attributes" do
|
71
|
+
output = @html.password_field("NAME" => "test", "VALUE" => "some value")
|
72
|
+
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "password" }, "", :not_closed => true)
|
73
|
+
|
74
|
+
output = @html.password_field("TYPE" => "hidden")
|
75
|
+
output.should equal_element("INPUT", {"TYPE" => "password"}, "", :not_closed => true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "ignores a passed block" do
|
79
|
+
output = @html.password_field("NAME" => "test", "VALUE" => "some value") { "test" }
|
80
|
+
output.should equal_element("INPUT", { "NAME" => "test", "VALUE" => "some value", "TYPE" => "password" }, "", :not_closed => true)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
3
|
+
|
4
|
+
describe "CGI::HtmlExtension#radio_button" do
|
5
|
+
before(:each) do
|
6
|
+
@html = CGISpecs.cgi_new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "when passed no arguments" do
|
10
|
+
it "returns a radio-'input'-element without a name" do
|
11
|
+
output = @html.radio_button
|
12
|
+
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "radio"}, "", :not_closed => true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "ignores a passed block" do
|
16
|
+
output = @html.radio_button { "test" }
|
17
|
+
output.should equal_element("INPUT", {"NAME" => "", "TYPE" => "radio"}, "", :not_closed => true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when passed name" do
|
22
|
+
it "returns a radio-'input'-element with the passed name" do
|
23
|
+
output = @html.radio_button("test")
|
24
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio"}, "", :not_closed => true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "ignores a passed block" do
|
28
|
+
output = @html.radio_button("test") { "test" }
|
29
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio"}, "", :not_closed => true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "CGI::HtmlExtension#checkbox when passed name, value" do
|
34
|
+
it "returns a radio-'input'-element with the passed name and value" do
|
35
|
+
output = @html.radio_button("test", "test-value")
|
36
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", :not_closed => true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "ignores a passed block" do
|
40
|
+
output = @html.radio_button("test", "test-value") { "test" }
|
41
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", :not_closed => true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when passed name, value, checked" do
|
46
|
+
it "returns a checked radio-'input'-element with the passed name and value when checked is true" do
|
47
|
+
output = @html.radio_button("test", "test-value", true)
|
48
|
+
output.should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", :not_closed => true)
|
49
|
+
|
50
|
+
output = @html.radio_button("test", "test-value", false)
|
51
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", :not_closed => true)
|
52
|
+
|
53
|
+
output = @html.radio_button("test", "test-value", nil)
|
54
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", :not_closed => true)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "ignores a passed block" do
|
58
|
+
output = @html.radio_button("test", "test-value", nil) { "test" }
|
59
|
+
output.should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "test-value"}, "", :not_closed => true)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "when passed Hash" do
|
64
|
+
it "returns a radio-'input'-element using the passed Hash for attributes" do
|
65
|
+
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
66
|
+
output = @html.radio_button(attributes)
|
67
|
+
output.should equal_element("INPUT", attributes, "", :not_closed => true)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "ignores a passed block" do
|
71
|
+
attributes = {"NAME" => "test", "VALUE" => "test-value", "CHECKED" => true}
|
72
|
+
output = @html.radio_button(attributes) { "test" }
|
73
|
+
output.should equal_element("INPUT", attributes, "", :not_closed => true)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
3
|
+
|
4
|
+
describe "CGI::HtmlExtension#radio_group" do
|
5
|
+
before(:each) do
|
6
|
+
@html = CGISpecs.cgi_new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "when passed name, values ..." do
|
10
|
+
it "returns a sequence of 'radio'-elements with the passed name and the passed values" do
|
11
|
+
output = CGISpecs.split(@html.radio_group("test", "foo", "bar", "baz"))
|
12
|
+
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", :not_closed => true)
|
13
|
+
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", :not_closed => true)
|
14
|
+
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", :not_closed => true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "allows passing a value inside an Array" do
|
18
|
+
output = CGISpecs.split(@html.radio_group("test", ["foo"], "bar", ["baz"]))
|
19
|
+
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", :not_closed => true)
|
20
|
+
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", :not_closed => true)
|
21
|
+
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", :not_closed => true)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "allows passing a value as an Array containing the value and the checked state or a label" do
|
25
|
+
output = CGISpecs.split(@html.radio_group("test", ["foo"], ["bar", true], ["baz", "label for baz"]))
|
26
|
+
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", :not_closed => true)
|
27
|
+
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", :not_closed => true)
|
28
|
+
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "label for baz", :not_closed => true)
|
29
|
+
end
|
30
|
+
|
31
|
+
# TODO: CGI does not like passing false instead of true.
|
32
|
+
ruby_bug "http://redmine.ruby-lang.org/issues/show/444", "1.8.7" do
|
33
|
+
it "allows passing a value as an Array containing the value, a label and the checked state" do
|
34
|
+
output = CGISpecs.split(@html.radio_group("test", ["foo", "label for foo", true], ["bar", "label for bar", false], ["baz", "label for baz", true]))
|
35
|
+
output[0].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "label for foo", :not_closed => true)
|
36
|
+
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "label for bar", :not_closed => true)
|
37
|
+
output[2].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "label for baz", :not_closed => true)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns an empty String when passed no values" do
|
42
|
+
@html.radio_group("test").should == ""
|
43
|
+
end
|
44
|
+
|
45
|
+
it "ignores a passed block" do
|
46
|
+
output = CGISpecs.split(@html.radio_group("test", "foo", "bar", "baz") { "test" })
|
47
|
+
output[0].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "foo"}, "foo", :not_closed => true)
|
48
|
+
output[1].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "bar"}, "bar", :not_closed => true)
|
49
|
+
output[2].should equal_element("INPUT", {"NAME" => "test", "TYPE" => "radio", "VALUE" => "baz"}, "baz", :not_closed => true)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "when passed Hash" do
|
54
|
+
it "uses the passed Hash to generate the radio sequence" do
|
55
|
+
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]))
|
56
|
+
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", :not_closed => true)
|
57
|
+
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", :not_closed => true)
|
58
|
+
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", :not_closed => true)
|
59
|
+
|
60
|
+
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => [["foo"], ["bar", true], "baz"]))
|
61
|
+
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", :not_closed => true)
|
62
|
+
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", :not_closed => true)
|
63
|
+
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", :not_closed => true)
|
64
|
+
|
65
|
+
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]))
|
66
|
+
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "1"}, "Foo", :not_closed => true)
|
67
|
+
output[1].should equal_element("INPUT", {"CHECKED" => true, "NAME" => "name", "TYPE" => "radio", "VALUE" => "2"}, "Bar", :not_closed => true)
|
68
|
+
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "Baz"}, "Baz", :not_closed => true)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "ignores a passed block" do
|
72
|
+
output = CGISpecs.split(@html.radio_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]) { "test" })
|
73
|
+
output[0].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "foo"}, "foo", :not_closed => true)
|
74
|
+
output[1].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "bar"}, "bar", :not_closed => true)
|
75
|
+
output[2].should equal_element("INPUT", {"NAME" => "name", "TYPE" => "radio", "VALUE" => "baz"}, "baz", :not_closed => true)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
3
|
+
|
4
|
+
describe "CGI::HtmlExtension#reset" do
|
5
|
+
before(:each) do
|
6
|
+
@html = CGISpecs.cgi_new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "when passed no arguments" do
|
10
|
+
it "returns a reset-'input'-element" do
|
11
|
+
output = @html.reset
|
12
|
+
output.should equal_element("INPUT", {"TYPE" => "reset"}, "", :not_closed => true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "ignores a passed block" do
|
16
|
+
output = @html.reset { "test" }
|
17
|
+
output.should equal_element("INPUT", {"TYPE" => "reset"}, "", :not_closed => true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when passed value" do
|
22
|
+
it "returns a reset-'input'-element with the passed value" do
|
23
|
+
output = @html.reset("Example")
|
24
|
+
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", :not_closed => true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "ignores a passed block" do
|
28
|
+
output = @html.reset("Example") { "test" }
|
29
|
+
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", :not_closed => true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when passed value, name" do
|
34
|
+
it "returns a reset-'input'-element with the passed value and the passed name" do
|
35
|
+
output = @html.reset("Example", "test-name")
|
36
|
+
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example", "NAME" => "test-name"}, "", :not_closed => true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "ignores a passed block" do
|
40
|
+
output = @html.reset("Example", "test-name") { "test" }
|
41
|
+
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example", "NAME" => "test-name"}, "", :not_closed => true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when passed Hash" do
|
46
|
+
it "returns a reset-'input'-element with the passed value" do
|
47
|
+
output = @html.reset("Example")
|
48
|
+
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", :not_closed => true)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "ignores a passed block" do
|
52
|
+
output = @html.reset("Example") { "test" }
|
53
|
+
output.should equal_element("INPUT", {"TYPE" => "reset", "VALUE" => "Example"}, "", :not_closed => true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
describe :cgi_htmlextension_popup_menu, :shared => true do
|
2
|
+
before(:each) do
|
3
|
+
@html = CGISpecs.cgi_new
|
4
|
+
end
|
5
|
+
|
6
|
+
describe "when passed no arguments" do
|
7
|
+
it "returns an empty 'select'-element without a name" do
|
8
|
+
output = @html.send(@method)
|
9
|
+
output.should equal_element("SELECT", {"NAME" => ""}, "")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "ignores a passed block" do
|
13
|
+
output = @html.send(@method) { "test" }
|
14
|
+
output.should equal_element("SELECT", {"NAME" => ""}, "")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "when passed name, values ..." do
|
19
|
+
it "returns a 'select'-element with the passed name containing 'option'-elements based on the passed values" do
|
20
|
+
content = @html.option("VALUE" => "foo") { "foo" }
|
21
|
+
content << @html.option("VALUE" => "bar") { "bar" }
|
22
|
+
content << @html.option("VALUE" => "baz") { "baz" }
|
23
|
+
|
24
|
+
output = @html.send(@method, "test", "foo", "bar", "baz")
|
25
|
+
output.should equal_element("SELECT", {"NAME" => "test"}, content)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "allows passing values inside of arrays" do
|
29
|
+
content = @html.option("VALUE" => "foo") { "foo" }
|
30
|
+
content << @html.option("VALUE" => "bar") { "bar" }
|
31
|
+
content << @html.option("VALUE" => "baz") { "baz" }
|
32
|
+
|
33
|
+
output = @html.send(@method, "test", ["foo"], ["bar"], ["baz"])
|
34
|
+
output.should equal_element("SELECT", {"NAME" => "test"}, content)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "allows passing a value as an Array containing the value and the select state or a label" do
|
38
|
+
content = @html.option("VALUE" => "foo") { "foo" }
|
39
|
+
content << @html.option("VALUE" => "bar", "SELECTED" => true) { "bar" }
|
40
|
+
content << @html.option("VALUE" => "baz") { "baz" }
|
41
|
+
|
42
|
+
output = @html.send(@method, "test", ["foo"], ["bar", true], "baz")
|
43
|
+
output.should equal_element("SELECT", {"NAME" => "test"}, content)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "allows passing a value as an Array containing the value, a label and the select state" do
|
47
|
+
content = @html.option("VALUE" => "1") { "Foo" }
|
48
|
+
content << @html.option("VALUE" => "2", "SELECTED" => true) { "Bar" }
|
49
|
+
content << @html.option("VALUE" => "Baz") { "Baz" }
|
50
|
+
|
51
|
+
output = @html.send(@method, "test", ["1", "Foo"], ["2", "Bar", true], "Baz")
|
52
|
+
output.should equal_element("SELECT", {"NAME" => "test"}, content)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "ignores a passed block" do
|
56
|
+
content = @html.option("VALUE" => "foo") { "foo" }
|
57
|
+
content << @html.option("VALUE" => "bar") { "bar" }
|
58
|
+
content << @html.option("VALUE" => "baz") { "baz" }
|
59
|
+
|
60
|
+
output = @html.send(@method, "test", "foo", "bar", "baz") { "woot" }
|
61
|
+
output.should equal_element("SELECT", {"NAME" => "test"}, content)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "when passed a Hash" do
|
66
|
+
it "uses the passed Hash to generate the 'select'-element and the 'option'-elements" do
|
67
|
+
attributes = {
|
68
|
+
"NAME" => "test", "SIZE" => 2, "MULTIPLE" => true,
|
69
|
+
"VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]
|
70
|
+
}
|
71
|
+
|
72
|
+
content = @html.option("VALUE" => "1") { "Foo" }
|
73
|
+
content << @html.option("VALUE" => "2", "SELECTED" => true) { "Bar" }
|
74
|
+
content << @html.option("VALUE" => "Baz") { "Baz" }
|
75
|
+
|
76
|
+
output = @html.send(@method, attributes)
|
77
|
+
output.should equal_element("SELECT", {"NAME" => "test", "SIZE" => 2, "MULTIPLE" => true}, content)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "ignores a passed block" do
|
81
|
+
attributes = {
|
82
|
+
"NAME" => "test", "SIZE" => 2, "MULTIPLE" => true,
|
83
|
+
"VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"]
|
84
|
+
}
|
85
|
+
|
86
|
+
content = @html.option("VALUE" => "1") { "Foo" }
|
87
|
+
content << @html.option("VALUE" => "2", "SELECTED" => true) { "Bar" }
|
88
|
+
content << @html.option("VALUE" => "Baz") { "Baz" }
|
89
|
+
|
90
|
+
output = @html.send(@method, attributes) { "testing" }
|
91
|
+
output.should equal_element("SELECT", {"NAME" => "test", "SIZE" => 2, "MULTIPLE" => true}, content)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
3
|
+
|
4
|
+
describe "CGI::HtmlExtension#submit" do
|
5
|
+
before(:each) do
|
6
|
+
@html = CGISpecs.cgi_new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "when passed no arguments" do
|
10
|
+
it "returns a submit-'input'-element" do
|
11
|
+
output = @html.submit
|
12
|
+
output.should equal_element("INPUT", {"TYPE" => "submit"}, "", :not_closed => true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "ignores a passed block" do
|
16
|
+
output = @html.submit { "test" }
|
17
|
+
output.should equal_element("INPUT", {"TYPE" => "submit"}, "", :not_closed => true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when passed value" do
|
22
|
+
it "returns a submit-'input'-element with the passed value" do
|
23
|
+
output = @html.submit("Example")
|
24
|
+
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", :not_closed => true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "ignores a passed block" do
|
28
|
+
output = @html.submit("Example") { "test" }
|
29
|
+
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", :not_closed => true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when passed value, name" do
|
34
|
+
it "returns a submit-'input'-element with the passed value and the passed name" do
|
35
|
+
output = @html.submit("Example", "test-name")
|
36
|
+
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example", "NAME" => "test-name"}, "", :not_closed => true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "ignores a passed block" do
|
40
|
+
output = @html.submit("Example", "test-name") { "test" }
|
41
|
+
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example", "NAME" => "test-name"}, "", :not_closed => true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when passed Hash" do
|
46
|
+
it "returns a submit-'input'-element with the passed value" do
|
47
|
+
output = @html.submit("Example")
|
48
|
+
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", :not_closed => true)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "ignores a passed block" do
|
52
|
+
output = @html.submit("Example") { "test" }
|
53
|
+
output.should equal_element("INPUT", {"TYPE" => "submit", "VALUE" => "Example"}, "", :not_closed => true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|