Sha256: 551b94f543dca840f4e585a84835858230e1d9386c995a5aee35a9b2611ea48e

Contents?: true

Size: 1.61 KB

Versions: 12

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'phone input' do

  include FormtasticSpecHelper

  before do
    @output_buffer = ''
    mock_everything
    Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
  end

  describe "when object is provided" do
    before do
      concat(semantic_form_for(@new_post) do |builder|
        concat(builder.input(:phone))
      end)
    end

    it_should_have_input_wrapper_with_class(:phone)
    it_should_have_input_wrapper_with_class(:clearfix)
    it_should_have_input_wrapper_with_class(:stringish)
    it_should_have_input_class_in_the_right_place
    it_should_have_input_wrapper_with_id("post_phone_input")
    it_should_have_label_with_text(/Phone/)
    it_should_have_label_for("post_phone")
    it_should_have_input_with_id("post_phone")
    it_should_have_input_with_type(:tel)
    it_should_have_input_with_name("post[phone]")

  end

  describe "when namespace is provided" do

    before do
      concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
        concat(builder.input(:phone))
      end)
    end

    it_should_have_input_wrapper_with_id("context2_post_phone_input")
    it_should_have_label_and_input_with_id("context2_post_phone")

  end
  
  describe "when required" do
    it "should add the required attribute to the input's html options" do
      with_config :use_required_attribute, true do 
        concat(semantic_form_for(@new_post) do |builder|
          concat(builder.input(:title, :as => :phone, :required => true))
        end)
        output_buffer.should have_tag("input[@required]")
      end
    end
  end
  
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
speedo-formstrap-1.2.7 spec/inputs/phone_input_spec.rb
speedo-formstrap-1.2.6 spec/inputs/phone_input_spec.rb
speedo-formstrap-1.2.5 spec/inputs/phone_input_spec.rb
speedo-formstrap-1.2.4 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.2.0 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.1.2 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.1.1 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.1.0 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.0.3 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.0.2 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.0.1 spec/inputs/phone_input_spec.rb
formtastic-bootstrap-1.0.0 spec/inputs/phone_input_spec.rb