formulaic 0.0.3 → 0.0.4
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/.ruby-version +1 -1
- data/README.md +2 -2
- data/lib/formulaic/dsl.rb +4 -0
- data/lib/formulaic/errors.rb +3 -0
- data/lib/formulaic/inputs/string_input.rb +11 -3
- data/lib/formulaic/version.rb +1 -1
- data/spec/features/fill_in_user_form_spec.rb +27 -0
- data/spec/fixtures/user_form.html +2 -0
- data/spec/formulaic/dsl_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- metadata +23 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d9ec5d5cc87209a8e0c514da227986091fae2f6
|
4
|
+
data.tar.gz: a4c19d8ff89e8aff97e4ba5ac7691acab348801d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be8c3a6bf12ca92ec6d77030be9f4f2e6abfe7a3853131022b378118493b62e395867a0314e28895ffb63d075017db7695d4714b9a4ecbda806688cc8ba2e719
|
7
|
+
data.tar.gz: 13be8a70905ad76aaf456134f2ca47451ee8a5856b944064b4fad8b65e45ee296bbeab18af1d568746d1c5cdd276c5671480b5332ca25525acbe55fab2165546
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.1.0
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ procedurally calling Capybara’s DSL methods.
|
|
9
9
|
|
10
10
|
```ruby
|
11
11
|
feature 'New user registration' do
|
12
|
-
scenario '
|
12
|
+
scenario 'successfull sign up' do
|
13
13
|
visit sign_in_path
|
14
14
|
|
15
15
|
fill_form(:user, { name: 'Caleb', email: 'caleb@thoughtbot.com', 'Terms of Service': true })
|
@@ -82,7 +82,7 @@ end
|
|
82
82
|
fill_form(:user, attributes_for(:user))
|
83
83
|
```
|
84
84
|
|
85
|
-
You may have attributes included in your `User` factory that don’t
|
85
|
+
You may have attributes included in your `User` factory that don’t pertain to
|
86
86
|
sign up:
|
87
87
|
|
88
88
|
```ruby
|
data/lib/formulaic/dsl.rb
CHANGED
@@ -2,18 +2,26 @@ module Formulaic
|
|
2
2
|
module Inputs
|
3
3
|
class StringInput < Input
|
4
4
|
def fill
|
5
|
-
if
|
5
|
+
if page.has_selector?(:fillable_field, input_text)
|
6
6
|
fill_in(input_text, with: value)
|
7
|
-
elsif page.
|
7
|
+
elsif page.has_selector?(:radio_button, input_text)
|
8
8
|
choose(value)
|
9
|
-
|
9
|
+
elsif has_option_in_select?(value, input_text)
|
10
10
|
select(value, from: input_text)
|
11
|
+
else
|
12
|
+
raise Formulaic::InputNotFound.new(%[Unable to find input "#{input_text}".])
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
def input_text
|
15
17
|
@input_text ||= input(model_name, field)
|
16
18
|
end
|
19
|
+
|
20
|
+
def has_option_in_select?(option, select)
|
21
|
+
find(:select, select).has_selector?(:option, option)
|
22
|
+
rescue Capybara::ElementNotFound
|
23
|
+
false
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
data/lib/formulaic/version.rb
CHANGED
@@ -22,6 +22,33 @@ describe 'Fill in user form' do
|
|
22
22
|
expect(input(:user, :password).value).to eq 'supersecr3t'
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'finds and fills a email field' do
|
26
|
+
visit 'user_form'
|
27
|
+
form = Formulaic::Form.new(:user, email: 'caleb@example.com')
|
28
|
+
|
29
|
+
form.fill
|
30
|
+
|
31
|
+
expect(input(:user, :email).value).to eq 'caleb@example.com'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'finds and fills a tel field' do
|
35
|
+
visit 'user_form'
|
36
|
+
form = Formulaic::Form.new(:user, phone: '123-555-1234')
|
37
|
+
|
38
|
+
form.fill
|
39
|
+
|
40
|
+
expect(input(:user, :phone).value).to eq '123-555-1234'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'finds and fills a url field' do
|
44
|
+
visit 'user_form'
|
45
|
+
form = Formulaic::Form.new(:user, url: 'https://github.com')
|
46
|
+
|
47
|
+
form.fill
|
48
|
+
|
49
|
+
expect(input(:user, :url).value).to eq 'https://github.com'
|
50
|
+
end
|
51
|
+
|
25
52
|
it 'finds and fills a textarea' do
|
26
53
|
visit 'user_form'
|
27
54
|
form = Formulaic::Form.new(:user, bio: 'blah blah blah')
|
@@ -2,6 +2,8 @@
|
|
2
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
3
|
<div class="input string required user_name"><label class="string required" for="user_name"><abbr title="required">*</abbr> Display name</label><input class="string required" id="user_name" maxlength="255" name="user[name]" size="50" type="text"></div>
|
4
4
|
<div class="input email required user_email"><label class="email required" for="user_email"><abbr title="required">*</abbr> Email</label><input class="string email required" id="user_email" maxlength="255" name="user[email]" size="50" type="email"></div>
|
5
|
+
<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>
|
6
|
+
<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>
|
5
7
|
<div class="input password optional user_password"><label class="password optional" for="user_password">Password</label><input class="password optional" id="user_password" name="user[password]" size="50" type="password"></div>
|
6
8
|
<div class="input select required user_awesome">
|
7
9
|
<label class="select required" for="user_awesome"><abbr title="required">*</abbr> Are you awesome?</label>
|
data/spec/formulaic/dsl_spec.rb
CHANGED
@@ -9,6 +9,12 @@ describe Formulaic::Dsl do
|
|
9
9
|
expect(object_with_dsl).to respond_to(:fill_form)
|
10
10
|
end
|
11
11
|
|
12
|
+
it 'finds a submit label' do
|
13
|
+
I18n.backend.store_translations(:en, { helpers: { submit: { user: { create: 'Create user' } } } })
|
14
|
+
|
15
|
+
expect(object_with_dsl.submit(:user)).to eq 'Create user'
|
16
|
+
end
|
17
|
+
|
12
18
|
def object_with_dsl
|
13
19
|
@object_with_dsl ||= Class.new do
|
14
20
|
include Formulaic::Dsl
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formulaic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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:
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: i18n
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: pry
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: |
|
@@ -118,9 +118,9 @@ executables: []
|
|
118
118
|
extensions: []
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
|
-
- .gitignore
|
122
|
-
- .ruby-gemset
|
123
|
-
- .ruby-version
|
121
|
+
- ".gitignore"
|
122
|
+
- ".ruby-gemset"
|
123
|
+
- ".ruby-version"
|
124
124
|
- CONTRIBUTING.md
|
125
125
|
- Gemfile
|
126
126
|
- LICENSE
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- formulaic.gemspec
|
130
130
|
- lib/formulaic.rb
|
131
131
|
- lib/formulaic/dsl.rb
|
132
|
+
- lib/formulaic/errors.rb
|
132
133
|
- lib/formulaic/form.rb
|
133
134
|
- lib/formulaic/inputs.rb
|
134
135
|
- lib/formulaic/inputs/array_input.rb
|
@@ -154,17 +155,17 @@ require_paths:
|
|
154
155
|
- lib
|
155
156
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
157
|
requirements:
|
157
|
-
- -
|
158
|
+
- - ">="
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
160
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
162
|
requirements:
|
162
|
-
- -
|
163
|
+
- - ">="
|
163
164
|
- !ruby/object:Gem::Version
|
164
165
|
version: '0'
|
165
166
|
requirements: []
|
166
167
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.2.1
|
168
169
|
signing_key:
|
169
170
|
specification_version: 4
|
170
171
|
summary: Simplify form filling with Capybara
|