Sha256: eecd50cc72918dd1c115833bd7bc1efc5bed672db636b23546c59774f94972fb

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 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('button[@type="submit"].btn')
  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('button[@type="reset"].btn', :text => "Reset Post")
  end

  it 'should not render a value attribute' do
    output_buffer.should_not have_tag('button[@value].btn')
  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

1 entries across 1 versions & 1 rubygems

Version Path
formtastic-bootstrap-2.0.0 spec/actions/button_action_spec.rb