ShadowBelmolve-formtastic 0.2.1 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/README.textile +191 -176
  2. data/Rakefile +65 -22
  3. data/generators/form/USAGE +16 -0
  4. data/generators/form/form_generator.rb +120 -0
  5. data/generators/form/templates/view__form.html.erb +5 -0
  6. data/generators/form/templates/view__form.html.haml +4 -0
  7. data/generators/formtastic/formtastic_generator.rb +24 -0
  8. data/generators/{formtastic_stylesheets → formtastic}/templates/formtastic.css +2 -0
  9. data/generators/formtastic/templates/formtastic.rb +51 -0
  10. data/generators/{formtastic_stylesheets → formtastic}/templates/formtastic_changes.css +0 -0
  11. data/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +5 -10
  12. data/lib/formtastic.rb +1234 -895
  13. data/lib/formtastic/i18n.rb +32 -0
  14. data/lib/locale/en.yml +2 -2
  15. data/rails/init.rb +1 -1
  16. data/spec/buttons_spec.rb +149 -0
  17. data/spec/commit_button_spec.rb +344 -0
  18. data/spec/custom_builder_spec.rb +62 -0
  19. data/spec/custom_macros.rb +561 -0
  20. data/spec/defaults_spec.rb +20 -0
  21. data/spec/error_proc_spec.rb +27 -0
  22. data/spec/errors_spec.rb +85 -0
  23. data/spec/form_helper_spec.rb +120 -0
  24. data/spec/i18n_spec.rb +131 -0
  25. data/spec/include_blank_spec.rb +70 -0
  26. data/spec/input_spec.rb +608 -0
  27. data/spec/inputs/boolean_input_spec.rb +93 -0
  28. data/spec/inputs/check_boxes_input_spec.rb +162 -0
  29. data/spec/inputs/country_input_spec.rb +80 -0
  30. data/spec/inputs/date_input_spec.rb +45 -0
  31. data/spec/inputs/datetime_input_spec.rb +155 -0
  32. data/spec/inputs/file_input_spec.rb +33 -0
  33. data/spec/inputs/hidden_input_spec.rb +52 -0
  34. data/spec/inputs/numeric_input_spec.rb +44 -0
  35. data/spec/inputs/password_input_spec.rb +46 -0
  36. data/spec/inputs/radio_input_spec.rb +149 -0
  37. data/spec/inputs/select_input_spec.rb +459 -0
  38. data/spec/inputs/string_input_spec.rb +47 -0
  39. data/spec/inputs/text_input_spec.rb +33 -0
  40. data/spec/inputs/time_input_spec.rb +44 -0
  41. data/spec/inputs/time_zone_input_spec.rb +102 -0
  42. data/spec/inputs_spec.rb +395 -0
  43. data/spec/label_spec.rb +48 -0
  44. data/spec/nested_forms_spec.rb +50 -0
  45. data/spec/semantic_fields_for_spec.rb +44 -0
  46. data/spec/spec.opts +2 -0
  47. data/spec/spec_helper.rb +212 -0
  48. metadata +121 -16
  49. data/lib/justin_french/formtastic.rb +0 -10
  50. data/spec/formtastic_spec.rb +0 -3072
  51. data/spec/test_helper.rb +0 -14
@@ -0,0 +1,93 @@
1
+ # coding: utf-8
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
4
+ describe 'boolean input' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ before do
9
+ @output_buffer = ''
10
+ mock_everything
11
+
12
+ semantic_form_for(@new_post) do |builder|
13
+ concat(builder.input(:allow_comments, :as => :boolean))
14
+ end
15
+ end
16
+
17
+ it_should_have_input_wrapper_with_class("boolean")
18
+ it_should_have_input_wrapper_with_id("post_allow_comments_input")
19
+ it_should_apply_error_logic_for_input_type(:boolean)
20
+
21
+ it 'should generate a label containing the input' do
22
+ output_buffer.should have_tag('form li label', :count => 1)
23
+ output_buffer.should have_tag('form li label[@for="post_allow_comments"]')
24
+ output_buffer.should have_tag('form li label', /Allow comments/)
25
+ output_buffer.should have_tag('form li label input[@type="checkbox"]')
26
+ end
27
+
28
+ it 'should generate a checkbox input' do
29
+ output_buffer.should have_tag('form li label input')
30
+ output_buffer.should have_tag('form li label input#post_allow_comments')
31
+ output_buffer.should have_tag('form li label input[@type="checkbox"]')
32
+ output_buffer.should have_tag('form li label input[@name="post[allow_comments]"]')
33
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="1"]')
34
+ end
35
+
36
+ it 'should allow checked and unchecked values to be sent' do
37
+ semantic_form_for(@new_post) do |builder|
38
+ concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'checked', :unchecked_value => 'unchecked'))
39
+ end
40
+
41
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="checked"]')
42
+ output_buffer.should have_tag('form li label input[@type="hidden"][@value="unchecked"]')
43
+ end
44
+
45
+ it 'should generate a label and a checkbox even if no object is given' do
46
+ semantic_form_for(:project, :url => 'http://test.host') do |builder|
47
+ concat(builder.input(:allow_comments, :as => :boolean))
48
+ end
49
+
50
+ output_buffer.should have_tag('form li label[@for="project_allow_comments"]')
51
+ output_buffer.should have_tag('form li label', /Allow comments/)
52
+ output_buffer.should have_tag('form li label input[@type="checkbox"]')
53
+
54
+ output_buffer.should have_tag('form li label input#project_allow_comments')
55
+ output_buffer.should have_tag('form li label input[@type="checkbox"]')
56
+ output_buffer.should have_tag('form li label input[@name="project[allow_comments]"]')
57
+ end
58
+
59
+ describe 'when :selected is set' do
60
+ before do
61
+ @output_buffer = ''
62
+ end
63
+
64
+ describe "not selected" do
65
+ before do
66
+ @new_post.stub!(:allow_comments).and_return(true)
67
+
68
+ semantic_form_for(@new_post) do |builder|
69
+ concat(builder.input(:allow_comments, :as => :boolean, :selected => false))
70
+ end
71
+ end
72
+
73
+ it 'should not be selected' do
74
+ output_buffer.should_not have_tag("form li label input[@type='checkbox'][@checked='checked']")
75
+ end
76
+ end
77
+
78
+ describe "selected" do
79
+ before do
80
+ @new_post.stub!(:allow_comments).and_return(false)
81
+
82
+ semantic_form_for(@new_post) do |builder|
83
+ concat(builder.input(:allow_comments, :as => :boolean, :selected => true))
84
+ end
85
+ end
86
+
87
+ it 'should be selected' do
88
+ output_buffer.should have_tag("form li label input[@type='checkbox'][@checked='checked']")
89
+ end
90
+ end
91
+ end
92
+
93
+ end
@@ -0,0 +1,162 @@
1
+ # coding: utf-8
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
4
+ describe 'check_boxes input' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ describe 'for a has_many association' do
9
+ before do
10
+ @output_buffer = ''
11
+ mock_everything
12
+
13
+ semantic_form_for(@fred) do |builder|
14
+ concat(builder.input(:posts, :as => :check_boxes, :value_as_class => true))
15
+ end
16
+ end
17
+
18
+ it_should_have_input_wrapper_with_class("check_boxes")
19
+ it_should_have_input_wrapper_with_id("author_posts_input")
20
+ it_should_have_a_nested_fieldset
21
+ it_should_apply_error_logic_for_input_type(:check_boxes)
22
+ it_should_call_find_on_association_class_when_no_collection_is_provided(:check_boxes)
23
+ it_should_use_the_collection_when_provided(:check_boxes, 'input[@type="checkbox"]')
24
+
25
+ it 'should generate a legend - classified as a label - containing label text for the input' do
26
+ output_buffer.should have_tag('form li fieldset legend.label')
27
+ output_buffer.should have_tag('form li fieldset legend.label', /Posts/)
28
+ end
29
+
30
+ it 'should generate an ordered list with a list item for each choice' do
31
+ output_buffer.should have_tag('form li fieldset ol')
32
+ output_buffer.should have_tag('form li fieldset ol li', :count => ::Post.find(:all).size)
33
+ end
34
+
35
+ it 'should have one option with a "checked" attribute' do
36
+ output_buffer.should have_tag('form li input[@checked]', :count => 1)
37
+ end
38
+
39
+ it 'should generate hidden inputs with default value blank' do
40
+ output_buffer.should have_tag("form li fieldset ol li label input[@type='hidden'][@value='']", :count => ::Post.find(:all).size)
41
+ end
42
+
43
+ describe "each choice" do
44
+
45
+ it 'should contain a label for the radio input with a nested input and label text' do
46
+ ::Post.find(:all).each do |post|
47
+ output_buffer.should have_tag('form li fieldset ol li label', /#{post.to_label}/)
48
+ output_buffer.should have_tag("form li fieldset ol li label[@for='author_post_ids_#{post.id}']")
49
+ end
50
+ end
51
+
52
+ it 'should use values as li.class when value_as_class is true' do
53
+ ::Post.find(:all).each do |post|
54
+ output_buffer.should have_tag("form li fieldset ol li.post_#{post.id} label")
55
+ end
56
+ end
57
+
58
+ it 'should have a checkbox input for each post' do
59
+ ::Post.find(:all).each do |post|
60
+ output_buffer.should have_tag("form li fieldset ol li label input#author_post_ids_#{post.id}")
61
+ output_buffer.should have_tag("form li fieldset ol li label input[@name='author[post_ids][]']", :count => 2)
62
+ end
63
+ end
64
+
65
+ it "should mark input as checked if it's the the existing choice" do
66
+ ::Post.find(:all).include?(@fred.posts.first).should be_true
67
+ output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked']")
68
+ end
69
+ end
70
+
71
+ describe 'and no object is given' do
72
+ before(:each) do
73
+ output_buffer.replace ''
74
+ semantic_form_for(:project, :url => 'http://test.host') do |builder|
75
+ concat(builder.input(:author_id, :as => :check_boxes, :collection => ::Author.find(:all)))
76
+ end
77
+ end
78
+
79
+ it 'should generate a fieldset with legend' do
80
+ output_buffer.should have_tag('form li fieldset legend', /Author/)
81
+ end
82
+
83
+ it 'shold generate an li tag for each item in the collection' do
84
+ output_buffer.should have_tag('form li fieldset ol li', :count => ::Author.find(:all).size)
85
+ end
86
+
87
+ it 'should generate labels for each item' do
88
+ ::Author.find(:all).each do |author|
89
+ output_buffer.should have_tag('form li fieldset ol li label', /#{author.to_label}/)
90
+ output_buffer.should have_tag("form li fieldset ol li label[@for='project_author_id_#{author.id}']")
91
+ end
92
+ end
93
+
94
+ it 'should generate inputs for each item' do
95
+ ::Author.find(:all).each do |author|
96
+ output_buffer.should have_tag("form li fieldset ol li label input#project_author_id_#{author.id}")
97
+ output_buffer.should have_tag("form li fieldset ol li label input[@type='checkbox']")
98
+ output_buffer.should have_tag("form li fieldset ol li label input[@value='#{author.id}']")
99
+ output_buffer.should have_tag("form li fieldset ol li label input[@name='project[author_id][]']")
100
+ end
101
+ end
102
+ end
103
+
104
+ describe 'when :selected is set' do
105
+ before do
106
+ @output_buffer = ''
107
+ end
108
+
109
+ describe "no selected items" do
110
+ before do
111
+ @new_post.stub!(:author_ids).and_return(nil)
112
+
113
+ semantic_form_for(@new_post) do |builder|
114
+ concat(builder.input(:authors, :as => :check_boxes, :selected => nil))
115
+ end
116
+ end
117
+
118
+ it 'should not have any selected item(s)' do
119
+ output_buffer.should_not have_tag("form li fieldset ol li label input[@checked='checked']")
120
+ end
121
+ end
122
+
123
+ describe "single selected item" do
124
+ before do
125
+ @new_post.stub!(:author_ids).and_return(nil)
126
+
127
+ semantic_form_for(@new_post) do |builder|
128
+ concat(builder.input(:authors, :as => :check_boxes, :selected => @fred.id))
129
+ end
130
+ end
131
+
132
+ it "should have one item selected; the specified one" do
133
+ output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked']", :count => 1)
134
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_ids_#{@fred.id}']", /fred/i)
135
+ output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked'][@value='#{@fred.id}']")
136
+ end
137
+ end
138
+
139
+ describe "multiple selected items" do
140
+ before do
141
+ @new_post.stub!(:author_ids).and_return(nil)
142
+
143
+ semantic_form_for(@new_post) do |builder|
144
+ concat(builder.input(:authors, :as => :check_boxes, :selected => [@bob.id, @fred.id]))
145
+ end
146
+ end
147
+
148
+ it "should have multiple items selected; the specified ones" do
149
+ output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked']", :count => 2)
150
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_ids_#{@bob.id}']", /bob/i)
151
+ output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked'][@value='#{@bob.id}']")
152
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_ids_#{@fred.id}']", /fred/i)
153
+ output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked'][@value='#{@fred.id}']")
154
+ end
155
+ end
156
+
157
+ end
158
+
159
+ end
160
+
161
+ end
162
+
@@ -0,0 +1,80 @@
1
+ # coding: utf-8
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
4
+ describe 'country input' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ before do
9
+ @output_buffer = ''
10
+ mock_everything
11
+ end
12
+
13
+ describe "when country_select is not available as a helper from a plugin" do
14
+
15
+ it "should raise an error, sugesting the author installs a plugin" do
16
+ lambda {
17
+ semantic_form_for(@new_post) do |builder|
18
+ concat(builder.input(:country, :as => :country))
19
+ end
20
+ }.should raise_error
21
+ end
22
+
23
+ end
24
+
25
+ describe "when country_select is available as a helper (from a plugin)" do
26
+
27
+ before do
28
+ semantic_form_for(@new_post) do |builder|
29
+ builder.stub!(:country_select).and_return("<select><option>...</option></select>")
30
+ concat(builder.input(:country, :as => :country))
31
+ end
32
+ end
33
+
34
+ it_should_have_input_wrapper_with_class("country")
35
+ it_should_have_input_wrapper_with_id("post_country_input")
36
+
37
+ # TODO -- needs stubbing inside the builder block, tricky!
38
+ #it_should_apply_error_logic_for_input_type(:country)
39
+
40
+ it 'should generate a label for the input' do
41
+ output_buffer.should have_tag('form li label')
42
+ output_buffer.should have_tag('form li label[@for="post_country"]')
43
+ output_buffer.should have_tag('form li label', /Country/)
44
+ end
45
+
46
+ it "should generate a select" do
47
+ output_buffer.should have_tag("form li select")
48
+ end
49
+
50
+ end
51
+
52
+ describe ":priority_countries option" do
53
+
54
+ it "should be passed down to the country_select helper when provided" do
55
+ priority_countries = ["Foo", "Bah"]
56
+ semantic_form_for(@new_post) do |builder|
57
+ builder.stub!(:country_select).and_return("<select><option>...</option></select>")
58
+ builder.should_receive(:country_select).with(:country, priority_countries, {}, {}).and_return("<select><option>...</option></select>")
59
+
60
+ concat(builder.input(:country, :as => :country, :priority_countries => priority_countries))
61
+ end
62
+ end
63
+
64
+ it "should default to the @@priority_countries config when absent" do
65
+ priority_countries = ::Formtastic::SemanticFormBuilder.priority_countries
66
+ priority_countries.should_not be_empty
67
+ priority_countries.should_not be_nil
68
+
69
+ semantic_form_for(@new_post) do |builder|
70
+ builder.stub!(:country_select).and_return("<select><option>...</option></select>")
71
+ builder.should_receive(:country_select).with(:country, priority_countries, {}, {}).and_return("<select><option>...</option></select>")
72
+
73
+ concat(builder.input(:country, :as => :country))
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+ end
80
+
@@ -0,0 +1,45 @@
1
+ # coding: utf-8
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
4
+ describe 'date input' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ before do
9
+ @output_buffer = ''
10
+ mock_everything
11
+
12
+ semantic_form_for(@new_post) do |builder|
13
+ concat(builder.input(:publish_at, :as => :date))
14
+ end
15
+ end
16
+
17
+ it_should_have_input_wrapper_with_class("date")
18
+ it_should_have_input_wrapper_with_id("post_publish_at_input")
19
+ it_should_have_a_nested_fieldset
20
+ it_should_apply_error_logic_for_input_type(:date)
21
+
22
+ it 'should have a legend - classified as a label - containing the label text inside the fieldset' do
23
+ output_buffer.should have_tag('form li.date fieldset legend.label', /Publish at/)
24
+ end
25
+
26
+ it 'should have an ordered list of three items inside the fieldset' do
27
+ output_buffer.should have_tag('form li.date fieldset ol')
28
+ output_buffer.should have_tag('form li.date fieldset ol li', :count => 3)
29
+ end
30
+
31
+ it 'should have three labels for year, month and day' do
32
+ output_buffer.should have_tag('form li.date fieldset ol li label', :count => 3)
33
+ output_buffer.should have_tag('form li.date fieldset ol li label', /year/i)
34
+ output_buffer.should have_tag('form li.date fieldset ol li label', /month/i)
35
+ output_buffer.should have_tag('form li.date fieldset ol li label', /day/i)
36
+ end
37
+
38
+ it 'should have three selects for year, month and day' do
39
+ output_buffer.should have_tag('form li.date fieldset ol li select', :count => 3)
40
+ end
41
+
42
+ it_should_select_existing_datetime_else_current(:year, :month, :day)
43
+ it_should_select_explicit_default_value_if_set(:year, :month, :day)
44
+
45
+ end
@@ -0,0 +1,155 @@
1
+ # coding: utf-8
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
4
+ describe 'datetime input' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ before do
9
+ @output_buffer = ''
10
+ mock_everything
11
+
12
+ @new_post.should_receive(:publish_at=).any_number_of_times
13
+ @new_post.should_receive(:created_at=).any_number_of_times
14
+ @bob.should_receive(:created_at=).any_number_of_times
15
+ @new_post.should_receive(:title=).any_number_of_times # Macro stuff forces this.
16
+
17
+ semantic_form_for(@new_post) do |builder|
18
+ concat(builder.input(:publish_at, :as => :datetime))
19
+ end
20
+ end
21
+
22
+ it_should_have_input_wrapper_with_class("datetime")
23
+ it_should_have_input_wrapper_with_id("post_publish_at_input")
24
+ it_should_have_a_nested_fieldset
25
+ it_should_apply_error_logic_for_input_type(:datetime)
26
+
27
+ it 'should have a legend containing the label text inside the fieldset' do
28
+ output_buffer.should have_tag('form li.datetime fieldset legend', /Publish at/)
29
+ end
30
+
31
+ it 'should have an ordered list of five items inside the fieldset' do
32
+ output_buffer.should have_tag('form li.datetime fieldset ol')
33
+ output_buffer.should have_tag('form li.datetime fieldset ol li', :count => 5)
34
+ end
35
+
36
+ it 'should have five labels for year, month, day, hour and minute' do
37
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', :count => 5)
38
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /year/i)
39
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /month/i)
40
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /day/i)
41
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /hour/i)
42
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /minute/i)
43
+ end
44
+
45
+ it 'should have five selects for year, month, day, hour and minute' do
46
+ output_buffer.should have_tag('form li.datetime fieldset ol li select', :count => 5)
47
+ end
48
+
49
+ it 'should generate a sanitized label and matching ids for attribute' do
50
+ semantic_form_for(@new_post) do |builder|
51
+ builder.semantic_fields_for(@bob, :index => 10) do |bob_builder|
52
+ concat(bob_builder.input(:created_at, :as => :datetime))
53
+ end
54
+ end
55
+
56
+ 1.upto(5) do |i|
57
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_10_created_at_#{i}i']")
58
+ output_buffer.should have_tag("form li fieldset ol li #post_author_10_created_at_#{i}i")
59
+ end
60
+ end
61
+
62
+ it_should_select_existing_datetime_else_current(:year, :month, :day, :hour, :minute, :second)
63
+ it_should_select_explicit_default_value_if_set(:year, :month, :day, :hour, :minute, :second)
64
+
65
+ describe 'when :discard_input => true is set' do
66
+ it 'should use default attribute value when it is not nil' do
67
+ @new_post.stub!(:publish_at).and_return(Date.new(2007,12,27))
68
+ semantic_form_for(@new_post) do |builder|
69
+ concat(builder.input(:publish_at, :as => :datetime, :discard_day => true))
70
+ end
71
+
72
+ output_buffer.should have_tag("form li input[@type='hidden'][@value='27']")
73
+ end
74
+ end
75
+
76
+ describe 'inputs order' do
77
+ it 'should have a default' do
78
+ semantic_form_for(@new_post) do |builder|
79
+ self.should_receive(:select_year).once.ordered.and_return('')
80
+ self.should_receive(:select_month).once.ordered.and_return('')
81
+ self.should_receive(:select_day).once.ordered.and_return('')
82
+ builder.input(:publish_at, :as => :datetime)
83
+ end
84
+ end
85
+
86
+ it 'should be specified with :order option' do
87
+ ::I18n.backend.store_translations 'en', :date => { :order => [:month, :year, :day] }
88
+ semantic_form_for(@new_post) do |builder|
89
+ self.should_receive(:select_month).once.ordered.and_return('')
90
+ self.should_receive(:select_year).once.ordered.and_return('')
91
+ self.should_receive(:select_day).once.ordered.and_return('')
92
+ builder.input(:publish_at, :as => :datetime)
93
+ end
94
+ end
95
+
96
+ it 'should be changed through I18n' do
97
+ semantic_form_for(@new_post) do |builder|
98
+ self.should_receive(:select_day).once.ordered.and_return('')
99
+ self.should_receive(:select_month).once.ordered.and_return('')
100
+ self.should_receive(:select_year).once.ordered.and_return('')
101
+ builder.input(:publish_at, :as => :datetime, :order => [:day, :month, :year])
102
+ end
103
+ end
104
+ end
105
+
106
+ describe 'when the locale changes the label text' do
107
+ before do
108
+ ::I18n.backend.store_translations 'en', :datetime => {:prompts => {
109
+ :year => 'The Year', :month => 'The Month', :day => 'The Day',
110
+ :hour => 'The Hour', :minute => 'The Minute'
111
+ }}
112
+ semantic_form_for(@new_post) do |builder|
113
+ concat(builder.input(:publish_at, :as => :datetime))
114
+ end
115
+ end
116
+
117
+ after do
118
+ ::I18n.backend.store_translations 'en', :formtastic => {
119
+ :year => nil, :month => nil, :day => nil,
120
+ :hour => nil, :minute => nil
121
+ }
122
+ end
123
+
124
+ it 'should have translated labels for year, month, day, hour and minute' do
125
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Year/)
126
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Month/)
127
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Day/)
128
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Hour/)
129
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', /The Minute/)
130
+ end
131
+ end
132
+
133
+ describe 'when no object is given' do
134
+ before(:each) do
135
+ output_buffer.replace ''
136
+ semantic_form_for(:project, :url => 'http://test.host') do |builder|
137
+ concat(builder.input(:publish_at, :as => :datetime))
138
+ end
139
+ end
140
+
141
+ it 'should have fieldset with legend - classified as a label' do
142
+ output_buffer.should have_tag('form li.datetime fieldset legend.label', /Publish at/)
143
+ end
144
+
145
+ it 'should have labels for each input' do
146
+ output_buffer.should have_tag('form li.datetime fieldset ol li label', :count => 5)
147
+ end
148
+
149
+ it 'should have selects for each inputs' do
150
+ output_buffer.should have_tag('form li.datetime fieldset ol li select', :count => 5)
151
+ end
152
+ end
153
+
154
+ end
155
+