formulaic 0.4.0 → 0.4.2

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
- SHA1:
3
- metadata.gz: 5aac19cb8a6553a97ce1cf6fd5685efe3d9670cd
4
- data.tar.gz: 4b2936160b65052f3eaf8f11fed542104ef86c2e
2
+ SHA256:
3
+ metadata.gz: 1e2acd58cffacd098ba64bdbe7e6b6a8397b2645e052a840cee04e64d30e4319
4
+ data.tar.gz: cd1f8f8402992ec04222ed7030c6690358cda018f838e7aae24f2648a1eb6c15
5
5
  SHA512:
6
- metadata.gz: 8aeb601d65baf8db3eb4a524b64917ca82ffc172aa3827c60c96beb2802974a6907c5569bb07d048af4f7e741f97794d89e07958902a6348c5fb123e280629f2
7
- data.tar.gz: 9821a23573b2387dde20940b476ef9e2247177c565aaeacc218deaf4f18058858d237cdc5bdb1aa926122603e9a7876ad2db857cc63804aa8f87f2ba8fa51568
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
- 2.4.0
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 Thompson*
38
+ *Caleb Hearth*
14
39
  * Allow action to be specified in DSL [ad4bb54](https://github.com/thoughtbot/formulaic/commit/ad4bb5402d68131038e53f67e2e981f6aa1d5fa9)
15
40
 
16
- *Caleb Thompson*
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
- [![Build Status](https://travis-ci.org/thoughtbot/formulaic.png?branch=master)](https://travis-ci.org/thoughtbot/formulaic)
4
- [![Code Climate](https://codeclimate.com/github/thoughtbot/formulaic.png)](https://codeclimate.com/github/thoughtbot/formulaic)
3
+ [![Build Status](https://travis-ci.org/calebhearth/formulaic.png?branch=master)](https://travis-ci.org/calebhearth/formulaic)
4
+ [![Code Climate](https://codeclimate.com/github/calebhearth/formulaic.png)](https://codeclimate.com/github/calebhearth/formulaic)
5
5
 
6
6
  Remove the tedium of formulaic form filling with Capybara.
7
7
 
@@ -112,7 +112,7 @@ class ActionDispatch::IntegrationTest
112
112
  end
113
113
  ```
114
114
 
115
- ### Integration with [FactoryGirl](https://github.com/thoughtbot/factory_girl)
115
+ ### Integration with [Factory Bot](https://github.com/thoughtbot/factory_bot)
116
116
 
117
117
  ```ruby
118
118
  fill_form(:user, attributes_for(:user))
@@ -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 Thompson][caleb]
180
- and thoughtbot's [Austin Ruby on Rails development team][team],
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
- [![Ralph](http://thoughtbot.com/assets/thoughtbot-logo.png)](http://thoughtbot.com)
198
+ [caleb]: http://github.com/calebhearth
199
+ [contributors]: http://github.com/thoughtbot/calebhearth/contributors
data/formulaic.gemspec CHANGED
@@ -6,26 +6,30 @@ 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 Thompson']
10
- spec.email = ['caleb@calebthompson.io']
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/thoughtbot/formulaic'
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'
27
31
 
28
- spec.add_development_dependency 'bundler', '~> 1.3'
32
+ spec.add_development_dependency 'bundler'
29
33
  spec.add_development_dependency 'rake'
30
34
  spec.add_development_dependency 'rspec'
31
35
  spec.add_development_dependency 'pry'
@@ -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)
@@ -1,11 +1,6 @@
1
1
  module Formulaic
2
2
  module Inputs
3
3
  class ArrayInput < Input
4
- def initialize(label, value)
5
- @label = label
6
- @value = value
7
- end
8
-
9
4
  def fill
10
5
  attempt_to_fill_selects ||
11
6
  attempt_to_fill_checkboxes ||
@@ -3,9 +3,9 @@ module Formulaic
3
3
  class BooleanInput < Input
4
4
  def fill
5
5
  if value
6
- check(label)
6
+ check(label.to_str)
7
7
  else
8
- uncheck(label)
8
+ uncheck(label.to_str)
9
9
  end
10
10
  end
11
11
  end
@@ -2,7 +2,7 @@ module Formulaic
2
2
  module Inputs
3
3
  class FileInput < Input
4
4
  def fill
5
- attach_file(label, value.path)
5
+ attach_file(label.to_str, value.path)
6
6
  end
7
7
  end
8
8
  end
@@ -21,7 +21,7 @@ module Formulaic
21
21
  end
22
22
 
23
23
  def has_select?
24
- has_field?(label, type: "select")
24
+ has_field?(label.to_str, type: "select")
25
25
  end
26
26
 
27
27
  def select_is_multiple?
@@ -30,7 +30,7 @@ module Formulaic
30
30
  end
31
31
 
32
32
  def select_element
33
- @select_element ||= find_field(label, type: "select")
33
+ @select_element ||= find_field(label.to_str, type: "select")
34
34
  end
35
35
  end
36
36
  end
@@ -2,19 +2,19 @@ module Formulaic
2
2
  module Inputs
3
3
  class StringInput < Input
4
4
  def fill
5
- if page.has_selector?(:fillable_field, label, wait: Formulaic.default_wait_time)
6
- fill_in(label, with: value)
7
- elsif page.has_selector?(:radio_button, label, wait: Formulaic.default_wait_time)
5
+ if page.has_selector?(:fillable_field, label.to_str, wait: Formulaic.default_wait_time)
6
+ fill_in(label.to_str, with: value)
7
+ elsif page.has_selector?(:radio_button, label.to_str, wait: Formulaic.default_wait_time)
8
8
  choose(value)
9
- elsif has_option_in_select?(translate_option(value), label)
10
- select(translate_option(value), from: label)
9
+ elsif has_option_in_select?(translate_option(value), label.to_str)
10
+ select(translate_option(value), from: label.to_str)
11
11
  else
12
12
  raise Formulaic::InputNotFound.new(%[Unable to find input "#{label}".])
13
13
  end
14
14
  end
15
15
 
16
16
  def has_option_in_select?(option, select)
17
- element = find(:select, select)
17
+ element = find(:select, select.to_str)
18
18
  if ! element.has_selector?(:option, option, wait: Formulaic.default_wait_time)
19
19
  raise Formulaic::OptionForSelectInputNotFound.new(%[Unable to find option with text matching "#{option}".])
20
20
  end
@@ -1,3 +1,6 @@
1
+ require "active_support"
2
+ require "active_support/core_ext/object/blank"
3
+
1
4
  module Formulaic
2
5
  class Label
3
6
  attr_reader :model_name, :attribute, :action
@@ -1,3 +1,3 @@
1
1
  module Formulaic
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.2'
3
3
  end
@@ -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
- it 'attaches a file to a file field' do
196
- visit 'user_form'
197
- file = File.open('spec/fixtures/file.txt')
198
- form = Formulaic::Form.new(:user, :new, avatar: file)
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
- form.fill
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
- expect(input(:user, :avatar).value).to eq file.path
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
@@ -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 { Formulaic::Form.new(nil, nil, { invalid: nil }) }.to raise_error(Formulaic::Form::InvalidAttributeTypeError)
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
@@ -13,7 +13,7 @@ module SpecHelper
13
13
 
14
14
  def page
15
15
  @page ||= begin
16
- Capybara.app = Rack::File.new(File.expand_path('../fixtures', __FILE__))
16
+ Capybara.app = Rack::Files.new(File.expand_path('../fixtures', __FILE__))
17
17
  Capybara.current_session
18
18
  end
19
19
  end
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.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
- - Caleb Thompson
8
- autorequire:
7
+ - Caleb Hearth
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: '0'
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
- version: '1.3'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -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@calebthompson.io
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/thoughtbot/formulaic
158
+ homepage: https://github.com/calebhearth/formulaic
159
159
  licenses:
160
160
  - MIT
161
- metadata: {}
162
- post_install_message:
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
- rubyforge_project:
178
- rubygems_version: 2.6.8
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:
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- rvm:
2
- - "2.2"
3
- - "2.3"
4
- - "2.4.0"
5
- - "ruby-head"
6
- notifications:
7
- email: false