erb_form 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,7 +47,7 @@ module ErbForm
47
47
  end
48
48
 
49
49
  def locals(attribute_name, options)
50
- options.except(:form, :attribute_name, :as, :error, :hint, :input, :label).tap { |o|
50
+ options.except(:form, :attribute_name, :as, :collection, :error, :hint, :input, :label).tap { |o|
51
51
  o[:form] = self
52
52
  o[:attribute_name] = attribute_name
53
53
  o[:error_options] = simplify_options(:error, options)
@@ -75,6 +75,7 @@ module ErbForm
75
75
  when :input
76
76
  locals = { :input_html => options[:input] }
77
77
  locals[:as] = options[:as] if options.has_key?(:as)
78
+ locals[:collection] = options[:collection] if options.has_key?(:collection)
78
79
  :input_html
79
80
  else
80
81
  locals = { key => options[key] }
@@ -1,3 +1,3 @@
1
1
  module ErbForm
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,5 @@
1
+ <%= form_for(@blog) do |f| %>
2
+ <fieldset>
3
+ <%= f.field :name, { :collection => ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA'] } %>
4
+ </fieldset>
5
+ <% end %>
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe "blogs/render_input_as_a_collection" do
4
+ before(:each) do
5
+ assign(:blog, stub_model(Blog,
6
+ :name => "",
7
+ ).as_new_record)
8
+ end
9
+
10
+ describe "when the as option is passed" do
11
+ it "finds the correct layout file" do
12
+ render
13
+ rendered.should have_selector "div", :class => "blogs_name_field"
14
+ end
15
+
16
+ it "renders the input as that type" do
17
+ render
18
+ rendered.should have_selector "select", :id => 'blog_name'
19
+ rendered.should have_selector "option", :value => 'ACT'
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simple_form
16
- requirement: &2152499440 !ruby/object:Gem::Requirement
16
+ requirement: &2152479800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 2.0.0.rc
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152499440
24
+ version_requirements: *2152479800
25
25
  description: Wrap form helper methods in re-usable erb templates.
26
26
  email:
27
27
  - 23inhouse@gmail.com
@@ -55,6 +55,7 @@ files:
55
55
  - spec/test_app/app/views/blogs/missing_layout_template_error.html.erb
56
56
  - spec/test_app/app/views/blogs/name_field.html.erb
57
57
  - spec/test_app/app/views/blogs/render_field_with_extra_options.html.erb
58
+ - spec/test_app/app/views/blogs/render_input_as_a_collection.html.erb
58
59
  - spec/test_app/app/views/blogs/render_input_as_different_type.html.erb
59
60
  - spec/test_app/app/views/blogs/render_multiple_layouts.html.erb
60
61
  - spec/test_app/app/views/blogs/render_simple_form_with_options.html.erb
@@ -92,6 +93,7 @@ files:
92
93
  - spec/test_app/spec/views/blogs/missing_attribute_template_error.html.erb_spec.rb
93
94
  - spec/test_app/spec/views/blogs/missing_layout_template_error.html.erb_spec.rb
94
95
  - spec/test_app/spec/views/blogs/render_field_with_extra_options.html.erb_spec.rb
96
+ - spec/test_app/spec/views/blogs/render_input_as_a_collection.html.erb_spec.rb
95
97
  - spec/test_app/spec/views/blogs/render_input_as_different_type.html.erb_spec
96
98
  - spec/test_app/spec/views/blogs/render_multiple_layouts.html.erb_spec.rb
97
99
  - spec/test_app/spec/views/blogs/render_simple_form_with_options.html.erb_spec.rb
@@ -140,6 +142,7 @@ test_files:
140
142
  - spec/test_app/app/views/blogs/missing_layout_template_error.html.erb
141
143
  - spec/test_app/app/views/blogs/name_field.html.erb
142
144
  - spec/test_app/app/views/blogs/render_field_with_extra_options.html.erb
145
+ - spec/test_app/app/views/blogs/render_input_as_a_collection.html.erb
143
146
  - spec/test_app/app/views/blogs/render_input_as_different_type.html.erb
144
147
  - spec/test_app/app/views/blogs/render_multiple_layouts.html.erb
145
148
  - spec/test_app/app/views/blogs/render_simple_form_with_options.html.erb
@@ -177,6 +180,7 @@ test_files:
177
180
  - spec/test_app/spec/views/blogs/missing_attribute_template_error.html.erb_spec.rb
178
181
  - spec/test_app/spec/views/blogs/missing_layout_template_error.html.erb_spec.rb
179
182
  - spec/test_app/spec/views/blogs/render_field_with_extra_options.html.erb_spec.rb
183
+ - spec/test_app/spec/views/blogs/render_input_as_a_collection.html.erb_spec.rb
180
184
  - spec/test_app/spec/views/blogs/render_input_as_different_type.html.erb_spec
181
185
  - spec/test_app/spec/views/blogs/render_multiple_layouts.html.erb_spec.rb
182
186
  - spec/test_app/spec/views/blogs/render_simple_form_with_options.html.erb_spec.rb