Sha256: 4e6257d17cef3144bd2e47c3d90615493af2c0957138d8006ad20cb4811aeccc

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'phone input' do

  include FormtasticSpecHelper

  before do
    @output_buffer = ''
    mock_everything
  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(:input)
    it_should_have_input_wrapper_with_class(:stringish)
    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
      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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
formtastic-2.0.0.rc4 spec/inputs/phone_input_spec.rb
formtastic-2.0.0.rc3 spec/inputs/phone_input_spec.rb
formtastic-2.0.0.rc2 spec/inputs/phone_input_spec.rb
formtastic-2.0.0.rc1 spec/inputs/phone_input_spec.rb