formnestic 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/.document +5 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +5 -0
  4. data/.watchr +31 -0
  5. data/Gemfile +27 -0
  6. data/Gemfile.lock +133 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.markdown +126 -0
  9. data/Rakefile +44 -0
  10. data/VERSION +1 -0
  11. data/app/assets/.DS_Store +0 -0
  12. data/app/assets/javascripts/formnestic/formnestic.js +139 -0
  13. data/app/assets/stylesheets/formnestic/entypo.css.scss +327 -0
  14. data/app/assets/stylesheets/formnestic/entypo.eot +0 -0
  15. data/app/assets/stylesheets/formnestic/entypo.svg +296 -0
  16. data/app/assets/stylesheets/formnestic/entypo.ttf +0 -0
  17. data/app/assets/stylesheets/formnestic/entypo.woff +0 -0
  18. data/app/assets/stylesheets/formnestic/formnestic.css.scss +167 -0
  19. data/config/locales/formnestic.en.yml +8 -0
  20. data/formnestic.gemspec +112 -0
  21. data/lib/formnestic/form_builder/base_builder.rb +55 -0
  22. data/lib/formnestic/form_builder/list_form_builder.rb +30 -0
  23. data/lib/formnestic/form_builder/table_form_builder.rb +94 -0
  24. data/lib/formnestic/form_builder.rb +13 -0
  25. data/lib/formnestic/helpers/inputs_helper.rb +82 -0
  26. data/lib/formnestic/helpers.rb +9 -0
  27. data/lib/formnestic/inputs/base/labelling.rb +15 -0
  28. data/lib/formnestic/inputs/base/wrapping.rb +52 -0
  29. data/lib/formnestic/inputs/base.rb +12 -0
  30. data/lib/formnestic/inputs.rb +7 -0
  31. data/lib/formnestic.rb +72 -0
  32. data/lib/generators/formnestic/install_generator.rb +36 -0
  33. data/log/development.log +0 -0
  34. data/rwatchr +1 -0
  35. data/screenshots/list_form.png +0 -0
  36. data/screenshots/table_form.png +0 -0
  37. data/spec/helpers/nested_model_helper_spec.rb +277 -0
  38. data/spec/helpers/nested_model_list_helper_spec.rb +51 -0
  39. data/spec/inputs/boolean_input_spec.rb +223 -0
  40. data/spec/spec_helper.rb +553 -0
  41. data/spec/support/custom_macros.rb +528 -0
  42. data/spec/support/deferred_garbage_collection.rb +21 -0
  43. data/spec/support/deprecation.rb +6 -0
  44. data/spec/support/test_environment.rb +31 -0
  45. metadata +271 -0
@@ -0,0 +1,528 @@
1
+ # encoding: utf-8
2
+
3
+ module CustomMacros
4
+
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+
11
+ def it_should_have_input_wrapper_with_class(class_name)
12
+ it "should have input wrapper with class '#{class_name}'" do
13
+ output_buffer.should have_tag("form li.#{class_name}")
14
+ end
15
+ end
16
+
17
+ def it_should_have_input_wrapper_with_id(id_string)
18
+ it "should have input wrapper with id '#{id_string}'" do
19
+ output_buffer.should have_tag("form li##{id_string}")
20
+ end
21
+ end
22
+
23
+ def it_should_not_have_a_label
24
+ it "should not have a label" do
25
+ output_buffer.should_not have_tag("form li label")
26
+ end
27
+ end
28
+
29
+ def it_should_have_a_nested_fieldset
30
+ it "should have a nested_fieldset" do
31
+ output_buffer.should have_tag("form li fieldset")
32
+ end
33
+ end
34
+
35
+ def it_should_have_a_nested_fieldset_with_class(klass)
36
+ it "should have a nested_fieldset with class #{klass}" do
37
+ output_buffer.should have_tag("form li fieldset.#{klass}")
38
+ end
39
+ end
40
+
41
+ def it_should_have_a_nested_ordered_list_with_class(klass)
42
+ it "should have a nested fieldset with class #{klass}" do
43
+ output_buffer.should have_tag("form li ol.#{klass}")
44
+ end
45
+ end
46
+
47
+ def it_should_have_label_with_text(string_or_regex)
48
+ it "should have a label with text '#{string_or_regex}'" do
49
+ output_buffer.should have_tag("form li label", string_or_regex)
50
+ end
51
+ end
52
+
53
+ def it_should_have_label_for(element_id)
54
+ it "should have a label for ##{element_id}" do
55
+ output_buffer.should have_tag("form li label.label[@for='#{element_id}']")
56
+ end
57
+ end
58
+
59
+ def it_should_have_an_inline_label_for(element_id)
60
+ it "should have a label for ##{element_id}" do
61
+ output_buffer.should have_tag("form li label[@for='#{element_id}']")
62
+ end
63
+ end
64
+
65
+ def it_should_have_input_with_id(element_id)
66
+ it "should have an input with id '#{element_id}'" do
67
+ output_buffer.should have_tag("form li input##{element_id}")
68
+ end
69
+ end
70
+
71
+ def it_should_have_select_with_id(element_id)
72
+ it "should have a select box with id '#{element_id}'" do
73
+ output_buffer.should have_tag("form li select##{element_id}")
74
+ end
75
+ end
76
+
77
+ def it_should_have_input_with_type(input_type)
78
+ it "should have a #{input_type} input" do
79
+ output_buffer.should have_tag("form li input[@type=\"#{input_type}\"]")
80
+ end
81
+ end
82
+
83
+ def it_should_have_input_with_name(name)
84
+ it "should have an input named #{name}" do
85
+ output_buffer.should have_tag("form li input[@name=\"#{name}\"]")
86
+ end
87
+ end
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
+
95
+ def it_should_have_textarea_with_name(name)
96
+ it "should have an input named #{name}" do
97
+ output_buffer.should have_tag("form li textarea[@name=\"#{name}\"]")
98
+ end
99
+ end
100
+
101
+ def it_should_have_textarea_with_id(element_id)
102
+ it "should have an input with id '#{element_id}'" do
103
+ output_buffer.should have_tag("form li textarea##{element_id}")
104
+ end
105
+ end
106
+
107
+ def it_should_have_label_and_input_with_id(element_id)
108
+ it "should have an input with id '#{element_id}'" do
109
+ output_buffer.should have_tag("form li input##{element_id}")
110
+ output_buffer.should have_tag("form li label[@for='#{element_id}']")
111
+ end
112
+ end
113
+
114
+ def it_should_use_default_text_field_size_when_not_nil(as)
115
+ it 'should use default_text_field_size when not nil' do
116
+ with_config :default_text_field_size, 30 do
117
+ concat(semantic_form_for(@new_post) do |builder|
118
+ concat(builder.input(:title, :as => as))
119
+ end)
120
+ output_buffer.should have_tag("form li input[@size='#{Formtastic::FormBuilder.default_text_field_size}']")
121
+ end
122
+ end
123
+ end
124
+
125
+ def it_should_not_use_default_text_field_size_when_nil(as)
126
+ it 'should not use default_text_field_size when nil' do
127
+ with_config :default_text_field_size, nil do
128
+ concat(semantic_form_for(@new_post) do |builder|
129
+ concat(builder.input(:title, :as => as))
130
+ end)
131
+ output_buffer.should have_tag("form li input")
132
+ output_buffer.should_not have_tag("form li input[@size]")
133
+ end
134
+ end
135
+ end
136
+
137
+ def it_should_apply_custom_input_attributes_when_input_html_provided(as)
138
+ it 'it should apply custom input attributes when input_html provided' do
139
+ concat(semantic_form_for(@new_post) do |builder|
140
+ concat(builder.input(:title, :as => as, :input_html => { :class => 'myclass' }))
141
+ end)
142
+ output_buffer.should have_tag("form li input.myclass")
143
+ end
144
+ end
145
+
146
+ def it_should_apply_custom_for_to_label_when_input_html_id_provided(as)
147
+ it 'it should apply custom for to label when input_html :id provided' do
148
+ concat(semantic_form_for(@new_post) do |builder|
149
+ concat(builder.input(:title, :as => as, :input_html => { :id => 'myid' }))
150
+ end)
151
+ output_buffer.should have_tag('form li label[@for="myid"]')
152
+ end
153
+ end
154
+
155
+ def it_should_have_maxlength_matching_column_limit
156
+ it 'should have a maxlength matching column limit' do
157
+ @new_post.column_for_attribute(:title).limit.should == 50
158
+ output_buffer.should have_tag("form li input[@maxlength='50']")
159
+ end
160
+ end
161
+
162
+ def it_should_use_column_size_for_columns_shorter_than_default_text_field_size(as)
163
+ it 'should use the column size for columns shorter than default_text_field_size' do
164
+ column_limit_shorted_than_default = 1
165
+ @new_post.stub!(:column_for_attribute).and_return(mock('column', :type => as, :limit => column_limit_shorted_than_default))
166
+
167
+ concat(semantic_form_for(@new_post) do |builder|
168
+ concat(builder.input(:title, :as => as))
169
+ end)
170
+
171
+ output_buffer.should have_tag("form li input[@size='#{column_limit_shorted_than_default}']")
172
+ end
173
+ end
174
+
175
+ def it_should_apply_error_logic_for_input_type(type)
176
+ describe 'when there are errors on the object for this method' do
177
+ before do
178
+ @title_errors = ['must not be blank', 'must be longer than 10 characters', 'must be awesome']
179
+ @errors = mock('errors')
180
+ @errors.stub!(:[]).with(:title).and_return(@title_errors)
181
+ Formtastic::FormBuilder.file_metadata_suffixes.each do |suffix|
182
+ @errors.stub!(:[]).with("title_#{suffix}".to_sym).and_return(nil)
183
+ end
184
+ @new_post.stub!(:errors).and_return(@errors)
185
+ end
186
+
187
+ it 'should apply an errors class to the list item' do
188
+ concat(semantic_form_for(@new_post) do |builder|
189
+ concat(builder.input(:title, :as => type))
190
+ end)
191
+ output_buffer.should have_tag('form li.error')
192
+ end
193
+
194
+ it 'should not wrap the input with the Rails default error wrapping' do
195
+ concat(semantic_form_for(@new_post) do |builder|
196
+ concat(builder.input(:title, :as => type))
197
+ end)
198
+ output_buffer.should_not have_tag('div.fieldWithErrors')
199
+ end
200
+
201
+ it 'should render a paragraph for the errors' do
202
+ Formtastic::FormBuilder.inline_errors = :sentence
203
+ concat(semantic_form_for(@new_post) do |builder|
204
+ concat(builder.input(:title, :as => type))
205
+ end)
206
+ output_buffer.should have_tag('form li.error p.inline-errors')
207
+ end
208
+
209
+ it 'should not display an error list' do
210
+ Formtastic::FormBuilder.inline_errors = :list
211
+ concat(semantic_form_for(@new_post) do |builder|
212
+ concat(builder.input(:title, :as => type))
213
+ end)
214
+ output_buffer.should have_tag('form li.error ul.errors')
215
+ end
216
+ end
217
+
218
+ describe 'when there are no errors on the object for this method' do
219
+ before do
220
+ @form = semantic_form_for(@new_post) do |builder|
221
+ concat(builder.input(:title, :as => type))
222
+ end
223
+ end
224
+
225
+ it 'should not apply an errors class to the list item' do
226
+ output_buffer.should_not have_tag('form li.error')
227
+ end
228
+
229
+ it 'should not render a paragraph for the errors' do
230
+ output_buffer.should_not have_tag('form li.error p.inline-errors')
231
+ end
232
+
233
+ it 'should not display an error list' do
234
+ output_buffer.should_not have_tag('form li.error ul.errors')
235
+ end
236
+ end
237
+
238
+ describe 'when no object is provided' do
239
+ before do
240
+ concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
241
+ concat(builder.input(:title, :as => type))
242
+ end)
243
+ end
244
+
245
+ it 'should not apply an errors class to the list item' do
246
+ output_buffer.should_not have_tag('form li.error')
247
+ end
248
+
249
+ it 'should not render a paragraph for the errors' do
250
+ output_buffer.should_not have_tag('form li.error p.inline-errors')
251
+ end
252
+
253
+ it 'should not display an error list' do
254
+ output_buffer.should_not have_tag('form li.error ul.errors')
255
+ end
256
+ end
257
+ end
258
+
259
+ def it_should_call_find_on_association_class_when_no_collection_is_provided(as)
260
+ it "should call find on the association class when no collection is provided" do
261
+ ::Author.should_receive(:where)
262
+ concat(semantic_form_for(@new_post) do |builder|
263
+ concat(builder.input(:author, :as => as))
264
+ end)
265
+ end
266
+ end
267
+
268
+ def it_should_use_the_collection_when_provided(as, countable)
269
+ describe 'when the :collection option is provided' do
270
+
271
+ before do
272
+ @authors = ::Author.all * 2
273
+ output_buffer.replace ''
274
+ end
275
+
276
+ it 'should use the provided collection' do
277
+ concat(semantic_form_for(@new_post) do |builder|
278
+ concat(builder.input(:author, :as => as, :collection => @authors))
279
+ end)
280
+ output_buffer.should have_tag("form li.#{as} #{countable}", :count => @authors.size + (as == :select ? 1 : 0))
281
+ end
282
+
283
+ describe 'and the :collection is an array of strings' do
284
+ before do
285
+ @categories = [ 'General', 'Design', 'Development', 'Quasi-Serious Inventions' ]
286
+ end
287
+
288
+ it "should use the string as the label text and value for each #{countable}" do
289
+ concat(semantic_form_for(@new_post) do |builder|
290
+ concat(builder.input(:category_name, :as => as, :collection => @categories))
291
+ end)
292
+
293
+ @categories.each do |value|
294
+ output_buffer.should have_tag("form li.#{as}", /#{value}/)
295
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value}']")
296
+ end
297
+ end
298
+
299
+ if as == :radio
300
+ it 'should generate a sanitized label for attribute' do
301
+ @bob.stub!(:category_name).and_return(@categories)
302
+ concat(semantic_form_for(@new_post) do |builder|
303
+ fields = builder.semantic_fields_for(@bob) do |bob_builder|
304
+ concat(bob_builder.input(:category_name, :as => as, :collection => @categories))
305
+ end
306
+ concat(fields)
307
+ end)
308
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_general']")
309
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_design']")
310
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_development']")
311
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_quasi-serious_inventions']")
312
+ end
313
+ end
314
+ end
315
+
316
+ describe 'and the :collection is a hash of strings' do
317
+ before do
318
+ @categories = { 'General' => 'gen', 'Design' => 'des','Development' => 'dev' }
319
+ end
320
+
321
+ it "should use the key as the label text and the hash value as the value attribute for each #{countable}" do
322
+ concat(semantic_form_for(@new_post) do |builder|
323
+ concat(builder.input(:category_name, :as => as, :collection => @categories))
324
+ end)
325
+
326
+ @categories.each do |label, value|
327
+ output_buffer.should have_tag("form li.#{as}", /#{label}/)
328
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value}']")
329
+ end
330
+ end
331
+ end
332
+
333
+ describe 'and the :collection is an array of arrays' do
334
+ before do
335
+ @categories = { 'General' => 'gen', 'Design' => 'des', 'Development' => 'dev' }.to_a
336
+ end
337
+
338
+ it "should use the first value as the label text and the last value as the value attribute for #{countable}" do
339
+ concat(semantic_form_for(@new_post) do |builder|
340
+ concat(builder.input(:category_name, :as => as, :collection => @categories))
341
+ end)
342
+
343
+ @categories.each do |text, value|
344
+ label = as == :select ? :option : :label
345
+ output_buffer.should have_tag("form li.#{as} #{label}", /#{text}/i)
346
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value.to_s}']")
347
+ output_buffer.should have_tag("form li.#{as} #{countable}#post_category_name_#{value.to_s}") if as == :radio
348
+ end
349
+ end
350
+ end
351
+
352
+ if as == :radio
353
+ describe 'and the :collection is an array of arrays with boolean values' do
354
+ before do
355
+ @choices = { 'Yeah' => true, 'Nah' => false }.to_a
356
+ end
357
+
358
+ it "should use the first value as the label text and the last value as the value attribute for #{countable}" do
359
+ concat(semantic_form_for(@new_post) do |builder|
360
+ concat(builder.input(:category_name, :as => as, :collection => @choices))
361
+ end)
362
+
363
+ output_buffer.should have_tag("form li.#{as} #{countable}#post_category_name_true")
364
+ output_buffer.should have_tag("form li.#{as} #{countable}#post_category_name_false")
365
+ end
366
+ end
367
+ end
368
+
369
+ describe 'and the :collection is an array of symbols' do
370
+ before do
371
+ @categories = [ :General, :Design, :Development ]
372
+ end
373
+
374
+ it "should use the symbol as the label text and value for each #{countable}" do
375
+ concat(semantic_form_for(@new_post) do |builder|
376
+ concat(builder.input(:category_name, :as => as, :collection => @categories))
377
+ end)
378
+
379
+ @categories.each do |value|
380
+ label = as == :select ? :option : :label
381
+ output_buffer.should have_tag("form li.#{as} #{label}", /#{value}/i)
382
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value.to_s}']")
383
+ end
384
+ end
385
+ end
386
+
387
+ describe 'and the :collection is an OrderedHash of strings' do
388
+ before do
389
+ @categories = ActiveSupport::OrderedHash.new('General' => 'gen', 'Design' => 'des','Development' => 'dev')
390
+ end
391
+
392
+ it "should use the key as the label text and the hash value as the value attribute for each #{countable}" do
393
+ concat(semantic_form_for(@new_post) do |builder|
394
+ concat(builder.input(:category_name, :as => as, :collection => @categories))
395
+ end)
396
+
397
+ @categories.each do |label, value|
398
+ output_buffer.should have_tag("form li.#{as}", /#{label}/)
399
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value}']")
400
+ end
401
+ end
402
+
403
+ end
404
+
405
+ describe 'when the :member_label option is provided' do
406
+
407
+ describe 'as a symbol' do
408
+ before do
409
+ concat(semantic_form_for(@new_post) do |builder|
410
+ concat(builder.input(:author, :as => as, :member_label => :login))
411
+ end)
412
+ end
413
+
414
+ it 'should have options with text content from the specified method' do
415
+ ::Author.all.each do |author|
416
+ output_buffer.should have_tag("form li.#{as}", /#{author.login}/)
417
+ end
418
+ end
419
+ end
420
+
421
+ describe 'as a proc' do
422
+ before do
423
+ concat(semantic_form_for(@new_post) do |builder|
424
+ concat(builder.input(:author, :as => as, :member_label => Proc.new {|a| a.login.reverse }))
425
+ end)
426
+ end
427
+
428
+ it 'should have options with the proc applied to each' do
429
+ ::Author.all.each do |author|
430
+ output_buffer.should have_tag("form li.#{as}", /#{author.login.reverse}/)
431
+ end
432
+ end
433
+ end
434
+
435
+ describe 'as a method object' do
436
+ before do
437
+ def reverse_login(a)
438
+ a.login.reverse
439
+ end
440
+ concat(semantic_form_for(@new_post) do |builder|
441
+ concat(builder.input(:author, :as => as, :member_label => method(:reverse_login)))
442
+ end)
443
+ end
444
+
445
+ it 'should have options with the proc applied to each' do
446
+ ::Author.all.each do |author|
447
+ output_buffer.should have_tag("form li.#{as}", /#{author.login.reverse}/)
448
+ end
449
+ end
450
+ end
451
+ end
452
+
453
+ describe 'when the :member_label option is not provided' do
454
+ Formtastic::FormBuilder.collection_label_methods.each do |label_method|
455
+
456
+ describe "when the collection objects respond to #{label_method}" do
457
+ before do
458
+ @fred.stub!(:respond_to?).and_return { |m| m.to_s == label_method || m.to_s == 'id' }
459
+ ::Author.all.each { |a| a.stub!(label_method).and_return('The Label Text') }
460
+
461
+ concat(semantic_form_for(@new_post) do |builder|
462
+ concat(builder.input(:author, :as => as))
463
+ end)
464
+ end
465
+
466
+ it "should render the options with #{label_method} as the label" do
467
+ ::Author.all.each do |author|
468
+ output_buffer.should have_tag("form li.#{as}", /The Label Text/)
469
+ end
470
+ end
471
+ end
472
+
473
+ end
474
+ end
475
+
476
+ describe 'when the :member_value option is provided' do
477
+
478
+ describe 'as a symbol' do
479
+ before do
480
+ concat(semantic_form_for(@new_post) do |builder|
481
+ concat(builder.input(:author, :as => as, :member_value => :login))
482
+ end)
483
+ end
484
+
485
+ it 'should have options with values from specified method' do
486
+ ::Author.all.each do |author|
487
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login}']")
488
+ end
489
+ end
490
+ end
491
+
492
+ describe 'as a proc' do
493
+ before do
494
+ concat(semantic_form_for(@new_post) do |builder|
495
+ concat(builder.input(:author, :as => as, :member_value => Proc.new {|a| a.login.reverse }))
496
+ end)
497
+ end
498
+
499
+ it 'should have options with the proc applied to each value' do
500
+ ::Author.all.each do |author|
501
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
502
+ end
503
+ end
504
+ end
505
+
506
+ describe 'as a method object' do
507
+ before do
508
+ def reverse_login(a)
509
+ a.login.reverse
510
+ end
511
+ concat(semantic_form_for(@new_post) do |builder|
512
+ concat(builder.input(:author, :as => as, :member_value => method(:reverse_login)))
513
+ end)
514
+ end
515
+
516
+ it 'should have options with the proc applied to each value' do
517
+ ::Author.all.each do |author|
518
+ output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
519
+ end
520
+ end
521
+ end
522
+ end
523
+
524
+ end
525
+ end
526
+
527
+ end
528
+ end
@@ -0,0 +1,21 @@
1
+ # Taken from http://makandra.com/notes/950-speed-up-rspec-by-deferring-garbage-collection
2
+ class DeferredGarbageCollection
3
+
4
+ DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f
5
+
6
+ @@last_gc_run = Time.now
7
+
8
+ def self.start
9
+ GC.disable if DEFERRED_GC_THRESHOLD > 0
10
+ end
11
+
12
+ def self.reconsider
13
+ if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
14
+ GC.enable
15
+ GC.start
16
+ GC.disable
17
+ @@last_gc_run = Time.now
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,6 @@
1
+ # Taken from https://github.com/justinfrench/formtastic
2
+ def with_deprecation_silenced(&block)
3
+ ::ActiveSupport::Deprecation.silence do
4
+ yield
5
+ end
6
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ # require 'rspec'
3
+ require 'rspec_tag_matchers'
4
+
5
+ RSpec.configure do |config|
6
+ config.include RspecTagMatchers
7
+ config.include CustomMacros
8
+ config.mock_with :rspec
9
+ end
10
+
11
+ require "action_controller/railtie"
12
+ require 'active_model'
13
+
14
+ # Create a simple rails application for use in testing the viewhelper
15
+ module FormtasticTest
16
+ class Application < Rails::Application
17
+ # Configure the default encoding used in templates for Ruby 1.9.
18
+ config.encoding = "utf-8"
19
+ config.active_support.deprecation = :stderr
20
+ config.secret_key_base = "secret"
21
+ config.eager_load = false
22
+ end
23
+ end
24
+ FormtasticTest::Application.initialize!
25
+
26
+ require 'rspec/rails'
27
+
28
+ # Quick hack to avoid the 'Spec' deprecation warnings from rspec_tag_matchers
29
+ module Spec
30
+ include RSpec
31
+ end