formulaic 0.0.5 → 0.0.6
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/.travis.yml +6 -0
- data/NEWS.md +5 -0
- data/README.md +33 -7
- data/Rakefile +5 -0
- data/lib/formulaic/form.rb +1 -0
- data/lib/formulaic/version.rb +1 -1
- data/spec/features/fill_in_user_form_spec.rb +9 -0
- data/spec/fixtures/user_form.html +1 -0
- data/spec/spec_helper.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bddf9295abcf67c8f465f0cf868233fec7998cc
|
4
|
+
data.tar.gz: a5b5c6bf0604458bfac05486835a8a53e02547b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b37abbe416ec93dc90fb814ccef4df969a087d82c33baa247b92b499719cf325baf481f80aabfd11c0f06a47535c64ad64ca1e8ba3f363dfe901031cba3e587
|
7
|
+
data.tar.gz: 78d46b03a053535978e7ec32c9ce9eb437f06b4bbafeccb07bec18c01043c60c03352ba16cce0c4c6e99b5fb749bbc0f3f46655f170c71cf23a3ccb4e501e0ef
|
data/.travis.yml
ADDED
data/NEWS.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Formulaic
|
2
2
|
|
3
|
+
[](https://travis-ci.org/thoughtbot/formulaic)
|
4
|
+
[](https://codeclimate.com/github/thoughtbot/formulaic)
|
5
|
+
|
3
6
|
Remove the tedium of formulaic form filling with Capybara.
|
4
7
|
|
5
8
|
Formulaic allows you to specify a hash of attributes to be input rather than
|
@@ -12,7 +15,7 @@ feature 'New user registration' do
|
|
12
15
|
scenario 'successfull sign up' do
|
13
16
|
visit sign_in_path
|
14
17
|
|
15
|
-
fill_form(:user, { name: 'Caleb', email: 'caleb@thoughtbot.com', 'Terms of Service'
|
18
|
+
fill_form(:user, { name: 'Caleb', email: 'caleb@thoughtbot.com', 'Terms of Service' => true })
|
16
19
|
click_on submit(:user)
|
17
20
|
|
18
21
|
expect(page).to have_content t('user.create.success')
|
@@ -76,6 +79,17 @@ RSpec.configure do |config|
|
|
76
79
|
end
|
77
80
|
```
|
78
81
|
|
82
|
+
### Integration with Minitest or Test::Unit:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
# test/test_helper.rb
|
86
|
+
|
87
|
+
class ActionDispatch::IntegrationTest
|
88
|
+
include Capybara::DSL
|
89
|
+
include Formulaic::Dsl
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
79
93
|
### Integration with [FactoryGirl](https://github.com/thoughtbot/factory_girl)
|
80
94
|
|
81
95
|
```ruby
|
@@ -94,17 +108,29 @@ def sign_up_attributes
|
|
94
108
|
end
|
95
109
|
```
|
96
110
|
|
111
|
+
## Assumptions
|
112
|
+
|
113
|
+
Formulaic relies pretty heavily on the assumption that your application is using
|
114
|
+
translations for SimpleForm and input helpers, using the
|
115
|
+
`simple_form.labels.<model>.<attribute>` and `helpers.submit.<model>.<action>`
|
116
|
+
conventions.
|
117
|
+
|
118
|
+
You can still use Formulaic by using strings as keys instead of symbols, which
|
119
|
+
it knows to pass directly to `fill_in` rather than trying to find a translation.
|
120
|
+
You’ll need to find submit buttons yourself since `submit` is a thin wrapper
|
121
|
+
around `I18n.t`.
|
122
|
+
|
97
123
|
## Known Limitations
|
98
124
|
|
99
125
|
* Formulaic currently supports the following mappings from the `#class` of the
|
100
126
|
attribute values to Capybara method calls:
|
101
127
|
|
102
|
-
| Classes | Formulaic’s action
|
103
|
-
|
|
104
|
-
| `String` | `fill_in`
|
105
|
-
| `Date`, `ActiveSupport::TimeWithZone` | `select` year, month, and day
|
106
|
-
| `TrueClass` | `check`
|
107
|
-
| `FalseClass` | `uncheck`
|
128
|
+
| Classes | Formulaic’s action |
|
129
|
+
| --------------------------------------|----------------------------------|
|
130
|
+
| `String` | `fill_in`, `choose`, or `select` |
|
131
|
+
| `Date`, `ActiveSupport::TimeWithZone` | `select` year, month, and day |
|
132
|
+
| `TrueClass` | `check` |
|
133
|
+
| `FalseClass` | `uncheck` |
|
108
134
|
| `Array` | `check` each array member, which should all be strings |
|
109
135
|
|
110
136
|
* Formulaic is currently tied to `simple_form` translations and field structure.
|
data/Rakefile
CHANGED
data/lib/formulaic/form.rb
CHANGED
@@ -7,6 +7,7 @@ module Formulaic
|
|
7
7
|
Date => Formulaic::Inputs::DateInput,
|
8
8
|
Array => Formulaic::Inputs::ArrayInput,
|
9
9
|
String => Formulaic::Inputs::StringInput,
|
10
|
+
Fixnum => Formulaic::Inputs::StringInput,
|
10
11
|
TrueClass => Formulaic::Inputs::BooleanInput,
|
11
12
|
FalseClass => Formulaic::Inputs::BooleanInput,
|
12
13
|
}.freeze
|
data/lib/formulaic/version.rb
CHANGED
@@ -78,6 +78,15 @@ describe 'Fill in user form' do
|
|
78
78
|
expect(input(:user, :terms_of_service)).to be_checked
|
79
79
|
end
|
80
80
|
|
81
|
+
it 'finds and fills in a number field' do
|
82
|
+
visit 'user_form'
|
83
|
+
form = Formulaic::Form.new(:user, age: 10)
|
84
|
+
|
85
|
+
form.fill
|
86
|
+
|
87
|
+
expect(input(:user, :age).value).to eq '10'
|
88
|
+
end
|
89
|
+
|
81
90
|
it 'selects a string if there is no input' do
|
82
91
|
visit 'user_form'
|
83
92
|
form = Formulaic::Form.new(:user, awesome: 'Yes')
|
@@ -3,6 +3,7 @@
|
|
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
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 integer required user_age"><label class="integer required" for="user_age"><abbr title="required">*</abbr> Age</label><input class="numeric integer age required" id="user_age" maxlength="255" name="user[age]" size="50" type="number"></div>
|
6
7
|
<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>
|
7
8
|
<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>
|
8
9
|
<div class="input select required user_awesome">
|
data/spec/spec_helper.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.6
|
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-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -121,9 +121,11 @@ files:
|
|
121
121
|
- ".gitignore"
|
122
122
|
- ".ruby-gemset"
|
123
123
|
- ".ruby-version"
|
124
|
+
- ".travis.yml"
|
124
125
|
- CONTRIBUTING.md
|
125
126
|
- Gemfile
|
126
127
|
- LICENSE
|
128
|
+
- NEWS.md
|
127
129
|
- README.md
|
128
130
|
- Rakefile
|
129
131
|
- formulaic.gemspec
|