Sha256: b4305dad24ae199458af30e3171f260bcd720f5aae9075969e014c2d5fcc9c4c

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'file input' do

  include FormtasticSpecHelper

  before do
    @output_buffer = ''
    mock_everything

    concat(semantic_form_for(@new_post) do |builder|
      concat(builder.input(:body, :as => :file))
    end)
  end

  it_should_have_input_wrapper_with_class("file")
  it_should_have_input_wrapper_with_class(:input)
  it_should_have_input_wrapper_with_id("post_body_input")
  it_should_have_label_with_text(/Body/)
  it_should_have_label_for("post_body")
  it_should_have_input_with_id("post_body")
  it_should_have_input_with_name("post[body]")
  it_should_apply_error_logic_for_input_type(:file)

  it 'should use input_html to style inputs' do
    concat(semantic_form_for(@new_post) do |builder|
      concat(builder.input(:title, :as => :file, :input_html => { :class => 'myclass' }))
    end)
    output_buffer.should have_tag("form li input.myclass")
  end

  describe "when namespace is provided" do

    before do
      @output_buffer = ''
      mock_everything

      concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
        concat(builder.input(:body, :as => :file))
      end)
    end

    it_should_have_input_wrapper_with_id("context2_post_body_input")
    it_should_have_label_and_input_with_id("context2_post_body")

  end
  
  context "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 => :file, :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/file_input_spec.rb
formtastic-2.0.0.rc3 spec/inputs/file_input_spec.rb
formtastic-2.0.0.rc2 spec/inputs/file_input_spec.rb
formtastic-2.0.0.rc1 spec/inputs/file_input_spec.rb