Sha256: 40e36293fa3c948848414ce8438b7b3ab1805f6d860fac512e57f16fc05114f3

Contents?: true

Size: 1.71 KB

Versions: 9

Compression:

Stored size: 1.71 KB

Contents

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

describe 'hidden input' do
  
  include FormtasticSpecHelper
  
  before do
    @output_buffer = ''
    mock_everything
    
    semantic_form_for(@new_post) do |builder|
      concat(builder.input(:secret, :as => :hidden))
      concat(builder.input(:author_id, :as => :hidden, :value => 99))
      concat(builder.input(:published, :as => :hidden, :input_html => {:value => true}))
    end
  end

  it_should_have_input_wrapper_with_class("hidden")
  it_should_have_input_wrapper_with_id("post_secret_input")
  it_should_not_have_a_label

  it "should generate a input field" do
    output_buffer.should have_tag("form li input#post_secret")
    output_buffer.should have_tag("form li input#post_secret[@type=\"hidden\"]")
    output_buffer.should have_tag("form li input#post_secret[@name=\"post[secret]\"]")
  end
  
  it "should pass any explicitly specified value - using :value" do
    output_buffer.should have_tag("form li input#post_author_id[@type=\"hidden\"][@value=\"99\"]")
  end
  
  # Handle Formtastic :input_html options for consistency.
  it "should pass any explicitly specified value - using :input_html options" do
    output_buffer.should have_tag("form li input#post_published[@type=\"hidden\"][@value=\"true\"]")
  end
  
  it "should not render inline errors" do
    @errors = mock('errors')
    @errors.stub!(:[]).with(:secret).and_return(["foo", "bah"])
    @new_post.stub!(:errors).and_return(@errors)
    
    semantic_form_for(@new_post) do |builder|
      concat(builder.input(:secret, :as => :hidden))
    end
    
    output_buffer.should_not have_tag("form li p.inline-errors")
    output_buffer.should_not have_tag("form li ul.errors")
  end
    
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
jintastic-1.1.0 vendor/plugins/formtastic/spec/inputs/hidden_input_spec.rb
jintastic-1.0.2 vendor/plugins/formtastic/spec/inputs/hidden_input_spec.rb
tmayad-formtastic-0.9.7 spec/inputs/hidden_input_spec.rb
ShadowBelmolve-formtastic-0.9.7 spec/inputs/hidden_input_spec.rb
formtastic-0.9.7 spec/inputs/hidden_input_spec.rb
formtastic-0.9.6 spec/inputs/hidden_input_spec.rb
formtastic-0.9.5 spec/inputs/hidden_input_spec.rb
formtastic-0.9.4 spec/inputs/hidden_input_spec.rb
formtastic-0.9.3 spec/inputs/hidden_input_spec.rb