formulaic 0.4.1 → 0.4.2
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/.github/workflows/ci.yml +25 -0
- data/.ruby-version +1 -1
- data/NEWS.md +27 -2
- data/README.md +22 -11
- data/Rakefile +3 -0
- data/formulaic.gemspec +7 -3
- data/lib/formulaic/form.rb +2 -0
- data/lib/formulaic/label.rb +3 -0
- data/lib/formulaic/version.rb +1 -1
- data/spec/features/fill_in_user_form_spec.rb +20 -6
- data/spec/formulaic/form_spec.rb +11 -1
- data/spec/spec_helper.rb +1 -1
- metadata +12 -12
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e2acd58cffacd098ba64bdbe7e6b6a8397b2645e052a840cee04e64d30e4319
|
4
|
+
data.tar.gz: cd1f8f8402992ec04222ed7030c6690358cda018f838e7aae24f2648a1eb6c15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9318b1108f7841eb5d09e9c53b862d4b222056e6996e99a4cee82d7ab00ba5453f949b1490f7769349c4e9fe9ed7f9c38dbd56f24b9081fb96aaa051fa627b4
|
7
|
+
data.tar.gz: 9a48cb6d20301b9502e637231c2b23db4fe7b7a9387dc29078ca05df34e7b815c23038640f90d15d07a0ac1a93fec3ba4de405e6c0c42cb6ae134fc1e1d291e7
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby-version:
|
13
|
+
- head
|
14
|
+
- '3.3'
|
15
|
+
- '3.2'
|
16
|
+
- '3.1'
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v3
|
19
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
23
|
+
bundler-cache: true # 'bundle install' and cache
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rake
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.3.1
|
data/NEWS.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
v0.4.2
|
2
|
+
------
|
3
|
+
|
4
|
+
* Fix imports for testing, update build matrix 41f797d
|
5
|
+
|
6
|
+
*Caleb Hearth*
|
7
|
+
* Merge pull request #81 from petergoldstein/feature/migrate_ci_to_github_actions ae644c4
|
8
|
+
|
9
|
+
*Caleb Hearth*
|
10
|
+
* Migrate CI to GitHub Actions c6b147b
|
11
|
+
|
12
|
+
*Peter Goldstein*
|
13
|
+
* Freshen things up a bit 1e893f2
|
14
|
+
|
15
|
+
*Caleb Hearth*
|
16
|
+
* Merge pull request #76 from ElMassimo/patch-1 9f19bfa
|
17
|
+
|
18
|
+
*Caleb Hearth*
|
19
|
+
* Add additional instructions for delegation ffa7775
|
20
|
+
|
21
|
+
*Máximo Mussini*
|
22
|
+
* Add instructions for Capybara Test Helpers 0da1d04
|
23
|
+
|
24
|
+
*Máximo Mussini*
|
25
|
+
|
1
26
|
v0.1.1
|
2
27
|
------
|
3
28
|
|
@@ -10,10 +35,10 @@ v0.1.0
|
|
10
35
|
|
11
36
|
* Add `fill_form_and_submit` shortcut [48f9bc2](https://github.com/thoughtbot/formulaic/commit/48f9bc257d6c2b26c859388ab01da8963b818a85)
|
12
37
|
|
13
|
-
*Caleb
|
38
|
+
*Caleb Hearth*
|
14
39
|
* Allow action to be specified in DSL [ad4bb54](https://github.com/thoughtbot/formulaic/commit/ad4bb5402d68131038e53f67e2e981f6aa1d5fa9)
|
15
40
|
|
16
|
-
*Caleb
|
41
|
+
*Caleb Hearth*
|
17
42
|
* Add support for File attachments [f4e4bae](https://github.com/thoughtbot/formulaic/commit/f4e4bae978ab32fde017ae8344f862076a9ef31a)
|
18
43
|
|
19
44
|
*Dan Collis-Puro and Sean Doyle*
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Formulaic
|
2
2
|
|
3
|
-
[](https://travis-ci.org/calebhearth/formulaic)
|
4
|
+
[](https://codeclimate.com/github/calebhearth/formulaic)
|
5
5
|
|
6
6
|
Remove the tedium of formulaic form filling with Capybara.
|
7
7
|
|
@@ -130,6 +130,22 @@ def sign_up_attributes
|
|
130
130
|
end
|
131
131
|
```
|
132
132
|
|
133
|
+
### Integration with [Capybara::TestHelper](https://github.com/ElMassimo/capybara_test_helpers)
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
class BaseTestHelper < Capybara::TestHelper
|
137
|
+
include Formulaic::Dsl
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
or alternatively delegate the needed methods:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
class FormTestHelper < BaseTestHelper
|
145
|
+
delegate_to_test_context(:fill_form, :input, :submit, :fill_form_and_submit)
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
133
149
|
## Assumptions
|
134
150
|
|
135
151
|
Formulaic relies pretty heavily on the assumption that your application is using
|
@@ -176,13 +192,8 @@ Formulaic.default_wait_time = 5
|
|
176
192
|
|
177
193
|
## About
|
178
194
|
|
179
|
-
Formulaic is maintained by [Caleb
|
180
|
-
|
181
|
-
with the help of community [contributors].
|
182
|
-
Thank you!
|
183
|
-
|
184
|
-
[caleb]: http://github.com/calebthompson
|
185
|
-
[team]: https://thoughtbot.com/austin?utm_source=github
|
186
|
-
[contributors]: http://github.com/thoughtbot/formulaic/contributors
|
195
|
+
Formulaic is maintained by [Caleb Hearth][caleb] and formerly thoughtbot with
|
196
|
+
the help of community [contributors]. Thank you!
|
187
197
|
|
188
|
-
[
|
198
|
+
[caleb]: http://github.com/calebhearth
|
199
|
+
[contributors]: http://github.com/thoughtbot/calebhearth/contributors
|
data/Rakefile
CHANGED
data/formulaic.gemspec
CHANGED
@@ -6,21 +6,25 @@ require 'formulaic/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'formulaic'
|
8
8
|
spec.version = Formulaic::VERSION
|
9
|
-
spec.authors = ['Caleb
|
10
|
-
spec.email = ['caleb@
|
9
|
+
spec.authors = ['Caleb Hearth']
|
10
|
+
spec.email = ['caleb@calebhearth.com']
|
11
11
|
spec.summary = 'Simplify form filling with Capybara'
|
12
12
|
spec.description = <<-DESCRIPTION.sub(/^ +/, '')
|
13
13
|
Removes the tedium of formulaic form filling with Capybara by allowing you
|
14
14
|
to specify a hash of attributes to be input rather than procedurally calling
|
15
15
|
Capybara’s DSL methods.
|
16
16
|
DESCRIPTION
|
17
|
-
spec.homepage = 'https://github.com/
|
17
|
+
spec.homepage = 'https://github.com/calebhearth/formulaic'
|
18
18
|
spec.license = 'MIT'
|
19
19
|
|
20
20
|
spec.files = `git ls-files`.split($/)
|
21
21
|
spec.test_files = spec.files.grep(%r{^spec/})
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
+
spec.metadata = {
|
25
|
+
"funding-uri" => "https://github.com/sponsors/calebhearth"
|
26
|
+
}
|
27
|
+
|
24
28
|
spec.add_dependency 'capybara'
|
25
29
|
spec.add_dependency 'i18n'
|
26
30
|
spec.add_dependency 'activesupport'
|
data/lib/formulaic/form.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support'
|
1
2
|
require 'active_support/time_with_zone'
|
2
3
|
|
3
4
|
module Formulaic
|
@@ -14,6 +15,7 @@ module Formulaic
|
|
14
15
|
TrueClass => Formulaic::Inputs::BooleanInput,
|
15
16
|
FalseClass => Formulaic::Inputs::BooleanInput,
|
16
17
|
File => Formulaic::Inputs::FileInput,
|
18
|
+
Rack::Multipart::UploadedFile => Formulaic::Inputs::FileInput
|
17
19
|
}.freeze
|
18
20
|
|
19
21
|
def initialize(model_name, action, attributes)
|
data/lib/formulaic/label.rb
CHANGED
data/lib/formulaic/version.rb
CHANGED
@@ -192,14 +192,28 @@ describe 'Fill in user form' do
|
|
192
192
|
expect(page).to have_select('user_awesome', selected: 'Yes')
|
193
193
|
end
|
194
194
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
195
|
+
context 'when File is an instance of File class' do
|
196
|
+
it 'attaches a file to a file field' do
|
197
|
+
visit 'user_form'
|
198
|
+
file = File.open('spec/fixtures/file.txt')
|
199
|
+
form = Formulaic::Form.new(:user, :new, avatar: file)
|
199
200
|
|
200
|
-
|
201
|
+
form.fill
|
202
|
+
|
203
|
+
expect(input(:user, :avatar).value).to eq file.path
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'when File is an instance of Rack::Multipart::UploadedFile class' do
|
208
|
+
it 'attaches a file to a file field' do
|
209
|
+
visit 'user_form'
|
210
|
+
file = Rack::Multipart::UploadedFile.new('spec/fixtures/file.txt')
|
211
|
+
form = Formulaic::Form.new(:user, :new, avatar: file)
|
201
212
|
|
202
|
-
|
213
|
+
form.fill
|
214
|
+
|
215
|
+
expect(input(:user, :avatar).value).to eq file.path
|
216
|
+
end
|
203
217
|
end
|
204
218
|
|
205
219
|
it 'finds and fills a date field regardless of select box order' do
|
data/spec/formulaic/form_spec.rb
CHANGED
@@ -2,6 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Formulaic::Form do
|
4
4
|
it 'throws an error if it does not know how to fill an attribute type' do
|
5
|
-
expect
|
5
|
+
expect do
|
6
|
+
Formulaic::Form.new(nil, nil, { invalid: nil })
|
7
|
+
end.to raise_error(Formulaic::Form::InvalidAttributeTypeError)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "doesn't throw error for Rack::Multipart::UploadedFile object" do
|
11
|
+
rack_multipart_uploaded_file = Rack::Multipart::UploadedFile.new(__FILE__)
|
12
|
+
|
13
|
+
expect do
|
14
|
+
Formulaic::Form.new(:user, :new, { avatar: rack_multipart_uploaded_file })
|
15
|
+
end.not_to raise_error
|
6
16
|
end
|
7
17
|
end
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Caleb
|
8
|
-
autorequire:
|
7
|
+
- Caleb Hearth
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -113,15 +113,15 @@ description: |
|
|
113
113
|
to specify a hash of attributes to be input rather than procedurally calling
|
114
114
|
Capybara’s DSL methods.
|
115
115
|
email:
|
116
|
-
- caleb@
|
116
|
+
- caleb@calebhearth.com
|
117
117
|
executables: []
|
118
118
|
extensions: []
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
|
+
- ".github/workflows/ci.yml"
|
121
122
|
- ".gitignore"
|
122
123
|
- ".ruby-gemset"
|
123
124
|
- ".ruby-version"
|
124
|
-
- ".travis.yml"
|
125
125
|
- CONTRIBUTING.md
|
126
126
|
- Gemfile
|
127
127
|
- LICENSE
|
@@ -155,11 +155,12 @@ files:
|
|
155
155
|
- spec/formulaic/label_spec.rb
|
156
156
|
- spec/spec_helper.rb
|
157
157
|
- spec/support/models/user.rb
|
158
|
-
homepage: https://github.com/
|
158
|
+
homepage: https://github.com/calebhearth/formulaic
|
159
159
|
licenses:
|
160
160
|
- MIT
|
161
|
-
metadata:
|
162
|
-
|
161
|
+
metadata:
|
162
|
+
funding-uri: https://github.com/sponsors/calebhearth
|
163
|
+
post_install_message:
|
163
164
|
rdoc_options: []
|
164
165
|
require_paths:
|
165
166
|
- lib
|
@@ -174,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
175
|
- !ruby/object:Gem::Version
|
175
176
|
version: '0'
|
176
177
|
requirements: []
|
177
|
-
|
178
|
-
|
179
|
-
signing_key:
|
178
|
+
rubygems_version: 3.5.9
|
179
|
+
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Simplify form filling with Capybara
|
182
182
|
test_files:
|