formtastic 0.9.2 → 0.9.3
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.
- data/README.textile +35 -4
- data/Rakefile +47 -22
- data/generators/formtastic/templates/formtastic.css +1 -0
- data/lib/formtastic/i18n.rb +27 -0
- data/lib/formtastic.rb +151 -81
- data/lib/locale/en.yml +2 -2
- data/spec/commit_button_spec.rb +5 -5
- data/spec/custom_builder_spec.rb +8 -8
- data/spec/custom_macros.rb +3 -3
- data/spec/errors_spec.rb +6 -6
- data/spec/form_helper_spec.rb +4 -4
- data/spec/i18n_spec.rb +83 -0
- data/spec/input_spec.rb +22 -21
- data/spec/inputs/check_boxes_input_spec.rb +3 -3
- data/spec/inputs/country_input_spec.rb +1 -1
- data/spec/inputs/date_input_spec.rb +2 -2
- data/spec/inputs/datetime_input_spec.rb +5 -5
- data/spec/inputs/hidden_input_spec.rb +13 -2
- data/spec/inputs/radio_input_spec.rb +3 -3
- data/spec/inputs/select_input_spec.rb +83 -4
- data/spec/inputs/time_input_spec.rb +2 -2
- data/spec/inputs_spec.rb +28 -16
- data/spec/label_spec.rb +0 -6
- data/spec/semantic_fields_for_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -2
- metadata +58 -6
data/spec/inputs_spec.rb
CHANGED
@@ -174,9 +174,12 @@ describe 'SemanticFormBuilder#inputs' do
|
|
174
174
|
describe 'and is a string' do
|
175
175
|
before do
|
176
176
|
@legend_text = "Advanced options"
|
177
|
-
@
|
177
|
+
@legend_text_using_name = "Advanced options 2"
|
178
|
+
@legend_text_using_title = "Advanced options 3"
|
178
179
|
semantic_form_for(@new_post) do |builder|
|
179
|
-
builder.inputs
|
180
|
+
builder.inputs @legend_text do
|
181
|
+
end
|
182
|
+
builder.inputs :name => @legend_text_using_name do
|
180
183
|
end
|
181
184
|
builder.inputs :title => @legend_text_using_title do
|
182
185
|
end
|
@@ -184,34 +187,40 @@ describe 'SemanticFormBuilder#inputs' do
|
|
184
187
|
end
|
185
188
|
|
186
189
|
it 'should render a fieldset with a legend inside the form' do
|
187
|
-
output_buffer.should have_tag("form fieldset legend",
|
188
|
-
output_buffer.should have_tag("form fieldset legend",
|
190
|
+
output_buffer.should have_tag("form fieldset legend", /^#{@legend_text}$/)
|
191
|
+
output_buffer.should have_tag("form fieldset legend", /^#{@legend_text_using_name}$/)
|
192
|
+
output_buffer.should have_tag("form fieldset legend", /^#{@legend_text_using_title}$/)
|
189
193
|
end
|
190
194
|
end
|
191
195
|
|
192
196
|
describe 'and is a symbol' do
|
193
197
|
before do
|
194
198
|
@localized_legend_text = "Localized advanced options"
|
195
|
-
@
|
196
|
-
|
199
|
+
@localized_legend_text_using_name = "Localized advanced options 2"
|
200
|
+
@localized_legend_text_using_title = "Localized advanced options 3"
|
201
|
+
::I18n.backend.store_translations :en, :formtastic => {
|
197
202
|
:titles => {
|
198
203
|
:post => {
|
199
204
|
:advanced_options => @localized_legend_text,
|
200
|
-
:
|
205
|
+
:advanced_options_using_name => @localized_legend_text_using_name,
|
206
|
+
:advanced_options_using_title => @localized_legend_text_using_title
|
201
207
|
}
|
202
208
|
}
|
203
209
|
}
|
204
210
|
semantic_form_for(@new_post) do |builder|
|
205
|
-
builder.inputs :
|
211
|
+
builder.inputs :advanced_options do
|
212
|
+
end
|
213
|
+
builder.inputs :name => :advanced_options_using_name do
|
206
214
|
end
|
207
|
-
builder.inputs :title => :
|
215
|
+
builder.inputs :title => :advanced_options_using_title do
|
208
216
|
end
|
209
217
|
end
|
210
218
|
end
|
211
219
|
|
212
220
|
it 'should render a fieldset with a localized legend inside the form' do
|
213
|
-
output_buffer.should have_tag("form fieldset legend",
|
214
|
-
output_buffer.should have_tag("form fieldset legend",
|
221
|
+
output_buffer.should have_tag("form fieldset legend", /^#{@localized_legend_text}$/)
|
222
|
+
output_buffer.should have_tag("form fieldset legend", /^#{@localized_legend_text_using_name}$/)
|
223
|
+
output_buffer.should have_tag("form fieldset legend", /^#{@localized_legend_text_using_title}$/)
|
215
224
|
end
|
216
225
|
end
|
217
226
|
end
|
@@ -238,9 +247,8 @@ describe 'SemanticFormBuilder#inputs' do
|
|
238
247
|
describe 'without a block' do
|
239
248
|
|
240
249
|
before do
|
241
|
-
::Post.stub!(:reflections).and_return({:author
|
250
|
+
::Post.stub!(:reflections).and_return({:author => mock('reflection', :options => {}, :macro => :belongs_to),
|
242
251
|
:comments => mock('reflection', :options => {}, :macro => :has_many) })
|
243
|
-
::Post.stub!(:content_columns).and_return([mock('column', :name => 'title'), mock('column', :name => 'body'), mock('column', :name => 'created_at')])
|
244
252
|
::Author.stub!(:find).and_return([@fred, @bob])
|
245
253
|
|
246
254
|
@new_post.stub!(:title)
|
@@ -352,12 +360,15 @@ describe 'SemanticFormBuilder#inputs' do
|
|
352
360
|
describe 'with column names and an options hash as args' do
|
353
361
|
before do
|
354
362
|
semantic_form_for(@new_post) do |builder|
|
355
|
-
|
363
|
+
@legend_text_using_option = "Legendary Legend Text"
|
364
|
+
@legend_text_using_arg = "Legendary Legend Text 2"
|
365
|
+
concat(builder.inputs(:title, :body, :name => @legend_text_using_option, :id => "my-id"))
|
366
|
+
concat(builder.inputs(@legend_text_using_arg, :title, :body, :id => "my-id-2"))
|
356
367
|
end
|
357
368
|
end
|
358
369
|
|
359
370
|
it 'should render a form with a fieldset containing two list items' do
|
360
|
-
output_buffer.should have_tag('form > fieldset.inputs > ol > li', :count =>
|
371
|
+
output_buffer.should have_tag('form > fieldset.inputs > ol > li', :count => 4)
|
361
372
|
end
|
362
373
|
|
363
374
|
it 'should pass the options down to the fieldset' do
|
@@ -365,7 +376,8 @@ describe 'SemanticFormBuilder#inputs' do
|
|
365
376
|
end
|
366
377
|
|
367
378
|
it 'should use the special :name option as a text for the legend tag' do
|
368
|
-
output_buffer.should have_tag('form > fieldset#my-id.inputs > legend',
|
379
|
+
output_buffer.should have_tag('form > fieldset#my-id.inputs > legend', /^#{@legend_text_using_option}$/)
|
380
|
+
output_buffer.should have_tag('form > fieldset#my-id-2.inputs > legend', /^#{@legend_text_using_arg}$/)
|
369
381
|
end
|
370
382
|
end
|
371
383
|
|
data/spec/label_spec.rb
CHANGED
@@ -16,12 +16,6 @@ describe 'SemanticFormBuilder#label' do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
it 'should be printed as span' do
|
20
|
-
semantic_form_for(@new_post) do |builder|
|
21
|
-
builder.label(:login, nil, { :required => true, :as_span => true }).should have_tag('span.label abbr')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
19
|
describe 'when required is given' do
|
26
20
|
it 'should append a required note' do
|
27
21
|
semantic_form_for(@new_post) do |builder|
|
@@ -14,7 +14,7 @@ describe 'SemanticFormBuilder#semantic_fields_for' do
|
|
14
14
|
it 'yields an instance of SemanticFormHelper.builder' do
|
15
15
|
semantic_form_for(@new_post) do |builder|
|
16
16
|
builder.semantic_fields_for(:author) do |nested_builder|
|
17
|
-
nested_builder.class.should == Formtastic::SemanticFormHelper.builder
|
17
|
+
nested_builder.class.should == ::Formtastic::SemanticFormHelper.builder
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -27,9 +27,8 @@ Spec::Runner.configure do |config|
|
|
27
27
|
config.include(CustomMacros)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
|
31
31
|
|
32
|
-
require 'formtastic'
|
33
32
|
|
34
33
|
module FormtasticSpecHelper
|
35
34
|
include ActionView::Helpers::FormHelper
|
@@ -116,6 +115,7 @@ module FormtasticSpecHelper
|
|
116
115
|
::Author.stub!(:human_name).and_return('::Author')
|
117
116
|
::Author.stub!(:reflect_on_validations_for).and_return([])
|
118
117
|
::Author.stub!(:reflect_on_association).and_return { |column_name| mock('reflection', :options => {}, :klass => Post, :macro => :has_many) if column_name == :posts }
|
118
|
+
::Author.stub!(:content_columns).and_return([mock('column', :name => 'login'), mock('column', :name => 'created_at')])
|
119
119
|
|
120
120
|
# Sometimes we need a mock @post object and some Authors for belongs_to
|
121
121
|
@new_post = mock('post')
|
@@ -153,11 +153,13 @@ module FormtasticSpecHelper
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
::Post.stub!(:find).and_return([@freds_post])
|
156
|
+
::Post.stub!(:content_columns).and_return([mock('column', :name => 'title'), mock('column', :name => 'body'), mock('column', :name => 'created_at')])
|
156
157
|
|
157
158
|
@new_post.stub!(:title)
|
158
159
|
@new_post.stub!(:body)
|
159
160
|
@new_post.stub!(:published)
|
160
161
|
@new_post.stub!(:publish_at)
|
162
|
+
@new_post.stub!(:created_at)
|
161
163
|
@new_post.stub!(:secret)
|
162
164
|
@new_post.stub!(:time_zone)
|
163
165
|
@new_post.stub!(:category_name)
|
metadata
CHANGED
@@ -1,18 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formtastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin French
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-23 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: actionpack
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec-rails
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.2.6
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: hpricot
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.6.1
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_hpricot_matchers
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.0.0
|
64
|
+
version:
|
16
65
|
description: A Rails form builder plugin/gem with semantically rich and accessible markup
|
17
66
|
email: justin@indent.com.au
|
18
67
|
executables: []
|
@@ -35,6 +84,7 @@ files:
|
|
35
84
|
- generators/formtastic/templates/formtastic_changes.css
|
36
85
|
- generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb
|
37
86
|
- lib/formtastic.rb
|
87
|
+
- lib/formtastic/i18n.rb
|
38
88
|
- lib/locale/en.yml
|
39
89
|
- rails/init.rb
|
40
90
|
- spec/buttons_spec.rb
|
@@ -44,6 +94,7 @@ files:
|
|
44
94
|
- spec/error_proc_spec.rb
|
45
95
|
- spec/errors_spec.rb
|
46
96
|
- spec/form_helper_spec.rb
|
97
|
+
- spec/i18n_spec.rb
|
47
98
|
- spec/include_blank_spec.rb
|
48
99
|
- spec/input_spec.rb
|
49
100
|
- spec/inputs/boolean_input_spec.rb
|
@@ -70,7 +121,7 @@ has_rdoc: true
|
|
70
121
|
homepage: http://github.com/justinfrench/formtastic/tree/master
|
71
122
|
licenses: []
|
72
123
|
|
73
|
-
post_install_message: "\n ========================================================================\n Thanks for installing Formtastic!\n
|
124
|
+
post_install_message: "\n ========================================================================\n Thanks for installing Formtastic!\n ------------------------------------------------------------------------\n You can now (optionally) run the generater to copy some stylesheets and\n a config initializer into your application:\n ./script/generate formtastic\n\n To generate some semantic form markup for your exisiting models, just run:\n ./script/generate form MODEL_NAME\n\n Find out more and get involved:\n http://github.com/justinfrench/formtastic\n http://groups.google.com.au/group/formtastic\n ========================================================================\n "
|
74
125
|
rdoc_options:
|
75
126
|
- --charset=UTF-8
|
76
127
|
require_paths:
|
@@ -102,6 +153,7 @@ test_files:
|
|
102
153
|
- spec/error_proc_spec.rb
|
103
154
|
- spec/errors_spec.rb
|
104
155
|
- spec/form_helper_spec.rb
|
156
|
+
- spec/i18n_spec.rb
|
105
157
|
- spec/include_blank_spec.rb
|
106
158
|
- spec/input_spec.rb
|
107
159
|
- spec/inputs/boolean_input_spec.rb
|