require File.expand_path('../../../../spec_helper', __FILE__) require 'cgi' require File.expand_path('../fixtures/common', __FILE__) describe "CGI::HtmlExtension#html" do before :each do @html = CGISpecs.cgi_new @html.stub!(:doctype).and_return("") end describe "when passed no arguments" do it "returns a self's doctype and an 'html'-element" do expected = '' @html.html.should == expected end it "includes the passed block when passed a block" do expected = 'test' @html.html { "test" }.should == expected end end describe "when passed 'PRETTY'" do it "returns pretty output when the passed String is 'PRETTY" do expected = "\n\n" @html.html("PRETTY").should == expected end it "includes the passed block when passed a block" do expected = "\n\n test\n\n" @html.html("PRETTY") { "test" }.should == expected end end describe "when passed a Hash" do it "returns an 'html'-element using the passed Hash for attributes" do expected = '' @html.html("DOCTYPE" => '', "BLA" => "TEST").should == expected 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("DOCTYPE" => nil).should == "" end end describe "when each HTML generation" do it "returns the doctype declaration for HTML3" do expect = '' CGISpecs.cgi_new("html3").html.should == expect + "" CGISpecs.cgi_new("html3").html { "html body" }.should == expect + "html body" end it "returns the doctype declaration for HTML4" do expect = '' CGISpecs.cgi_new("html4").html.should == expect + "" CGISpecs.cgi_new("html4").html { "html body" }.should == expect + "html body" end it "returns the doctype declaration for the Transitional version of HTML4" do expect = '' CGISpecs.cgi_new("html4Tr").html.should == expect + "" CGISpecs.cgi_new("html4Tr").html { "html body" }.should == expect + "html body" end end end