chop 0.28.1 → 0.30.0
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 +2 -2
- data/Appraisals +4 -4
- data/gemfiles/{rails_6.1.gemfile → rails_7.2.gemfile} +1 -1
- data/lib/chop/create.rb +6 -6
- data/lib/chop/diff.rb +8 -4
- data/lib/chop/dsl.rb +2 -2
- data/lib/chop/form.rb +6 -0
- data/lib/chop/version.rb +1 -1
- data/lib/chop.rb +9 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7abe69b089b6ecea7a858c4f3b8976836898cb4059272ea0cf75564478c55ec
|
|
4
|
+
data.tar.gz: 3cb9b264816068b341a25dc31f64a6720c3342fa147e65226f2f40855f581ad3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43fe87ba581cdcc8a53d1f0e52f8f8a8de20fc7254ec00326e669c41e3fd999014c9fc29d91b93d52c65ec68a35aa42448aacc445521de91ad44da30ba70c8d5
|
|
7
|
+
data.tar.gz: 15f0337c814421702e794364e2fb1f038bd024cdfab7092bad0119e0b749ffb5d2368a2956352014bd7d0175c91cbaa539a26f8b620c3982ed1a24791d35ac21
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -5,8 +5,8 @@ jobs:
|
|
|
5
5
|
strategy:
|
|
6
6
|
fail-fast: false
|
|
7
7
|
matrix:
|
|
8
|
-
gemfile: [
|
|
9
|
-
ruby: [
|
|
8
|
+
gemfile: [ rails_7.0, rails_7.1, rails_7.2 ]
|
|
9
|
+
ruby: [ 3.1, 3.2, 3.3 ]
|
|
10
10
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
data/Appraisals
CHANGED
data/lib/chop/create.rb
CHANGED
|
@@ -157,19 +157,19 @@ module Chop
|
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
|
|
160
|
-
def has_many key, klass=nil, delimiter: ", ",
|
|
160
|
+
def has_many key, klass=nil, delimiter: ", ", field: :name
|
|
161
161
|
klass ||= key.to_s.classify.constantize
|
|
162
|
-
field key do |names|
|
|
162
|
+
self.field key do |names|
|
|
163
163
|
names.split(delimiter).map do |name|
|
|
164
|
-
klass.find_by!(
|
|
164
|
+
klass.find_by!(field => name)
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
def has_one key, klass=nil,
|
|
169
|
+
def has_one key, klass=nil, field: :name
|
|
170
170
|
klass ||= key.to_s.classify.constantize
|
|
171
|
-
field key do |name|
|
|
172
|
-
klass.find_by!(
|
|
171
|
+
self.field key do |name|
|
|
172
|
+
klass.find_by!(field => name) if name.present?
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
alias_method :belongs_to, :has_one
|
data/lib/chop/diff.rb
CHANGED
|
@@ -5,8 +5,12 @@ require "active_support/hash_with_indifferent_access"
|
|
|
5
5
|
|
|
6
6
|
module Chop
|
|
7
7
|
class Diff < Struct.new(:selector, :table, :session, :timeout, :block)
|
|
8
|
-
def self.diff! selector, table, session: Capybara.current_session, timeout: Capybara.default_max_wait_time, &block
|
|
9
|
-
|
|
8
|
+
def self.diff! selector, table, session: Capybara.current_session, timeout: Capybara.default_max_wait_time, errors: [], **kwargs, &block
|
|
9
|
+
errors += session.driver.invalid_element_errors
|
|
10
|
+
errors += [Cucumber::MultilineArgument::DataTable::Different]
|
|
11
|
+
session.document.synchronize timeout, errors: errors do
|
|
12
|
+
new(selector, table, session, timeout, block).diff! **kwargs
|
|
13
|
+
end
|
|
10
14
|
end
|
|
11
15
|
|
|
12
16
|
def cell_to_image_filename cell
|
|
@@ -135,11 +139,11 @@ module Chop
|
|
|
135
139
|
end
|
|
136
140
|
end
|
|
137
141
|
|
|
138
|
-
def diff! cucumber_table = table
|
|
142
|
+
def diff! cucumber_table = table, **kwargs
|
|
139
143
|
actual = to_a
|
|
140
144
|
# FIXME should just delegate to Cucumber's #diff!. Cucumber needs to handle empty tables better.
|
|
141
145
|
if !cucumber_table.raw.flatten.empty? && !actual.flatten.empty?
|
|
142
|
-
cucumber_table.diff! actual
|
|
146
|
+
cucumber_table.diff! actual, **kwargs
|
|
143
147
|
elsif cucumber_table.raw.flatten != actual.flatten
|
|
144
148
|
raise Cucumber::MultilineArgument::DataTable::Different.new(cucumber_table)
|
|
145
149
|
end
|
data/lib/chop/dsl.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Chop
|
|
|
8
8
|
Create.create! klass, table, &block
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def diff! selector, table, session: Capybara.current_session, as: nil, timeout: nil, &block
|
|
11
|
+
def diff! selector, table, session: Capybara.current_session, as: nil, timeout: nil, **kwargs, &block
|
|
12
12
|
class_name = if as
|
|
13
13
|
as.to_s
|
|
14
14
|
elsif selector.respond_to?(:tag_name)
|
|
@@ -17,7 +17,7 @@ module Chop
|
|
|
17
17
|
session.find(selector).tag_name
|
|
18
18
|
end.camelize
|
|
19
19
|
klass = const_get("Chop::#{class_name}")
|
|
20
|
-
kwargs =
|
|
20
|
+
kwargs[:session] = session
|
|
21
21
|
kwargs[:timeout] = timeout if timeout.present?
|
|
22
22
|
klass.diff! selector, table, **kwargs, &block
|
|
23
23
|
end
|
data/lib/chop/form.rb
CHANGED
|
@@ -100,6 +100,12 @@ module Chop
|
|
|
100
100
|
def fill_in!
|
|
101
101
|
session.select value, from: label
|
|
102
102
|
end
|
|
103
|
+
|
|
104
|
+
def get_value
|
|
105
|
+
if selected_value = field.value
|
|
106
|
+
field.find("option[value='#{selected_value}']").text
|
|
107
|
+
end
|
|
108
|
+
end
|
|
103
109
|
end
|
|
104
110
|
|
|
105
111
|
class MultipleCheckbox < Field
|
data/lib/chop/version.rb
CHANGED
data/lib/chop.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "chop/version"
|
|
2
|
+
require "cucumber"
|
|
2
3
|
require "chop/create"
|
|
3
4
|
require "chop/table"
|
|
4
5
|
require "chop/definition_list"
|
|
@@ -13,7 +14,14 @@ module Chop
|
|
|
13
14
|
extend Config
|
|
14
15
|
|
|
15
16
|
def self.empty_table
|
|
16
|
-
Cucumber::MultilineArgument::DataTable.from([[]])
|
|
17
|
+
empty = Cucumber::MultilineArgument::DataTable.from([[]])
|
|
18
|
+
|
|
19
|
+
def empty.diff! other_table, **kwargs, &block
|
|
20
|
+
super other_table, **kwargs.reverse_merge(surplus_col: true, surplus_row: true), &block
|
|
21
|
+
rescue Capybara::ElementNotFound
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
empty
|
|
17
25
|
end
|
|
18
26
|
end
|
|
19
27
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.30.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-09-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -141,9 +141,9 @@ files:
|
|
|
141
141
|
- bin/setup
|
|
142
142
|
- chop.gemspec
|
|
143
143
|
- gemfiles/.bundle/config
|
|
144
|
-
- gemfiles/rails_6.1.gemfile
|
|
145
144
|
- gemfiles/rails_7.0.gemfile
|
|
146
145
|
- gemfiles/rails_7.1.gemfile
|
|
146
|
+
- gemfiles/rails_7.2.gemfile
|
|
147
147
|
- lib/chop.rb
|
|
148
148
|
- lib/chop/config.rb
|
|
149
149
|
- lib/chop/create.rb
|
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
174
174
|
- !ruby/object:Gem::Version
|
|
175
175
|
version: '0'
|
|
176
176
|
requirements: []
|
|
177
|
-
rubygems_version: 3.5.
|
|
177
|
+
rubygems_version: 3.5.6
|
|
178
178
|
signing_key:
|
|
179
179
|
specification_version: 4
|
|
180
180
|
summary: Slice and dice your cucumber tables with ease!
|