Sha256: d7a28f3489c48761bf676322420c32759e6fc922612968b913f113a3839c1248

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require "spec_helper"

describe Form::Component::TextArea do
  context "with defaults" do
    let(:form) { mock(:base_name => nil, :data => nil) }
    subject { described_class.new(form, :bio) }

    it "includes cols" do
      subject.attributes[:cols].should eql(50)
    end

    it "includes rows" do
      subject.attributes[:rows].should eql(5)
    end

    it "includes name" do
      subject.attributes[:name].should eql("bio")
    end

    it "returns html" do
      html = subject.to_html

      html.should have_tag(:textarea, :count => 1)
      html.should have_tag("[cols='50']")
      html.should have_tag("[rows='5']")
      html.should have_tag("[name='bio']")
    end
  end

  context "with custom options" do
    let(:form) { mock(:base_name => :user, :data => nil) }
    subject {
      described_class.new(form, :bio,
        :autofocus => true,
        :rows => 10,
        :cols => 25
      )
    }

    it "includes cols" do
      subject.attributes[:cols].should eql(25)
    end

    it "includes rows" do
      subject.attributes[:rows].should eql(10)
    end

    it "includes name" do
      subject.attributes[:name].should eql("user[bio]")
    end

    it "returns html" do
      html = subject.to_html

      html.should have_tag(:textarea, :count => 1)
      html.should have_tag("[cols='25']")
      html.should have_tag("[rows='10']")
      html.should have_tag("[name='user[bio]']")
      html.should have_tag("[autofocus]")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
form-0.0.1.alpha1 spec/form/component/text_area_spec.rb