formtastic 2.0.2 → 2.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.gitignore +4 -1
  2. data/Appraisals +11 -0
  3. data/CHANGELOG +2 -2
  4. data/Gemfile +0 -2
  5. data/README.textile +183 -151
  6. data/Rakefile +9 -5
  7. data/app/assets/stylesheets/formtastic.css +16 -3
  8. data/formtastic.gemspec +6 -2
  9. data/gemfiles/rails-3.0.gemfile +7 -0
  10. data/gemfiles/rails-3.1.gemfile +7 -0
  11. data/gemfiles/rails-3.2.gemfile +7 -0
  12. data/lib/formtastic.rb +10 -2
  13. data/lib/formtastic/actions.rb +11 -0
  14. data/lib/formtastic/actions/base.rb +156 -0
  15. data/lib/formtastic/actions/button_action.rb +72 -0
  16. data/lib/formtastic/actions/buttonish.rb +17 -0
  17. data/lib/formtastic/actions/input_action.rb +68 -0
  18. data/lib/formtastic/actions/link_action.rb +87 -0
  19. data/lib/formtastic/engine.rb +5 -1
  20. data/lib/formtastic/form_builder.rb +3 -0
  21. data/lib/formtastic/helpers.rb +2 -1
  22. data/lib/formtastic/helpers/action_helper.rb +109 -0
  23. data/lib/formtastic/helpers/actions_helper.rb +168 -0
  24. data/lib/formtastic/helpers/buttons_helper.rb +22 -9
  25. data/lib/formtastic/helpers/errors_helper.rb +0 -54
  26. data/lib/formtastic/helpers/fieldset_wrapper.rb +10 -5
  27. data/lib/formtastic/helpers/form_helper.rb +2 -2
  28. data/lib/formtastic/helpers/input_helper.rb +1 -10
  29. data/lib/formtastic/helpers/inputs_helper.rb +6 -3
  30. data/lib/formtastic/i18n.rb +3 -2
  31. data/lib/formtastic/inputs/base.rb +11 -3
  32. data/lib/formtastic/inputs/base/choices.rb +6 -1
  33. data/lib/formtastic/inputs/base/collections.rb +36 -13
  34. data/lib/formtastic/inputs/base/grouped_collections.rb +1 -1
  35. data/lib/formtastic/inputs/base/numeric.rb +50 -0
  36. data/lib/formtastic/inputs/base/options.rb +1 -1
  37. data/lib/formtastic/inputs/base/placeholder.rb +17 -0
  38. data/lib/formtastic/inputs/base/stringish.rb +2 -7
  39. data/lib/formtastic/inputs/base/timeish.rb +21 -5
  40. data/lib/formtastic/inputs/base/validations.rb +1 -1
  41. data/lib/formtastic/inputs/base/wrapping.rb +10 -3
  42. data/lib/formtastic/inputs/boolean_input.rb +10 -2
  43. data/lib/formtastic/inputs/check_boxes_input.rb +18 -9
  44. data/lib/formtastic/inputs/country_input.rb +2 -2
  45. data/lib/formtastic/inputs/date_input.rb +19 -1
  46. data/lib/formtastic/inputs/datetime_input.rb +1 -1
  47. data/lib/formtastic/inputs/email_input.rb +2 -1
  48. data/lib/formtastic/inputs/file_input.rb +1 -1
  49. data/lib/formtastic/inputs/hidden_input.rb +1 -1
  50. data/lib/formtastic/inputs/number_input.rb +6 -36
  51. data/lib/formtastic/inputs/password_input.rb +2 -1
  52. data/lib/formtastic/inputs/phone_input.rb +3 -2
  53. data/lib/formtastic/inputs/radio_input.rb +1 -1
  54. data/lib/formtastic/inputs/range_input.rb +8 -32
  55. data/lib/formtastic/inputs/search_input.rb +2 -1
  56. data/lib/formtastic/inputs/select_input.rb +56 -28
  57. data/lib/formtastic/inputs/string_input.rb +3 -1
  58. data/lib/formtastic/inputs/text_input.rb +5 -4
  59. data/lib/formtastic/inputs/time_input.rb +4 -8
  60. data/lib/formtastic/inputs/time_zone_input.rb +1 -1
  61. data/lib/formtastic/inputs/url_input.rb +2 -1
  62. data/lib/formtastic/localized_string.rb +6 -94
  63. data/lib/formtastic/localizer.rb +110 -0
  64. data/lib/formtastic/version.rb +1 -1
  65. data/lib/generators/formtastic/form/form_generator.rb +105 -0
  66. data/lib/generators/templates/_form.html.erb +2 -2
  67. data/lib/generators/templates/_form.html.haml +4 -4
  68. data/lib/generators/templates/_form.html.slim +2 -2
  69. data/lib/generators/templates/formtastic.rb +4 -0
  70. data/lib/locale/en.yml +2 -0
  71. data/sample/basic_inputs.html +22 -0
  72. data/spec/actions/button_action_spec.rb +63 -0
  73. data/spec/actions/generic_action_spec.rb +484 -0
  74. data/spec/actions/input_action_spec.rb +59 -0
  75. data/spec/actions/link_action_spec.rb +92 -0
  76. data/spec/builder/semantic_fields_for_spec.rb +14 -0
  77. data/spec/generators/formtastic/form/form_generator_spec.rb +118 -0
  78. data/spec/generators/formtastic/install/install_generator_spec.rb +47 -0
  79. data/spec/helpers/action_helper_spec.rb +365 -0
  80. data/spec/helpers/actions_helper_spec.rb +143 -0
  81. data/spec/helpers/buttons_helper_spec.rb +39 -23
  82. data/spec/helpers/commit_button_helper_spec.rb +153 -93
  83. data/spec/helpers/inputs_helper_spec.rb +14 -0
  84. data/spec/i18n_spec.rb +11 -0
  85. data/spec/inputs/boolean_input_spec.rb +31 -2
  86. data/spec/inputs/check_boxes_input_spec.rb +29 -1
  87. data/spec/inputs/date_input_spec.rb +95 -0
  88. data/spec/inputs/datetime_input_spec.rb +49 -0
  89. data/spec/inputs/email_input_spec.rb +28 -0
  90. data/spec/inputs/file_input_spec.rb +28 -0
  91. data/spec/inputs/hidden_input_spec.rb +28 -0
  92. data/spec/inputs/include_blank_spec.rb +53 -45
  93. data/spec/inputs/number_input_spec.rb +34 -4
  94. data/spec/inputs/password_input_spec.rb +28 -0
  95. data/spec/inputs/phone_input_spec.rb +28 -0
  96. data/spec/inputs/placeholder_spec.rb +10 -10
  97. data/spec/inputs/radio_input_spec.rb +51 -6
  98. data/spec/inputs/range_input_spec.rb +30 -2
  99. data/spec/inputs/search_input_spec.rb +27 -0
  100. data/spec/inputs/select_input_spec.rb +52 -6
  101. data/spec/inputs/string_input_spec.rb +28 -0
  102. data/spec/inputs/text_input_spec.rb +27 -0
  103. data/spec/inputs/time_input_spec.rb +67 -1
  104. data/spec/inputs/time_zone_input_spec.rb +28 -0
  105. data/spec/inputs/url_input_spec.rb +28 -0
  106. data/spec/inputs/with_options_spec.rb +43 -0
  107. data/spec/spec_helper.rb +22 -6
  108. data/spec/support/custom_macros.rb +6 -134
  109. data/spec/support/test_environment.rb +0 -1
  110. metadata +104 -17
  111. data/lib/formtastic/helpers/semantic_form_helper.rb +0 -11
  112. data/lib/formtastic/inputs/numeric_input.rb +0 -21
  113. data/lib/formtastic/railtie.rb +0 -12
  114. data/lib/formtastic/semantic_form_builder.rb +0 -11
  115. data/spec/builder/errors_spec.rb +0 -203
  116. data/spec/inputs/numeric_input_spec.rb +0 -41
@@ -124,6 +124,34 @@ describe 'string input' do
124
124
 
125
125
  end
126
126
 
127
+ describe "when index is provided" do
128
+
129
+ before do
130
+ @output_buffer = ''
131
+ mock_everything
132
+
133
+ concat(semantic_form_for(@new_post) do |builder|
134
+ concat(builder.fields_for(:author, :index => 3) do |author|
135
+ concat(author.input(:name, :as => :string))
136
+ end)
137
+ end)
138
+ end
139
+
140
+ it 'should index the id of the wrapper' do
141
+ output_buffer.should have_tag("li#post_author_attributes_3_name_input")
142
+ end
143
+
144
+ it 'should index the id of the select tag' do
145
+ output_buffer.should have_tag("input#post_author_attributes_3_name")
146
+ end
147
+
148
+ it 'should index the name of the select tag' do
149
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
150
+ end
151
+
152
+ end
153
+
154
+
127
155
  describe "when no object is provided" do
128
156
  before do
129
157
  concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
@@ -81,6 +81,33 @@ describe 'text input' do
81
81
 
82
82
  end
83
83
 
84
+ describe "when index is provided" do
85
+
86
+ before do
87
+ @output_buffer = ''
88
+ mock_everything
89
+
90
+ concat(semantic_form_for(@new_post) do |builder|
91
+ concat(builder.fields_for(:author, :index => 3) do |author|
92
+ concat(author.input(:name, :as => :text))
93
+ end)
94
+ end)
95
+ end
96
+
97
+ it 'should index the id of the wrapper' do
98
+ output_buffer.should have_tag("li#post_author_attributes_3_name_input")
99
+ end
100
+
101
+ it 'should index the id of the select tag' do
102
+ output_buffer.should have_tag("textarea#post_author_attributes_3_name")
103
+ end
104
+
105
+ it 'should index the name of the select tag' do
106
+ output_buffer.should have_tag("textarea[@name='post[author_attributes][3][name]']")
107
+ end
108
+
109
+ end
110
+
84
111
  context "when required" do
85
112
  it "should add the required attribute to the input's html options" do
86
113
  with_config :use_required_attribute, true do
@@ -58,6 +58,37 @@ describe 'time input' do
58
58
  output_buffer.should have_tag('select#post_publish_at_5i')
59
59
  end
60
60
 
61
+ it 'should associate the legend label with the hour select' do
62
+ output_buffer.should have_tag('form li.time fieldset legend.label label[@for="post_publish_at_4i"]')
63
+ end
64
+
65
+ end
66
+
67
+ describe "with :ignore_date => false and no initial Time" do
68
+ before do
69
+ @new_post.stub(:publish_at)
70
+ concat(semantic_form_for(@new_post) do |builder|
71
+ concat(builder.input(:publish_at, :as => :time, :ignore_date => false))
72
+ end)
73
+ end
74
+
75
+ it 'should have a hidden input for day, month and year' do
76
+ output_buffer.should have_tag('input#post_publish_at_1i')
77
+ output_buffer.should have_tag('input#post_publish_at_2i')
78
+ output_buffer.should have_tag('input#post_publish_at_3i')
79
+ end
80
+
81
+ it 'should not have values in hidden inputs for day, month and year' do
82
+ output_buffer.should have_tag('input#post_publish_at_1i[@value=""]')
83
+ output_buffer.should have_tag('input#post_publish_at_2i[@value=""]')
84
+ output_buffer.should have_tag('input#post_publish_at_3i[@value=""]')
85
+ end
86
+
87
+ it 'should have an select for hour and minute' do
88
+ output_buffer.should have_tag('select#post_publish_at_4i')
89
+ output_buffer.should have_tag('select#post_publish_at_5i')
90
+ end
91
+
61
92
  end
62
93
 
63
94
  describe "without seconds" do
@@ -80,7 +111,7 @@ describe 'time input' do
80
111
  end
81
112
 
82
113
  it 'should associate the legend label with the first select' do
83
- output_buffer.should have_tag('form li.time fieldset legend.label label[@for="post_publish_at_1i"]')
114
+ output_buffer.should have_tag('form li.time fieldset legend.label label[@for="post_publish_at_4i"]')
84
115
  end
85
116
 
86
117
  it 'should have an ordered list of two items inside the fieldset' do
@@ -198,4 +229,39 @@ describe 'time input' do
198
229
  end
199
230
  end
200
231
 
232
+ describe "when index is provided" do
233
+
234
+ before do
235
+ concat(semantic_form_for(@new_post) do |builder|
236
+ concat(builder.fields_for(:author, :index => 3) do |author|
237
+ concat(author.input(:created_at, :as => :time))
238
+ end)
239
+ end)
240
+ end
241
+
242
+ it 'should index the id of the wrapper' do
243
+ output_buffer.should have_tag("li#post_author_attributes_3_created_at_input")
244
+ end
245
+
246
+ it 'should index the id of the select tag' do
247
+ output_buffer.should have_tag("input#post_author_attributes_3_created_at_1i")
248
+ output_buffer.should have_tag("input#post_author_attributes_3_created_at_2i")
249
+ output_buffer.should have_tag("input#post_author_attributes_3_created_at_3i")
250
+ output_buffer.should have_tag("select#post_author_attributes_3_created_at_4i")
251
+ output_buffer.should have_tag("select#post_author_attributes_3_created_at_5i")
252
+ end
253
+
254
+ it 'should index the name of the select tag' do
255
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(1i)]']")
256
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(2i)]']")
257
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(3i)]']")
258
+ output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
259
+ output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
260
+ end
261
+
262
+ end
263
+
201
264
  end
265
+
266
+
267
+
@@ -54,6 +54,34 @@ describe 'time_zone input' do
54
54
  it_should_have_label_for("context2_post_time_zone")
55
55
 
56
56
  end
57
+
58
+ describe "when index is provided" do
59
+
60
+ before do
61
+ @output_buffer = ''
62
+ mock_everything
63
+
64
+ concat(semantic_form_for(@new_post) do |builder|
65
+ concat(builder.fields_for(:author, :index => 3) do |author|
66
+ concat(author.input(:name, :as => :time_zone))
67
+ end)
68
+ end)
69
+ end
70
+
71
+ it 'should index the id of the wrapper' do
72
+ output_buffer.should have_tag("li#post_author_attributes_3_name_input")
73
+ end
74
+
75
+ it 'should index the id of the select tag' do
76
+ output_buffer.should have_tag("select#post_author_attributes_3_name")
77
+ end
78
+
79
+ it 'should index the name of the select tag' do
80
+ output_buffer.should have_tag("select[@name='post[author_attributes][3][name]']")
81
+ end
82
+
83
+ end
84
+
57
85
 
58
86
  describe 'when no object is given' do
59
87
  before(:each) do
@@ -42,6 +42,34 @@ describe 'url input' do
42
42
 
43
43
  end
44
44
 
45
+ describe "when index is provided" do
46
+
47
+ before do
48
+ @output_buffer = ''
49
+ mock_everything
50
+
51
+ concat(semantic_form_for(@new_post) do |builder|
52
+ concat(builder.fields_for(:author, :index => 3) do |author|
53
+ concat(author.input(:name, :as => :url))
54
+ end)
55
+ end)
56
+ end
57
+
58
+ it 'should index the id of the wrapper' do
59
+ output_buffer.should have_tag("li#post_author_attributes_3_name_input")
60
+ end
61
+
62
+ it 'should index the id of the select tag' do
63
+ output_buffer.should have_tag("input#post_author_attributes_3_name")
64
+ end
65
+
66
+ it 'should index the name of the select tag' do
67
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
68
+ end
69
+
70
+ end
71
+
72
+
45
73
  describe "when required" do
46
74
  it "should add the required attribute to the input's html options" do
47
75
  with_config :use_required_attribute, true do
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'string input' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ before do
9
+ @output_buffer = ''
10
+ mock_everything
11
+ end
12
+
13
+ describe "with_options and :wrapper_html" do
14
+ before do
15
+ concat(semantic_form_for(@new_post) do |builder|
16
+ builder.with_options :wrapper_html => { :class => ['extra'] } do |opt_builder|
17
+ concat(opt_builder.input(:title, :as => :string))
18
+ concat(opt_builder.input(:author, :as => :radio))
19
+ end
20
+ end)
21
+ end
22
+
23
+ it "should have extra class on title" do
24
+ output_buffer.should have_tag("form li#post_title_input.extra")
25
+ end
26
+ it "should have title as string" do
27
+ output_buffer.should have_tag("form li#post_title_input.string")
28
+ end
29
+ it "should not have title as radio" do
30
+ output_buffer.should_not have_tag("form li#post_title_input.radio")
31
+ end
32
+
33
+ it "should have extra class on author" do
34
+ output_buffer.should have_tag("form li#post_author_input.extra")
35
+ end
36
+ it "should not have author as string" do
37
+ output_buffer.should_not have_tag("form li#post_author_input.string")
38
+ end
39
+ it "should have author as radio" do
40
+ output_buffer.should have_tag("form li#post_author_input.radio")
41
+ end
42
+ end
43
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'rubygems'
3
- require 'bundler'
4
- Bundler.setup
5
-
3
+ require 'bundler/setup'
6
4
  require 'active_support'
7
5
  require 'action_pack'
8
6
  require 'action_view'
@@ -12,6 +10,8 @@ require 'action_dispatch'
12
10
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/util'))
13
11
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
14
12
 
13
+ require 'ammeter/init'
14
+
15
15
  # Requires supporting files with custom matchers and macros, etc,
16
16
  # in ./support/ and its subdirectories in alphabetic order.
17
17
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
@@ -137,6 +137,18 @@ module FormtasticSpecHelper
137
137
  include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
138
138
  end
139
139
 
140
+ ##
141
+ # We can't mock :respond_to?, so we need a concrete class override
142
+ class ::MongoidReflectionMock < RSpec::Mocks::Mock
143
+ def initialize(name=nil, stubs_and_options={})
144
+ super name, stubs_and_options
145
+ end
146
+
147
+ def respond_to?(sym)
148
+ sym == :options ? false : super
149
+ end
150
+ end
151
+
140
152
  def _routes
141
153
  url_helpers = mock('url_helpers')
142
154
  url_helpers.stub!(:hash_for_posts_path).and_return({})
@@ -151,7 +163,9 @@ module FormtasticSpecHelper
151
163
  end
152
164
 
153
165
  def controller
154
- mock('controller', :controller_path= => '', :params => {})
166
+ env = mock('env', :[] => nil)
167
+ request = mock('request', :env => env)
168
+ mock('controller', :controller_path= => '', :params => {}, :request => request)
155
169
  end
156
170
 
157
171
  def default_url_options
@@ -282,7 +296,9 @@ module FormtasticSpecHelper
282
296
  when :main_post
283
297
  mock('reflection', :options => {}, :klass => ::Post, :macro => :belongs_to)
284
298
  when :mongoid_reviewer
285
- mock('reflection', :options => nil, :klass => ::Author, :macro => :referenced_in, :foreign_key => "reviewer_id") # custom id
299
+ ::MongoidReflectionMock.new('reflection',
300
+ :options => Proc.new { raise NoMethodError, "Mongoid has no reflection.options" },
301
+ :klass => ::Author, :macro => :referenced_in, :foreign_key => "reviewer_id") # custom id
286
302
  end
287
303
  end
288
304
  ::Post.stub!(:find).and_return([@freds_post])
@@ -409,4 +425,4 @@ RSpec.configure do |config|
409
425
  config.after(:all) do
410
426
  DeferredGarbageCollection.reconsider unless ENV["DEFER_GC"] == "false"
411
427
  end
412
- end
428
+ end
@@ -86,6 +86,12 @@ module CustomMacros
86
86
  end
87
87
  end
88
88
 
89
+ def it_should_have_select_with_name(name)
90
+ it "should have an input named #{name}" do
91
+ output_buffer.should have_tag("form li select[@name=\"#{name}\"]")
92
+ end
93
+ end
94
+
89
95
  def it_should_have_textarea_with_name(name)
90
96
  it "should have an input named #{name}" do
91
97
  output_buffer.should have_tag("form li textarea[@name=\"#{name}\"]")
@@ -515,140 +521,6 @@ module CustomMacros
515
521
  end
516
522
  end
517
523
 
518
- describe 'when the deprecated :label_method option is provided' do
519
-
520
- describe 'as a symbol' do
521
- before do
522
- with_deprecation_silenced do
523
- concat(semantic_form_for(@new_post) do |builder|
524
- concat(builder.input(:author, :as => as, :label_method => :login))
525
- end)
526
- end
527
- end
528
-
529
- it 'should have options with text content from the specified method' do
530
- ::Author.all.each do |author|
531
- output_buffer.should have_tag("form li.#{as}", /#{author.login}/)
532
- end
533
- end
534
- end
535
-
536
- describe 'as a proc' do
537
-
538
- before do
539
- with_deprecation_silenced do
540
- concat(semantic_form_for(@new_post) do |builder|
541
- concat(builder.input(:author, :as => as, :label_method => Proc.new {|a| a.login.reverse }))
542
- end)
543
- end
544
- end
545
-
546
- it 'should have options with the proc applied to each' do
547
- ::Author.all.each do |author|
548
- output_buffer.should have_tag("form li.#{as}", /#{author.login.reverse}/)
549
- end
550
- end
551
- end
552
-
553
- describe 'as a method object' do
554
- before do
555
- def reverse_login(a)
556
- a.login.reverse
557
- end
558
- with_deprecation_silenced do
559
- concat(semantic_form_for(@new_post) do |builder|
560
- concat(builder.input(:author, :as => as, :label_method => method(:reverse_login)))
561
- end)
562
- end
563
- end
564
-
565
- it 'should have options with the proc applied to each' do
566
- ::Author.all.each do |author|
567
- output_buffer.should have_tag("form li.#{as}", /#{author.login.reverse}/)
568
- end
569
- end
570
- end
571
- end
572
-
573
- describe 'when the deprecated :label_method option is not provided' do
574
- Formtastic::FormBuilder.collection_label_methods.each do |label_method|
575
-
576
- describe "when the collection objects respond to #{label_method}" do
577
- before do
578
- @fred.stub!(:respond_to?).and_return { |m| m.to_s == label_method || m.to_s == 'id' }
579
- ::Author.all.each { |a| a.stub!(label_method).and_return('The Label Text') }
580
-
581
- with_deprecation_silenced do
582
- concat(semantic_form_for(@new_post) do |builder|
583
- concat(builder.input(:author, :as => as))
584
- end)
585
- end
586
- end
587
-
588
- it "should render the options with #{label_method} as the label" do
589
- ::Author.all.each do |author|
590
- output_buffer.should have_tag("form li.#{as}", /The Label Text/)
591
- end
592
- end
593
- end
594
-
595
- end
596
- end
597
-
598
- describe 'when the deprecated :value_method option is provided' do
599
-
600
- describe 'as a symbol' do
601
- before do
602
- with_deprecation_silenced do
603
- concat(semantic_form_for(@new_post) do |builder|
604
- concat(builder.input(:author, :as => as, :value_method => :login))
605
- end)
606
- end
607
- end
608
-
609
- it 'should have options with values from specified method' do
610
- ::Author.all.each do |author|
611
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login}']")
612
- end
613
- end
614
- end
615
-
616
- describe 'as a proc' do
617
- before do
618
- with_deprecation_silenced do
619
- concat(semantic_form_for(@new_post) do |builder|
620
- concat(builder.input(:author, :as => as, :value_method => Proc.new {|a| a.login.reverse }))
621
- end)
622
- end
623
- end
624
-
625
- it 'should have options with the proc applied to each value' do
626
- ::Author.all.each do |author|
627
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
628
- end
629
- end
630
- end
631
-
632
- describe 'as a method object' do
633
- before do
634
- def reverse_login(a)
635
- a.login.reverse
636
- end
637
- with_deprecation_silenced do
638
- concat(semantic_form_for(@new_post) do |builder|
639
- concat(builder.input(:author, :as => as, :value_method => method(:reverse_login)))
640
- end)
641
- end
642
- end
643
-
644
- it 'should have options with the proc applied to each value' do
645
- ::Author.all.each do |author|
646
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
647
- end
648
- end
649
- end
650
- end
651
-
652
524
  end
653
525
  end
654
526