array_form_helper 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +103 -0
- data/Rakefile +11 -0
- data/array_form_helper.gemspec +31 -0
- data/lib/array_form_helper.rb +8 -0
- data/lib/array_form_helper/form_builder.rb +13 -0
- data/lib/array_form_helper/form_helper.rb +29 -0
- data/lib/array_form_helper/version.rb +3 -0
- data/test/array_form_builder_test.rb +178 -0
- data/test/array_form_helper_test.rb +30 -0
- data/test/minitest_helper.rb +23 -0
- data/test/support/person.rb +5 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b467f759f2f931af4f4dc4419f0661be172ba0a
|
4
|
+
data.tar.gz: 71f46f92efadc8139100d28d82ecce0776de549a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 112b14fd6539a8193aad4f0cdd95acd7a680d317ce28c6ed8f319a56ad51b567710ff2d97a6be5cdeac43c80047b0364215a2a774e911f4e77057311ef03a853
|
7
|
+
data.tar.gz: 3445c0af0b0ae7bfe6fb6cecb5108a5c9a3c1cb44fe3a8853ededa35f8a06c6fdfe85f603ada7e7395e5dd18afe67dd7a8ac26299312d404f291ce1e3843fe0e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 yuuji.yaginuma
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# ArrayFormHelper
|
2
|
+
|
3
|
+
[](https://travis-ci.org/y-yagi/array_form_helper)
|
4
|
+
[](https://coveralls.io/r/y-yagi/array_form_helper)
|
5
|
+
[](https://codeclimate.com/github/y-yagi/array_form_helper)
|
6
|
+
|
7
|
+
ArrayFormHelper provides some form helper methods to use array column in Rails.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'array_form_helper'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install array_form_helper
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
ArrayFormHelper provides methods is a format that added a prefix called "array\_" to a method of rails provides helper method. For example, it is like `array_text_field`, `array_email_field`.
|
28
|
+
|
29
|
+
You can appoint array size with `array_size` option. Other option can set contents same as an original method.
|
30
|
+
|
31
|
+
### Example
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# migration file
|
35
|
+
class CreateBooks < ActiveRecord::Migration
|
36
|
+
def change
|
37
|
+
create_table :books do |t|
|
38
|
+
t.string :name
|
39
|
+
t.string :tags, array: true
|
40
|
+
|
41
|
+
t.timestamps null: false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# controller
|
49
|
+
def book_params
|
50
|
+
# need permit of array
|
51
|
+
params.require(:book).permit(:name, tags: [])
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# form
|
57
|
+
<%= form_for(@book) do |f| %>
|
58
|
+
<div class="field">
|
59
|
+
<%= f.label :name %><br>
|
60
|
+
<%= f.text_field :name %>
|
61
|
+
</div>
|
62
|
+
<div class="field">
|
63
|
+
<%= f.label :tags %><br>
|
64
|
+
<%= f.array_text_field :tags, array_size: 3 %>
|
65
|
+
</div>
|
66
|
+
<div class="actions">
|
67
|
+
<%= f.submit %>
|
68
|
+
</div>
|
69
|
+
<% end %>
|
70
|
+
```
|
71
|
+
The code generates following HTML.
|
72
|
+
|
73
|
+
```html
|
74
|
+
<form class="new_book" id="new_book" action="/books" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓" /><input type="hidden" name="authenticity_token" value="Nu05ebKkwQEfvACgAu+N1TskwoCeAXyhbVDNROrVR69yWH24IJ7JiXetwrSOnsZX19ZwdSH96FAnuKlxy5prwQ==" />
|
75
|
+
<div class="field">
|
76
|
+
<label for="book_name">Name</label><br>
|
77
|
+
<input type="text" name="book[name]" id="book_name" />
|
78
|
+
</div>
|
79
|
+
<div class="field">
|
80
|
+
<label for="book_tags">Tags</label><br>
|
81
|
+
<input name="book[tags][]" id="book_tags_0" type="text" /><input name="book[tags][]" id="book_tags_1" type="text" /><input name="book[tags][]" id="book_tags_2" type="text" />
|
82
|
+
</div>
|
83
|
+
<div class="actions">
|
84
|
+
<input type="submit" name="commit" value="Create Book" />
|
85
|
+
</div>
|
86
|
+
</form>
|
87
|
+
```
|
88
|
+
|
89
|
+
### Methods
|
90
|
+
|
91
|
+
The methods supporting are as follows now.
|
92
|
+
|
93
|
+
`array_text_field`, `array_text_area`, `array_color_field`, `array_search_field`, `array_telephone_field`
|
94
|
+
`array_phone_field`, `array_date_field`, `array_time_field`, `array_datetime_field`
|
95
|
+
`array_datetime_local_field`, `array_month_field`, `array_week_field`, `array_url_field`
|
96
|
+
|
97
|
+
## Contributing
|
98
|
+
|
99
|
+
1. Fork it ( https://github.com/y-yagi/array_form_helper/fork )
|
100
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
101
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
102
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
103
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'array_form_helper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'array_form_helper'
|
8
|
+
spec.version = ArrayFormHelper::VERSION
|
9
|
+
spec.authors = ['Yuji Yaginuma']
|
10
|
+
spec.email = ['yuuji.yaginuma@gmail.com']
|
11
|
+
spec.summary = %q{A Rails plugin that provides some form helper methods for use array column.}
|
12
|
+
|
13
|
+
spec.homepage = 'https://github.com/y-yagi/array_form_helper'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'actionpack', '>= 4.0'
|
22
|
+
spec.add_development_dependency 'activemodel', '>= 4.0'
|
23
|
+
spec.add_development_dependency 'activesupport', '>= 4.0'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'minitest'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3.3'
|
29
|
+
spec.add_development_dependency 'coveralls'
|
30
|
+
spec.add_development_dependency 'rails-dom-testing'
|
31
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
require 'action_controller'
|
3
|
+
require 'array_form_helper/version'
|
4
|
+
require 'array_form_helper/form_builder'
|
5
|
+
require 'array_form_helper/form_helper'
|
6
|
+
|
7
|
+
ActionView::Helpers::FormBuilder.send(:include, ArrayFormHelper::FormBuilder)
|
8
|
+
ActionController::Base.helper ArrayFormHelper::FormHelper
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'array_form_helper/form_helper'
|
2
|
+
module ArrayFormHelper
|
3
|
+
module FormBuilder
|
4
|
+
ArrayFormHelper::FormHelper::ARRAY_FIELD_HELPERS.each do |selector|
|
5
|
+
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
6
|
+
def array_#{selector}(method, options = {})
|
7
|
+
options[:value] = @object.public_send(method)
|
8
|
+
@template.array_#{selector}(@object_name, method, objectify_options(options))
|
9
|
+
end
|
10
|
+
RUBY_EVAL
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ArrayFormHelper
|
2
|
+
module FormHelper
|
3
|
+
ARRAY_FIELD_HELPERS = [
|
4
|
+
:text_field, :text_area, :color_field, :search_field, :telephone_field,
|
5
|
+
:phone_field, :date_field, :time_field, :datetime_field,
|
6
|
+
:datetime_local_field, :month_field, :week_field, :url_field,
|
7
|
+
:email_field, :number_field, :range_field
|
8
|
+
]
|
9
|
+
|
10
|
+
ARRAY_FIELD_HELPERS.each do |selector|
|
11
|
+
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
12
|
+
def array_#{selector}(object_name, method, options = {})
|
13
|
+
options[:name] = "%s[%s][]" % [object_name, method]
|
14
|
+
if options[:array_size]
|
15
|
+
array_size = options.delete(:array_size).to_i
|
16
|
+
value = options.delete(:value) if options[:value]
|
17
|
+
array_size.times.map do |i|
|
18
|
+
options[:value] = value[i] if value && value.is_a?(Array)
|
19
|
+
options[:id] = "%s_%s_%s" % [object_name, method, i]
|
20
|
+
#{selector}(object_name, method, options)
|
21
|
+
end.join.html_safe
|
22
|
+
else
|
23
|
+
#{selector}(object_name, method, options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
RUBY_EVAL
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
class ArrayFormBuilderTest < MiniTest::Test
|
4
|
+
include ArrayFormHelper::TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
setup_controller
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_array_text_field_without_array_size_option
|
11
|
+
setup_form
|
12
|
+
|
13
|
+
actual = @f.array_text_field(:tags)
|
14
|
+
expected = %(<input name="person[tags][]" type="text" id="person_tags" />)
|
15
|
+
assert_dom_equal expected, actual
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_array_text_field_with_array_size_option
|
19
|
+
setup_form
|
20
|
+
|
21
|
+
actual = @f.array_text_field(:tags, { array_size: 2 })
|
22
|
+
expected = %(<input name="person[tags][]" type="text" id="person_tags_0" />) +
|
23
|
+
%(<input name="person[tags][]" type="text" id="person_tags_1" />)
|
24
|
+
assert_dom_equal expected, actual
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_array_text_field_with_value
|
28
|
+
setup_form(tags: %w(sports art))
|
29
|
+
|
30
|
+
actual = @f.array_text_field(:tags, array_size: 3)
|
31
|
+
expected = %(<input name="person[tags][]" value="sports" type="text" id="person_tags_0" />) +
|
32
|
+
%(<input name="person[tags][]" value="art" type="text" id="person_tags_1" />) +
|
33
|
+
%(<input name="person[tags][]" type="text" id="person_tags_2" />)
|
34
|
+
assert_dom_equal expected, actual
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_array_text_area_with_array_size_option
|
38
|
+
setup_form
|
39
|
+
|
40
|
+
actual = @f.array_text_area(:tags, { array_size: 2 })
|
41
|
+
expected = %(<textarea name="person[tags][]" id="person_tags_0">\n</textarea>) +
|
42
|
+
%(<textarea name="person[tags][]" id="person_tags_1">\n</textarea>)
|
43
|
+
assert_dom_equal expected, actual
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_array_color_field_with_array_size_option
|
47
|
+
setup_form
|
48
|
+
|
49
|
+
actual = @f.array_color_field(:tags, { array_size: 2 })
|
50
|
+
expected = %(<input value="#000000" name="person[tags][]" type="color" id="person_tags_0" />) +
|
51
|
+
%(<input value="#000000" name="person[tags][]" type="color" id="person_tags_1" />)
|
52
|
+
assert_dom_equal expected, actual
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_array_search_field_with_array_size_option
|
56
|
+
setup_form
|
57
|
+
|
58
|
+
actual = @f.array_search_field(:tags, { array_size: 2 })
|
59
|
+
expected = %(<input name="person[tags][]" type="search" id="person_tags_0" />) +
|
60
|
+
%(<input name="person[tags][]" type="search" id="person_tags_1" />)
|
61
|
+
assert_dom_equal expected, actual
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_array_telephone_field_with_array_size_option
|
65
|
+
setup_form
|
66
|
+
|
67
|
+
actual = @f.array_telephone_field(:tags, { array_size: 2 })
|
68
|
+
expected = %(<input name="person[tags][]" type="tel" id="person_tags_0" />) +
|
69
|
+
%(<input name="person[tags][]" type="tel" id="person_tags_1" />)
|
70
|
+
assert_dom_equal expected, actual
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_array_phone_field_with_array_size_option
|
74
|
+
setup_form
|
75
|
+
|
76
|
+
actual = @f.array_phone_field(:tags, { array_size: 2 })
|
77
|
+
expected = %(<input name="person[tags][]" type="tel" id="person_tags_0" />) +
|
78
|
+
%(<input name="person[tags][]" type="tel" id="person_tags_1" />)
|
79
|
+
assert_dom_equal expected, actual
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_array_date_field_with_array_size_option
|
83
|
+
setup_form
|
84
|
+
|
85
|
+
actual = @f.array_date_field(:tags, { array_size: 2 })
|
86
|
+
expected = %(<input name="person[tags][]" type="date" id="person_tags_0" />) +
|
87
|
+
%(<input name="person[tags][]" type="date" id="person_tags_1" />)
|
88
|
+
assert_dom_equal expected, actual
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_array_time_field_with_array_size_option
|
92
|
+
setup_form
|
93
|
+
|
94
|
+
actual = @f.array_time_field(:tags, { array_size: 2 })
|
95
|
+
expected = %(<input name="person[tags][]" type="time" id="person_tags_0" />) +
|
96
|
+
%(<input name="person[tags][]" type="time" id="person_tags_1" />)
|
97
|
+
assert_dom_equal expected, actual
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_array_text_datetime_with_array_size_option
|
101
|
+
setup_form
|
102
|
+
|
103
|
+
actual = @f.array_datetime_field(:tags, { array_size: 2 })
|
104
|
+
expected = %(<input name="person[tags][]" type="datetime" id="person_tags_0" />) +
|
105
|
+
%(<input name="person[tags][]" type="datetime" id="person_tags_1" />)
|
106
|
+
assert_dom_equal expected, actual
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_array_datetime_local_field_with_array_size_option
|
110
|
+
setup_form
|
111
|
+
|
112
|
+
actual = @f.array_datetime_local_field(:tags, { array_size: 2 })
|
113
|
+
expected = %(<input name="person[tags][]" type="datetime-local" id="person_tags_0" />) +
|
114
|
+
%(<input name="person[tags][]" type="datetime-local" id="person_tags_1" />)
|
115
|
+
assert_dom_equal expected, actual
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_array_month_field_with_array_size_option
|
119
|
+
setup_form
|
120
|
+
|
121
|
+
actual = @f.array_month_field(:tags, { array_size: 2 })
|
122
|
+
expected = %(<input name="person[tags][]" type="month" id="person_tags_0" />) +
|
123
|
+
%(<input name="person[tags][]" type="month" id="person_tags_1" />)
|
124
|
+
assert_dom_equal expected, actual
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_array_week_field_with_array_size_option
|
128
|
+
setup_form
|
129
|
+
|
130
|
+
actual = @f.array_week_field(:tags, { array_size: 2 })
|
131
|
+
expected = %(<input name="person[tags][]" type="week" id="person_tags_0" />) +
|
132
|
+
%(<input name="person[tags][]" type="week" id="person_tags_1" />)
|
133
|
+
assert_dom_equal expected, actual
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_array_url_field_with_array_size_option
|
137
|
+
setup_form
|
138
|
+
|
139
|
+
actual = @f.array_url_field(:tags, { array_size: 2 })
|
140
|
+
expected = %(<input name="person[tags][]" type="url" id="person_tags_0" />) +
|
141
|
+
%(<input name="person[tags][]" type="url" id="person_tags_1" />)
|
142
|
+
assert_dom_equal expected, actual
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_array_email_field_with_array_size_option
|
146
|
+
setup_form
|
147
|
+
|
148
|
+
actual = @f.array_email_field(:tags, { array_size: 2 })
|
149
|
+
expected = %(<input name="person[tags][]" type="email" id="person_tags_0" />) +
|
150
|
+
%(<input name="person[tags][]" type="email" id="person_tags_1" />)
|
151
|
+
assert_dom_equal expected, actual
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_array_number_field_with_array_size_option
|
155
|
+
setup_form
|
156
|
+
|
157
|
+
actual = @f.array_number_field(:tags, { array_size: 2 })
|
158
|
+
expected = %(<input name="person[tags][]" type="number" id="person_tags_0" />) +
|
159
|
+
%(<input name="person[tags][]" type="number" id="person_tags_1" />)
|
160
|
+
assert_dom_equal expected, actual
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_array_range_field_with_array_size_option
|
164
|
+
setup_form
|
165
|
+
|
166
|
+
actual = @f.array_range_field(:tags, { array_size: 2 })
|
167
|
+
expected = %(<input name="person[tags][]" type="range" id="person_tags_0" />) +
|
168
|
+
%(<input name="person[tags][]" type="range" id="person_tags_1" />)
|
169
|
+
assert_dom_equal expected, actual
|
170
|
+
end
|
171
|
+
|
172
|
+
private
|
173
|
+
|
174
|
+
def setup_form(object_params = nil)
|
175
|
+
p = Person.new(object_params)
|
176
|
+
@controller.view_context.form_for(p) { |f| @f = f }
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
class ArrayFormHelperTest < MiniTest::Test
|
4
|
+
include ArrayFormHelper::TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
setup_controller
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_array_text_field_without_array_size_option
|
11
|
+
actual = @controller.view_context.array_text_field(:person, :tags)
|
12
|
+
expected = %(<input name="person[tags][]" type="text" id="person_tags" />)
|
13
|
+
assert_dom_equal expected, actual
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_array_text_field_with_array_size_option
|
17
|
+
actual = @controller.view_context.array_text_field(:person, :tags, { array_size: 2 })
|
18
|
+
expected = %(<input name="person[tags][]" type="text" id="person_tags_0" />) +
|
19
|
+
%(<input name="person[tags][]" type="text" id="person_tags_1" />)
|
20
|
+
assert_dom_equal expected, actual
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_array_text_field_with_value
|
24
|
+
actual = @controller.view_context.array_text_field(:person, :tags, { array_size: 3, value: %w(sports art) })
|
25
|
+
expected = %(<input name="person[tags][]" value="sports" type="text" id="person_tags_0" />) +
|
26
|
+
%(<input name="person[tags][]" value="art" type="text" id="person_tags_1" />) +
|
27
|
+
%(<input name="person[tags][]" type="text" id="person_tags_2" />)
|
28
|
+
assert_dom_equal expected, actual
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
require 'array_form_helper'
|
7
|
+
require 'support/person'
|
8
|
+
require 'minitest/autorun'
|
9
|
+
require 'pry'
|
10
|
+
require 'rails/dom/testing/assertions/dom_assertions'
|
11
|
+
|
12
|
+
module ArrayFormHelper::TestHelper
|
13
|
+
def setup_controller
|
14
|
+
router = ActionDispatch::Routing::RouteSet.new
|
15
|
+
router.draw { resources :people }
|
16
|
+
@controller = ActionView::TestCase::TestController.new
|
17
|
+
@controller.instance_variable_set(:@_routes, router)
|
18
|
+
@controller.class_eval { include router.url_helpers }
|
19
|
+
@controller.view_context_class.class_eval { include router.url_helpers }
|
20
|
+
end
|
21
|
+
|
22
|
+
include ::Rails::Dom::Testing::Assertions::DomAssertions
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: array_form_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuji Yaginuma
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: actionpack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.3.3
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.3.3
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: coveralls
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rails-dom-testing
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description:
|
154
|
+
email:
|
155
|
+
- yuuji.yaginuma@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".travis.yml"
|
162
|
+
- Gemfile
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.md
|
165
|
+
- Rakefile
|
166
|
+
- array_form_helper.gemspec
|
167
|
+
- lib/array_form_helper.rb
|
168
|
+
- lib/array_form_helper/form_builder.rb
|
169
|
+
- lib/array_form_helper/form_helper.rb
|
170
|
+
- lib/array_form_helper/version.rb
|
171
|
+
- test/array_form_builder_test.rb
|
172
|
+
- test/array_form_helper_test.rb
|
173
|
+
- test/minitest_helper.rb
|
174
|
+
- test/support/person.rb
|
175
|
+
homepage: https://github.com/y-yagi/array_form_helper
|
176
|
+
licenses:
|
177
|
+
- MIT
|
178
|
+
metadata: {}
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 2.4.5
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: A Rails plugin that provides some form helper methods for use array column.
|
199
|
+
test_files:
|
200
|
+
- test/array_form_builder_test.rb
|
201
|
+
- test/array_form_helper_test.rb
|
202
|
+
- test/minitest_helper.rb
|
203
|
+
- test/support/person.rb
|