formulaic 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f3bb41653f105138a4e6b8000926309388b3fc1
4
- data.tar.gz: a6186759dd0fa86fe0b3c728ee9a9b90fa2d4192
3
+ metadata.gz: c026f02fa3953de98d1ba4a0fccaa6c819dc7b7a
4
+ data.tar.gz: 26a4272f43171165d273e1795c2cf42d2c589041
5
5
  SHA512:
6
- metadata.gz: 38fbdee254c72c6ea83472da44b41a2fb205d9f7433cb6c4df712362c12789ca82ea2c8326c0114499ad500c7474f84e9ceffcafa0a8150bd8ec35f3870bef5e
7
- data.tar.gz: a27ae91dba89c3e785e8fdbc335702278dd7504b66e9761587eb56435c437646d5a70f6c086220326026a6d75837c8821e984e33c1e23e51520fced82b42eeac
6
+ metadata.gz: 3cb706f8aea2980c8f2d72f279c79c7407ec2074b76349a18bb76683f927966c1acd276ad49d3cf4ed14d66629f2cc07ff082c228fbfc84fab78f758a9a75b44
7
+ data.tar.gz: 61bc168e59c036253db73e52ec7372ef3f8ebef9937e90230ae77d73fc778518fee14d3a5a0f788c80112ef267d1c2fc1e0718da56315c16b443396c47e55768
@@ -1 +1 @@
1
- 2.1.5
1
+ 2.2.0
@@ -1,7 +1,6 @@
1
1
  rvm:
2
- - "2.0.0"
3
- - "2.1.0"
4
- - "2.1.1"
5
- - "2.1.2"
2
+ - "2.0"
3
+ - "2.1"
4
+ - "2.2"
6
5
  notifications:
7
6
  email: false
data/README.md CHANGED
@@ -9,6 +9,9 @@ Formulaic allows you to specify a hash of attributes to be input rather than
9
9
  procedurally calling Capybara’s DSL methods.
10
10
 
11
11
  ## Usage
12
+ ```ruby
13
+ gem 'formulaic', group: :test
14
+ ```
12
15
 
13
16
  ```ruby
14
17
  feature 'New user registration' do
@@ -5,6 +5,7 @@ module Formulaic
5
5
  ATTRIBUTE_INPUT_MAP = {
6
6
  ActiveSupport::TimeWithZone => Formulaic::Inputs::DateInput,
7
7
  Date => Formulaic::Inputs::DateInput,
8
+ DateTime => Formulaic::Inputs::DateTimeInput,
8
9
  Array => Formulaic::Inputs::ArrayInput,
9
10
  String => Formulaic::Inputs::StringInput,
10
11
  Fixnum => Formulaic::Inputs::StringInput,
@@ -2,5 +2,6 @@ require 'formulaic/inputs/input'
2
2
  require 'formulaic/inputs/array_input'
3
3
  require 'formulaic/inputs/boolean_input'
4
4
  require 'formulaic/inputs/date_input'
5
+ require 'formulaic/inputs/date_time_input'
5
6
  require 'formulaic/inputs/string_input'
6
7
  require 'formulaic/inputs/file_input'
@@ -10,7 +10,7 @@ module Formulaic
10
10
  def select_date(date, options)
11
11
  field = find_field(options[:from].to_s)["id"].gsub(/_\di/, "")
12
12
  select date.year.to_s, from: "#{field}_1i"
13
- select Date::MONTHNAMES[date.month], from: "#{field}_2i"
13
+ select I18n.t("date.month_names")[date.month], from: "#{field}_2i"
14
14
  select date.day.to_s, from: "#{field}_3i"
15
15
  end
16
16
  end
@@ -0,0 +1,18 @@
1
+ module Formulaic
2
+ module Inputs
3
+ class DateTimeInput < DateInput
4
+ def fill
5
+ select_date(value, from: label)
6
+ end
7
+
8
+ private
9
+
10
+ def select_date(date_time, options)
11
+ super
12
+ field = find_field(options[:from].to_s)["id"].gsub(/_\di/, "")
13
+ select date_time.hour.to_s, from: "#{field}_4i"
14
+ select date_time.minute.to_s, from: "#{field}_5i"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Formulaic
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -70,6 +70,35 @@ describe 'Fill in user form' do
70
70
  expect(page.find('#user_date_of_birth_3i').value).to eq('2')
71
71
  end
72
72
 
73
+ it 'finds and fills a datetime field' do
74
+ visit 'user_form'
75
+ form = Formulaic::Form.new(:user, :new, date_of_birth: DateTime.new(1980, 1, 2, 10, 30))
76
+
77
+ form.fill
78
+
79
+ expect(page.find('#user_date_of_birth_1i').value).to eq('1980')
80
+ expect(page.find('#user_date_of_birth_2i').value).to eq('1')
81
+ expect(page.find('#user_date_of_birth_3i').value).to eq('2')
82
+ expect(page.find('#user_date_of_birth_4i').value).to eq('10')
83
+ expect(page.find('#user_date_of_birth_5i').value).to eq('30')
84
+ end
85
+
86
+ it 'finds and fills a spanish locale date field' do
87
+ begin
88
+ I18n.locale = :es
89
+ visit 'user_form_es'
90
+ form = Formulaic::Form.new(:user, :new, date_of_birth: Date.new(1980, 1, 2))
91
+
92
+ form.fill
93
+
94
+ expect(page.find('#user_date_of_birth_1i').value).to eq('1980')
95
+ expect(page.find('#user_date_of_birth_2i').value).to eq('1')
96
+ expect(page.find('#user_date_of_birth_3i').value).to eq('2')
97
+ ensure
98
+ I18n.locale = :en
99
+ end
100
+ end
101
+
73
102
  it 'finds and checks a boolean field' do
74
103
  visit 'user_form'
75
104
  form = Formulaic::Form.new(:user, :new, terms_of_service: true)
@@ -199,6 +199,94 @@
199
199
  <option value="30">30</option>
200
200
  <option value="31">31</option>
201
201
  </select>
202
+ <select class="date required" id="user_date_of_birth_4i" name="user[date_of_birth(4i)]">
203
+ <option value="00">00</option>
204
+ <option value="01">01</option>
205
+ <option value="02">02</option>
206
+ <option value="03">03</option>
207
+ <option value="04">04</option>
208
+ <option value="05">05</option>
209
+ <option value="06">06</option>
210
+ <option value="07">07</option>
211
+ <option value="08">08</option>
212
+ <option value="09">09</option>
213
+ <option value="10">10</option>
214
+ <option value="11">11</option>
215
+ <option value="12" selected="selected">12</option>
216
+ <option value="13">13</option>
217
+ <option value="14">14</option>
218
+ <option value="15">15</option>
219
+ <option value="16">16</option>
220
+ <option value="17">17</option>
221
+ <option value="18">18</option>
222
+ <option value="19">19</option>
223
+ <option value="20">20</option>
224
+ <option value="21">21</option>
225
+ <option value="22">22</option>
226
+ <option value="23">23</option>
227
+ </select>
228
+ <select class="date required" id="user_date_of_birth_5i" name="user[date_of_birth(5i)]">
229
+ <option value="00">00</option>
230
+ <option value="01">01</option>
231
+ <option value="02">02</option>
232
+ <option value="03">03</option>
233
+ <option value="04">04</option>
234
+ <option value="05">05</option>
235
+ <option value="06">06</option>
236
+ <option value="07">07</option>
237
+ <option value="08">08</option>
238
+ <option value="09">09</option>
239
+ <option value="10">10</option>
240
+ <option value="11">11</option>
241
+ <option value="12">12</option>
242
+ <option value="13">13</option>
243
+ <option value="14">14</option>
244
+ <option value="15">15</option>
245
+ <option value="16">16</option>
246
+ <option value="17">17</option>
247
+ <option value="18">18</option>
248
+ <option value="19">19</option>
249
+ <option value="20">20</option>
250
+ <option value="21">21</option>
251
+ <option value="22">22</option>
252
+ <option value="23">23</option>
253
+ <option value="24">24</option>
254
+ <option value="25">25</option>
255
+ <option value="26">26</option>
256
+ <option value="27">27</option>
257
+ <option value="28" selected="selected">28</option>
258
+ <option value="29">29</option>
259
+ <option value="30">30</option>
260
+ <option value="31">31</option>
261
+ <option value="32">32</option>
262
+ <option value="33">33</option>
263
+ <option value="34">34</option>
264
+ <option value="35">35</option>
265
+ <option value="36">36</option>
266
+ <option value="37">37</option>
267
+ <option value="38">38</option>
268
+ <option value="39">39</option>
269
+ <option value="40">40</option>
270
+ <option value="41">41</option>
271
+ <option value="42">42</option>
272
+ <option value="43">43</option>
273
+ <option value="44">44</option>
274
+ <option value="45">45</option>
275
+ <option value="46">46</option>
276
+ <option value="47">47</option>
277
+ <option value="48">48</option>
278
+ <option value="49">49</option>
279
+ <option value="50">50</option>
280
+ <option value="51">51</option>
281
+ <option value="52">52</option>
282
+ <option value="53">53</option>
283
+ <option value="54">54</option>
284
+ <option value="55">55</option>
285
+ <option value="56">56</option>
286
+ <option value="57">57</option>
287
+ <option value="58">58</option>
288
+ <option value="59">59</option>
289
+ </select>
202
290
  </div>
203
291
  <div class="input boolean required user_terms_of_service"><input name="user[terms_of_service]" type="hidden" value="0"><input class="boolean required" id="user_terms_of_service" name="user[terms_of_service]" type="checkbox" value="1"><label class="boolean required" for="user_terms_of_service"><abbr title="required">*</abbr> I agree to the Terms of Service</label></div>
204
292
  <input name="commit" type="submit" value="Register">
@@ -0,0 +1,205 @@
1
+ <form accept-charset="UTF-8" action="/users" class="simple_form new_user" id="new_user" method="post" novalidate="novalidate">
2
+ <div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="O6ORla31JvEaWroCuiA7bArM15ztDotMfPAbNW0v61g="></div>
3
+ <div class="input string required user_name"><label class="string required"
4
+ for="user_name"><abbr title="required">*</abbr> Your Display name</label><input class="string required" id="user_name" maxlength="255" name="user[name]" size="50" type="text"></div>
5
+ <div class="input email required user_email"><label class="email required"
6
+ for="user_email"><abbr title="required">*</abbr> Your Email</label><input class="string email required" id="user_email" maxlength="255" name="user[email]" size="50" type="email"></div>
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
+ <div class="input integer required user_age"><label class="integer required"
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 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
+ <div class="input file optional user_avatar"><label class="file optional"
12
+ for="user_avatar">Your Avatar</label><input class="file optional" id="user_avatar" name="user[avatar]" type="file" /></div>
13
+ <div class="input password optional user_password"><label class="password
14
+ optional" for="user_password">Your Password</label><input class="password optional" id="user_password" name="user[password]" size="50" type="password"></div>
15
+ <div class="input select required user_awesome">
16
+ <label class="select required" for="user_awesome"><abbr title="required">*</abbr> Are you awesome?</label>
17
+ <select class="select required" id="user_awesome" name="user[awesome]">
18
+ <option value=""></option>
19
+ <option value="true">Yes</option>
20
+ <option value="false">No</option>
21
+ </select>
22
+ </div>
23
+ <div class="input select user_likes">
24
+ <label class="select" for="user_likes">Your Likes</label>
25
+ <select class="select" id="user_likes" name="user[likes][]" multiple>
26
+ <option value=""></option>
27
+ <option value="ruby">Ruby</option>
28
+ <option value="rails">Rails</option>
29
+ <option value="git">Git</option>
30
+ </select>
31
+ </div>
32
+ <div class="input check_boxes optional user_dislikes">
33
+ <label class="check_boxes optional">Your Dislikes</label>
34
+ <span class="checkbox">
35
+ <input class="check_boxes optional" id="user_dislikes_1" name="user[dislikes][]" type="checkbox" value="java">
36
+ <label class="collection_check_boxes" for="user_dislikes_1">Java</label>
37
+ </span>
38
+ <span class="checkbox">
39
+ <label class="collection_check_boxes" for="user_dislikes_2">
40
+ PHP
41
+ <input class="check_boxes optional" id="user_dislikes_2" name="user[dislikes][]" type="checkbox" value="php">
42
+ </label>
43
+ </span>
44
+ <input name="user[dislikes][]" type="hidden" value="">
45
+ </div>
46
+ <div class="input text required user_bio"><label class="text required"
47
+ 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
+ <div class="input date required user_date_of_birth">
49
+ <label class="date required" for="user_date_of_birth_1i"><abbr
50
+ title="required">*</abbr> Your Date of birth</label>
51
+ <select class="date required" id="user_date_of_birth_1i" name="user[date_of_birth(1i)]">
52
+ <option value="2001">2001</option>
53
+ <option value="2000">2000</option>
54
+ <option value="1999">1999</option>
55
+ <option value="1998">1998</option>
56
+ <option value="1997">1997</option>
57
+ <option value="1996">1996</option>
58
+ <option value="1995">1995</option>
59
+ <option value="1994">1994</option>
60
+ <option value="1993">1993</option>
61
+ <option value="1992">1992</option>
62
+ <option value="1991">1991</option>
63
+ <option value="1990">1990</option>
64
+ <option value="1989">1989</option>
65
+ <option value="1988">1988</option>
66
+ <option value="1987">1987</option>
67
+ <option value="1986">1986</option>
68
+ <option value="1985">1985</option>
69
+ <option value="1984">1984</option>
70
+ <option value="1983">1983</option>
71
+ <option value="1982">1982</option>
72
+ <option value="1981">1981</option>
73
+ <option value="1980">1980</option>
74
+ <option value="1979">1979</option>
75
+ <option value="1978">1978</option>
76
+ <option value="1977">1977</option>
77
+ <option value="1976">1976</option>
78
+ <option value="1975">1975</option>
79
+ <option value="1974">1974</option>
80
+ <option value="1973">1973</option>
81
+ <option value="1972">1972</option>
82
+ <option value="1971">1971</option>
83
+ <option value="1970">1970</option>
84
+ <option value="1969">1969</option>
85
+ <option value="1968">1968</option>
86
+ <option value="1967">1967</option>
87
+ <option value="1966">1966</option>
88
+ <option value="1965">1965</option>
89
+ <option value="1964">1964</option>
90
+ <option value="1963">1963</option>
91
+ <option value="1962">1962</option>
92
+ <option value="1961">1961</option>
93
+ <option value="1960">1960</option>
94
+ <option value="1959">1959</option>
95
+ <option value="1958">1958</option>
96
+ <option value="1957">1957</option>
97
+ <option value="1956">1956</option>
98
+ <option value="1955">1955</option>
99
+ <option value="1954">1954</option>
100
+ <option value="1953">1953</option>
101
+ <option value="1952">1952</option>
102
+ <option value="1951">1951</option>
103
+ <option value="1950">1950</option>
104
+ <option value="1949">1949</option>
105
+ <option value="1948">1948</option>
106
+ <option value="1947">1947</option>
107
+ <option value="1946">1946</option>
108
+ <option value="1945">1945</option>
109
+ <option value="1944">1944</option>
110
+ <option value="1943">1943</option>
111
+ <option value="1942">1942</option>
112
+ <option value="1941">1941</option>
113
+ <option value="1940">1940</option>
114
+ <option value="1939">1939</option>
115
+ <option value="1938">1938</option>
116
+ <option value="1937">1937</option>
117
+ <option value="1936">1936</option>
118
+ <option value="1935">1935</option>
119
+ <option value="1934">1934</option>
120
+ <option value="1933">1933</option>
121
+ <option value="1932">1932</option>
122
+ <option value="1931">1931</option>
123
+ <option value="1930">1930</option>
124
+ <option value="1929">1929</option>
125
+ <option value="1928">1928</option>
126
+ <option value="1927">1927</option>
127
+ <option value="1926">1926</option>
128
+ <option value="1925">1925</option>
129
+ <option value="1924">1924</option>
130
+ <option value="1923">1923</option>
131
+ <option value="1922">1922</option>
132
+ <option value="1921">1921</option>
133
+ <option value="1920">1920</option>
134
+ <option value="1919">1919</option>
135
+ <option value="1918">1918</option>
136
+ <option value="1917">1917</option>
137
+ <option value="1916">1916</option>
138
+ <option value="1915">1915</option>
139
+ <option value="1914">1914</option>
140
+ <option value="1913">1913</option>
141
+ <option value="1912">1912</option>
142
+ <option value="1911">1911</option>
143
+ <option value="1910">1910</option>
144
+ <option value="1909">1909</option>
145
+ <option value="1908">1908</option>
146
+ <option value="1907">1907</option>
147
+ <option value="1906">1906</option>
148
+ <option value="1905">1905</option>
149
+ <option value="1904">1904</option>
150
+ <option value="1903">1903</option>
151
+ <option value="1902">1902</option>
152
+ <option value="1901">1901</option>
153
+ <option value="1900">1900</option>
154
+ </select>
155
+ <select class="date required" id="user_date_of_birth_2i" name="user[date_of_birth(2i)]">
156
+ <option value="1">Enero</option>
157
+ <option value="2">February</option>
158
+ <option value="3">Marzo</option>
159
+ <option value="4">Abril</option>
160
+ <option value="5">Mayo</option>
161
+ <option selected="selected" value="6">Junio</option>
162
+ <option value="7">Julio</option>
163
+ <option value="8">Agosto</option>
164
+ <option value="9">Septiembre</option>
165
+ <option value="10">Octubre</option>
166
+ <option value="11">Noviembre</option>
167
+ <option value="12">Diciembre</option>
168
+ </select>
169
+ <select class="date required" id="user_date_of_birth_3i" name="user[date_of_birth(3i)]">
170
+ <option value="1">1</option>
171
+ <option value="2">2</option>
172
+ <option value="3">3</option>
173
+ <option value="4">4</option>
174
+ <option value="5">5</option>
175
+ <option value="6">6</option>
176
+ <option selected="selected" value="7">7</option>
177
+ <option value="8">8</option>
178
+ <option value="9">9</option>
179
+ <option value="10">10</option>
180
+ <option value="11">11</option>
181
+ <option value="12">12</option>
182
+ <option value="13">13</option>
183
+ <option value="14">14</option>
184
+ <option value="15">15</option>
185
+ <option value="16">16</option>
186
+ <option value="17">17</option>
187
+ <option value="18">18</option>
188
+ <option value="19">19</option>
189
+ <option value="20">20</option>
190
+ <option value="21">21</option>
191
+ <option value="22">22</option>
192
+ <option value="23">23</option>
193
+ <option value="24">24</option>
194
+ <option value="25">25</option>
195
+ <option value="26">26</option>
196
+ <option value="27">27</option>
197
+ <option value="28">28</option>
198
+ <option value="29">29</option>
199
+ <option value="30">30</option>
200
+ <option value="31">31</option>
201
+ </select>
202
+ </div>
203
+ <div class="input boolean required user_terms_of_service"><input name="user[terms_of_service]" type="hidden" value="0"><input class="boolean required" id="user_terms_of_service" name="user[terms_of_service]" type="checkbox" value="1"><label class="boolean required" for="user_terms_of_service"><abbr title="required">*</abbr> I agree to the Terms of Service</label></div>
204
+ <input name="commit" type="submit" value="Register">
205
+ </form>
@@ -36,6 +36,23 @@ module SpecHelper
36
36
  terms_of_service: I agree to the Terms of Service
37
37
  url: Website
38
38
  TRANSLATIONS
39
+ I18n.backend.store_translations(:es, YAML.load(<<-TRANSLATIONS))
40
+ date:
41
+ month_names:
42
+ -
43
+ - Enero
44
+ - Febrero
45
+ - Marzo
46
+ - Abril
47
+ - Mayo
48
+ - Junio
49
+ - Julio
50
+ - Agosto
51
+ - Septiembre
52
+ - Octubre
53
+ - Noviembre
54
+ - Diciembre
55
+ TRANSLATIONS
39
56
  end
40
57
  end
41
58
 
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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -138,6 +138,7 @@ files:
138
138
  - lib/formulaic/inputs/boolean_input.rb
139
139
  - lib/formulaic/inputs/checkbox_input.rb
140
140
  - lib/formulaic/inputs/date_input.rb
141
+ - lib/formulaic/inputs/date_time_input.rb
141
142
  - lib/formulaic/inputs/file_input.rb
142
143
  - lib/formulaic/inputs/input.rb
143
144
  - lib/formulaic/inputs/select_input.rb
@@ -148,6 +149,7 @@ files:
148
149
  - spec/fixtures/event_form.html
149
150
  - spec/fixtures/file.txt
150
151
  - spec/fixtures/user_form.html
152
+ - spec/fixtures/user_form_es.html
151
153
  - spec/formulaic/dsl_spec.rb
152
154
  - spec/formulaic/form_spec.rb
153
155
  - spec/formulaic/label_spec.rb
@@ -172,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
174
  version: '0'
173
175
  requirements: []
174
176
  rubyforge_project:
175
- rubygems_version: 2.4.3
177
+ rubygems_version: 2.4.5
176
178
  signing_key:
177
179
  specification_version: 4
178
180
  summary: Simplify form filling with Capybara
@@ -181,6 +183,7 @@ test_files:
181
183
  - spec/fixtures/event_form.html
182
184
  - spec/fixtures/file.txt
183
185
  - spec/fixtures/user_form.html
186
+ - spec/fixtures/user_form_es.html
184
187
  - spec/formulaic/dsl_spec.rb
185
188
  - spec/formulaic/form_spec.rb
186
189
  - spec/formulaic/label_spec.rb