Sha256: 488d296736404b546d6f8572d2273aa9f3f391dc31f35cc5c2990deb55adfd96

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

# coding: utf-8
require File.dirname(__FILE__) + '/spec_helper'

describe 'SemanticFormBuilder#label' do

  include FormtasticSpecHelper
  
  before do
    @output_buffer = ''
    mock_everything
  end

  it 'should humanize the given attribute' do
    semantic_form_for(@new_post) do |builder|
      builder.label(:login).should have_tag('label', :with => /Login/)
    end
  end

  describe 'when required is given' do
    it 'should append a required note' do
      semantic_form_for(@new_post) do |builder|
        builder.label(:login, nil, :required => true).should have_tag('label abbr')
      end
    end

    it 'should allow require option to be given as second argument' do
      semantic_form_for(@new_post) do |builder|
        builder.label(:login, :required => true).should have_tag('label abbr')
      end
    end
  end

  describe 'when label is given' do
    it 'should allow the text to be given as label option' do
      semantic_form_for(@new_post) do |builder|
        builder.label(:login, :required => true, :label => 'My label').should have_tag('label', :with => /My label/)
      end
    end

    it 'should return nil if label is false' do
      semantic_form_for(@new_post) do |builder|
        builder.label(:login, :label => false).should be_blank
      end
    end
  end
  
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
formtastic-rails3-0.9.10.1 spec/label_spec.rb
formtastic-1.0.0.beta spec/label_spec.rb
formtastic-rails3-0.9.10.0 spec/label_spec.rb
formtastic-0.9.10 spec/label_spec.rb
formtastic-0.9.9 spec/label_spec.rb
formtastic-0.9.8 spec/label_spec.rb
jintastic-1.1.0 vendor/plugins/formtastic/spec/label_spec.rb
jintastic-1.0.2 vendor/plugins/formtastic/spec/label_spec.rb
tmayad-formtastic-0.9.7 spec/label_spec.rb
ShadowBelmolve-formtastic-0.9.7 spec/label_spec.rb
formtastic-0.9.7 spec/label_spec.rb
formtastic-0.9.6 spec/label_spec.rb
formtastic-0.9.5 spec/label_spec.rb
formtastic-0.9.4 spec/label_spec.rb
formtastic-0.9.3 spec/label_spec.rb