0
@@ -4,6 +4,222 @@ require Pathname(__FILE__).dirname.expand_path.parent.parent + 'spec_helper'
0
describe Mack::ViewHelpers::FormHelpers do
0
include Mack::ViewHelpers
0
+ attr_accessor :full_name
0
+ attr_accessor :bio_file
0
+ @cop.full_name = "ness"
0
+ @cop.bio_file = "~/bio.doc"
0
+ @default_file = "~/resume.doc"
0
+ describe "check_box" do
0
+ it "should create a nested checkbox for a model" do
0
+ check_box(:cop, :tos).should == %{<input id="cop_tos" name="cop[tos]" type="checkbox" />}
0
+ it "should create a non-nested checkbox for a simple object" do
0
+ check_box(:simple).should == %{<input checked="checked" id="simple" name="simple" type="checkbox" />}
0
+ it "should create a non-nested checkbox for just a symbol" do
0
+ check_box(:unknown).should == %{<input id="unknown" name="unknown" type="checkbox" />}
0
+ it "should be checked if the value is true" do
0
+ check_box(:cop, :tos).should == %{<input checked="checked" id="cop_tos" name="cop[tos]" type="checkbox" />}
0
+ it "should be unchecked if the value is false" do
0
+ check_box(:cop, :tos).should == %{<input id="cop_tos" name="cop[tos]" type="checkbox" />}
0
+ describe "file_field" do
0
+ it "should create a nested file_field for a model" do
0
+ file_field(:cop, :bio_file).should == %{<input id="cop_bio_file" name="cop[bio_file]" type="file" value="~/bio.doc" />}
0
+ it "should create a non-nested file_field for a simple object" do
0
+ file_field(:default_file).should == %{<input id="default_file" name="default_file" type="file" value="~/resume.doc" />}
0
+ it "should create a non-nested file_field for just a symbol" do
0
+ file_field(:unknown).should == %{<input id="unknown" name="unknown" type="file" />}
0
+ it "should create a nested file_field for a model with an empty value if value is false" do
0
+ file_field(:cop, :bio_file).should == %{<input id="cop_bio_file" name="cop[bio_file]" type="file" value="" />}
0
+ describe "hidden_field" do
0
+ it "should create a nested hidden_field for a model" do
0
+ hidden_field(:cop, :full_name).should == %{<input id="cop_full_name" name="cop[full_name]" type="hidden" value="ness" />}
0
+ it "should create a non-nested hidden_field for a simple object" do
0
+ hidden_field(:simple).should == %{<input id="simple" name="simple" type="hidden" value="hi" />}
0
+ it "should create a non-nested hidden_field for just a symbol" do
0
+ hidden_field(:unknown).should == %{<input id="unknown" name="unknown" type="hidden" />}
0
+ it "should create a nested hidden_field for a model with an empty value if value is false" do
0
+ hidden_field(:cop, :full_name).should == %{<input id="cop_full_name" name="cop[full_name]" type="hidden" value="" />}
0
+ describe "password_field" do
0
+ it "should create a nested password_field for a model" do
0
+ password_field(:cop, :full_name).should == %{<input id="cop_full_name" name="cop[full_name]" type="password" value="ness" />}
0
+ it "should create a non-nested password_field for a simple object" do
0
+ password_field(:simple).should == %{<input id="simple" name="simple" type="password" value="hi" />}
0
+ it "should create a non-nested password_field for just a symbol" do
0
+ password_field(:unknown).should == %{<input id="unknown" name="unknown" type="password" />}
0
+ it "should create a nested password_field for a model with an empty value if value is false" do
0
+ password_field(:cop, :full_name).should == %{<input id="cop_full_name" name="cop[full_name]" type="password" value="" />}
0
+ describe "image_submit" do
0
+ it "should create an image submit tag" do
0
+ image_submit("login.png").should == %{<input src="/images/login.png" type="image" />}
0
+ image_submit("purchase.png", :disabled => true).should == %{<input disabled="disabled" src="/images/purchase.png" type="image" />}
0
+ image_submit("search.png", :class => 'search-button').should == %{<input class="search-button" src="/images/search.png" type="image" />}
0
+ it "should create a nested label for a model" do
0
+ label(:cop, :full_name).should == %{<label for="cop_full_name">Full name</label>}
0
+ it "should create a non-nested label for a simple object" do
0
+ label(:simple).should == %{<label for="simple">Simple</label>}
0
+ it "should create a non-nested label for just a symbol" do
0
+ label(:unknown).should == %{<label for="unknown">Unknown</label>}
0
+ it "should create a non-nested label for just a symbol" do
0
+ label(:unknown).should == %{<label for="unknown">Unknown</label>}
0
+ it "should create a non-nested label and use :value for it's content" do
0
+ label(:unknown, :value => "My Label").should == %{<label for="unknown">My Label</label>}
0
+ it "should create a non-nested label and use :for for it's for" do
0
+ label(:unknown, :for => "my_label").should == %{<label for="my_label">Unknown</label>}
0
+ describe "radio_button" do
0
+ it "should create a nested radio_button for a model" do
0
+ radio_button(:cop, :tos).should == %{<input id="cop_tos" name="cop[tos]" type="radio" />}
0
+ it "should create a non-nested radio_button for a simple object" do
0
+ radio_button(:simple).should == %{<input checked="checked" id="simple" name="simple" type="radio" />}
0
+ it "should create a non-nested radio_button for just a symbol" do
0
+ radio_button(:unknown).should == %{<input id="unknown" name="unknown" type="radio" />}
0
+ it "should be checked if the value is true" do
0
+ radio_button(:cop, :tos).should == %{<input checked="checked" id="cop_tos" name="cop[tos]" type="radio" />}
0
+ it "should be unchecked if the value is false" do
0
+ radio_button(:cop, :tos).should == %{<input id="cop_tos" name="cop[tos]" type="radio" />}
0
+ describe "text_area" do
0
+ it "should create a nested text_area for a model" do
0
+ text_area(:cop, :full_name).should == %{<textarea id="cop_full_name" name="cop[full_name]">ness</textarea>}
0
+ it "should create a non-nested text_area for a simple object" do
0
+ text_area(:simple).should == %{<textarea id="simple" name="simple">hi</textarea>}
0
+ it "should create a non-nested text_area for just a symbol" do
0
+ text_area(:unknown).should == %{<textarea id="unknown" name="unknown"></textarea>}
0
+ it "should create a nested text_area for a model with an empty value if value is false" do
0
+ text_area(:cop, :full_name).should == %{<textarea id="cop_full_name" name="cop[full_name]"></textarea>}
0
+ describe "text_field" do
0
+ it "should create a nested text_field for a model" do
0
+ text_field(:cop, :full_name).should == %{<input id="cop_full_name" name="cop[full_name]" type="text" value="ness" />}
0
+ it "should create a non-nested text_field for a simple object" do
0
+ text_field(:simple).should == %{<input id="simple" name="simple" type="text" value="hi" />}
0
+ it "should create a non-nested text_field for just a symbol" do
0
+ text_field(:unknown).should == %{<input id="unknown" name="unknown" type="text" />}
0
+ it "should create a nested text_field for a model with an empty value if value is false" do
0
+ text_field(:cop, :full_name).should == %{<input id="cop_full_name" name="cop[full_name]" type="text" value="" />}
0
@@ -43,18 +259,18 @@ Hello
0
- describe "submit
_tag" do
0
it "should build a simple submit tag" do
0
- submit
_tag.should == %{<input type="submit" value="Submit" />}
0
+ submit
.should == %{<input type="submit" value="Submit" />}
0
it "should allow you to change the value" do
0
- submit
_tag("Login").should == %{<input type="submit" value="Login" />}
0
+ submit
("Login").should == %{<input type="submit" value="Login" />}
0
it "should take options" do
0
- submit
_tag("Login", {:class => :foo}).should == %{<input class="foo" type="submit" value="Login" />}
0
+ submit
("Login", {:class => :foo}).should == %{<input class="foo" type="submit" value="Login" />}