formulaic 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/formulaic/form.rb +1 -0
- data/lib/formulaic/inputs/checkbox_input.rb +10 -1
- data/lib/formulaic/version.rb +1 -1
- data/spec/features/fill_in_user_form_spec.rb +18 -0
- data/spec/fixtures/user_form.html +13 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e824316e6057f6205ce73483ffbd7f513d4a02a6
|
4
|
+
data.tar.gz: 778f34355e21e73ca38564f5163781d4ae34474f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dc66a2e7bca50643c48344247a6912f2f5d1645b1b4141f25af2b94042b970307417f5e7f2949d9fcd53fe3eccaa534bf5ad719de5171d8f2f996250c0526bb
|
7
|
+
data.tar.gz: cd453dffc6b4d9c381ef65d8c52119234c1b3d38adf9ce89272bc5efd4b9467ec7cc2f8341f1df8de45938f21d501b6ae86ca667d708774c5f455859a9d00bff
|
data/lib/formulaic/form.rb
CHANGED
@@ -9,6 +9,7 @@ module Formulaic
|
|
9
9
|
Array => Formulaic::Inputs::ArrayInput,
|
10
10
|
String => Formulaic::Inputs::StringInput,
|
11
11
|
Fixnum => Formulaic::Inputs::StringInput,
|
12
|
+
Float => Formulaic::Inputs::StringInput,
|
12
13
|
TrueClass => Formulaic::Inputs::BooleanInput,
|
13
14
|
FalseClass => Formulaic::Inputs::BooleanInput,
|
14
15
|
File => Formulaic::Inputs::FileInput,
|
@@ -28,8 +28,17 @@ module Formulaic
|
|
28
28
|
"input[type='checkbox'][name='#{label.model_name}[#{label.attribute}][]']"
|
29
29
|
end
|
30
30
|
|
31
|
+
def checkbox_name_selector_for_association
|
32
|
+
"input[type='checkbox'][name='#{label.model_name}[#{label.attribute.to_s.singularize}_ids][]']"
|
33
|
+
end
|
34
|
+
|
31
35
|
def checkbox_labels_selector
|
32
|
-
|
36
|
+
[
|
37
|
+
"#{checkbox_name_selector} ~ label",
|
38
|
+
"label:has(#{checkbox_name_selector})",
|
39
|
+
"#{checkbox_name_selector_for_association} ~ label",
|
40
|
+
"label:has(#{checkbox_name_selector_for_association})",
|
41
|
+
].join(",")
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
data/lib/formulaic/version.rb
CHANGED
@@ -117,6 +117,15 @@ describe 'Fill in user form' do
|
|
117
117
|
expect(input(:user, :age).value).to eq '10'
|
118
118
|
end
|
119
119
|
|
120
|
+
it 'finds an fills in a number field which is a float' do
|
121
|
+
visit 'user_form'
|
122
|
+
form = Formulaic::Form.new(:user, :new, score: 23.53)
|
123
|
+
|
124
|
+
form.fill
|
125
|
+
|
126
|
+
expect(input(:user, :score).value).to eq '23.53'
|
127
|
+
end
|
128
|
+
|
120
129
|
it 'raises a useful error if selecting multiple from a normal select' do
|
121
130
|
visit 'user_form'
|
122
131
|
form = Formulaic::Form.new(:user, :new, awesome: ['Yes', 'No'])
|
@@ -206,4 +215,13 @@ describe 'Fill in user form' do
|
|
206
215
|
expect(page.find('#event_ends_on_3i').value).to eq('31')
|
207
216
|
end
|
208
217
|
|
218
|
+
it 'knows to use _ids for association fields' do
|
219
|
+
visit 'user_form'
|
220
|
+
|
221
|
+
form = Formulaic::Form.new(:user, :new, friends: ['Caleb'])
|
222
|
+
|
223
|
+
form.fill
|
224
|
+
|
225
|
+
expect(page.find('#user_friend_ids_1')).to be_checked
|
226
|
+
end
|
209
227
|
end
|
@@ -7,6 +7,8 @@
|
|
7
7
|
<div class="input tel required user_phone"><label class="tel required" for="user_phone"><abbr title="required">*</abbr> Phone Number</label><input class="string phone required" id="user_phone" maxlength="255" name="user[phone]" size="50" type="tel"></div>
|
8
8
|
<div class="input integer required user_age"><label class="integer required"
|
9
9
|
for="user_age"><abbr title="required">*</abbr> Your Age</label><input class="numeric integer age required" id="user_age" maxlength="255" name="user[age]" size="50" type="number"></div>
|
10
|
+
<div class="input decimal required user_score"><label class="decimal required"
|
11
|
+
for="user_score"><abbr title="required">*</abbr> Your Score</label><input class="numeric decimal score required" id="user_score" maxlength="255" name="user[score]" size="50" type="number"></div>
|
10
12
|
<div class="input url required user_url"><label class="tel required" for="user_url"><abbr title="required">*</abbr> Website</label><input class="string url required" id="user_url" maxlength="255" name="user[url]" size="50" type="url"></div>
|
11
13
|
<div class="input file optional user_avatar"><label class="file optional"
|
12
14
|
for="user_avatar">Your Avatar</label><input class="file optional" id="user_avatar" name="user[avatar]" type="file" /></div>
|
@@ -43,6 +45,17 @@
|
|
43
45
|
</span>
|
44
46
|
<input name="user[dislikes][]" type="hidden" value="">
|
45
47
|
</div>
|
48
|
+
<div class="input check_boxes optional user_friends">
|
49
|
+
<label class="check_boxes optional">Friends</label>
|
50
|
+
<span class="checkbox">
|
51
|
+
<label for="user_friend_ids_1">
|
52
|
+
<input class="check_boxes optional" type="checkbox" value="1" name="user[friend_ids][]" id="user_friend_ids_1">
|
53
|
+
Caleb
|
54
|
+
</label>
|
55
|
+
</span>
|
56
|
+
<input type="hidden" name="user[friend_ids][]" value="">
|
57
|
+
</div>
|
58
|
+
|
46
59
|
<div class="input text required user_bio"><label class="text required"
|
47
60
|
for="user_bio"><abbr title="required">*</abbr> Your Biography</label><textarea class="text required" cols="40" id="user_bio" name="user[bio]" rows="20" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 464px;"></textarea></div>
|
48
61
|
<div class="input date required user_date_of_birth">
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formulaic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.4.
|
177
|
+
rubygems_version: 2.4.6
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Simplify form filling with Capybara
|