Sha256: 712ea774f0da550a2a2a640c932b4d60d1ab21bff97b260b44017678ef3c5de4

Contents?: true

Size: 988 Bytes

Versions: 8

Compression:

Stored size: 988 Bytes

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")

describe Form do

  include Erector::Mixin

  it "defaults to POST, with no magic hidden method param" do
    Form.new(:action => "/foo").to_html.should == "<form action=\"/foo\" method=\"post\"></form>"
  end

  it "works plainly with GET too" do
    Form.new(:action => "/foo", :method => "get").to_html.should == "<form action=\"/foo\" method=\"get\"></form>"
  end
  
  it "uses POST and adds a magic hidden field with a _method param for DELETE" do
    Form.new(:action => "/foo", :method => "delete").to_html.should ==
      "<form action=\"/foo\" method=\"post\">"+
      "<input name=\"_method\" type=\"hidden\" value=\"delete\" />"+
      "</form>"
  end

  it "executes its block in the caller's 'self' context" do
    erector {
      @pet = "dog"
      widget(Form.new(:action => "/foo") do
        p @pet
      end)  
    }.should == "<form action=\"/foo\" method=\"post\"><p>dog</p></form>"
  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
erector-0.10.0 spec/erector/widgets/form_spec.rb
erector-0.9.0 spec/erector/widgets/form_spec.rb
erector-0.9.0.pre1 spec/erector/widgets/form_spec.rb
erector-0.8.3 spec/erector/widgets/form_spec.rb
erector-0.8.2 spec/erector/widgets/form_spec.rb
honkster-erector-0.8.1 spec/erector/widgets/form_spec.rb
erector-0.8.1 spec/erector/widgets/form_spec.rb
erector-0.8.0 spec/erector/widgets/form_spec.rb