Sha256: b8230fd2c9c35c5c0f11e4d507cf92b594ccc6d332e3aa14a607034018e22461

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'LinkAction', 'when cancelling' do

  include FormtasticSpecHelper

  before do
    @output_buffer = ''
    mock_everything
  end
  
  context 'without a :url' do
    before do
      concat(semantic_form_for(@new_post) do |builder|
        concat(builder.action(:cancel, :as => :link))
      end)
    end
    
    it 'should render a submit type of input' do
      output_buffer.should have_tag('a[@href="javascript:history.back()"].btn')
    end
    
  end
  
  context 'with a :url as String' do
    
    before do
      concat(semantic_form_for(@new_post) do |builder|
        concat(builder.action(:cancel, :as => :link, :url => "http://foo.bah/baz"))
      end)
    end
    
    it 'should render a submit type of input' do
      output_buffer.should have_tag('a[@href="http://foo.bah/baz"].btn')
    end
    
  end

  context 'with a :url as Hash' do
    
    before do
      concat(semantic_form_for(@new_post) do |builder|
        concat(builder.action(:cancel, :as => :link, :url => { :action => "foo" }))
      end)
    end
    
    it 'should render a submit type of input' do
      output_buffer.should have_tag('a[@href="/mock/path"].btn')
    end
    
  end

end

describe 'LinkAction', 'when submitting' 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(:submit, :as => :link))
      end)
    }.should raise_error(Formtastic::UnsupportedMethodForAction)
  end
  
end

describe 'LinkAction', 'when submitting' 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(:reset, :as => :link))
      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/link_action_spec.rb