Sha256: 82bf63bd2159ca13fd9564f2bf7f3f8730c11ece5db3ccdff67a1b90837691bb

Contents?: true

Size: 1.37 KB

Versions: 25

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'ButtonAction', 'when submitting' do

  include FormtasticSpecHelper

  before do
    @output_buffer = ''
    mock_everything
    
    concat(semantic_form_for(@new_post) do |builder|
      concat(builder.action(:submit, :as => :button))
    end)
  end
  
  it 'should render a submit type of button' do
    output_buffer.should have_tag('li.action.button_action button[@type="submit"]')
  end

end

describe 'ButtonAction', 'when resetting' do

  include FormtasticSpecHelper
  
  before do
    @output_buffer = ''
    mock_everything
    
    concat(semantic_form_for(@new_post) do |builder|
      concat(builder.action(:reset, :as => :button))
    end)
  end
  
  it 'should render a reset type of button' do
    output_buffer.should have_tag('li.action.button_action button[@type="reset"]', :text => "Reset Post")
  end

  it 'should not render a value attribute' do
    output_buffer.should_not have_tag('li.action.button_action button[@value]')
  end
  
end

describe 'InputAction', 'when cancelling' do

  include FormtasticSpecHelper
  
  before do
    @output_buffer = ''
    mock_everything
  end
  
  it 'should raise an error' do
    lambda { 
      concat(semantic_form_for(@new_post) do |builder|
        concat(builder.action(:cancel, :as => :button))
      end)
    }.should raise_error(Formtastic::UnsupportedMethodForAction)
  end
  
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
formtastic-2.2.0.rc spec/actions/button_action_spec.rb
formtastic-2.1.1 spec/actions/button_action_spec.rb
formtastic-2.1.0 spec/actions/button_action_spec.rb
formtastic-2.1.0.rc spec/actions/button_action_spec.rb
formtastic-2.1.0.beta1 spec/actions/button_action_spec.rb