/
button_action_spec.rb
63 lines (45 loc) · 1.37 KB
/
button_action_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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