chop 0.28.1 → 0.30.0

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
2
  SHA256:
3
- metadata.gz: f6ba456da0a548764f1a18e69630fe483b74ba5f4011c4f2f0468f63425e6a16
4
- data.tar.gz: 0b7ddf32ce0881dc3fea0ab5360dc6f9140b07a819b26c648de400b777938742
3
+ metadata.gz: e7abe69b089b6ecea7a858c4f3b8976836898cb4059272ea0cf75564478c55ec
4
+ data.tar.gz: 3cb9b264816068b341a25dc31f64a6720c3342fa147e65226f2f40855f581ad3
5
5
  SHA512:
6
- metadata.gz: 7bf304ee6020e23edda9a226fa4dbde24a23ba8a7cd0e4e098eb024da1e90ea89e552515c751bcf347d96dd7bed41ec49199478501d852eb2f61b3a95bc956b3
7
- data.tar.gz: 51dbb0ca6ec2295305349948418cfb0c56a8ffeedad2570b444053da19a300ff60600a94108667d12c902c342fe066638c7d185e030953c93adb2be98bc7550c
6
+ metadata.gz: 43fe87ba581cdcc8a53d1f0e52f8f8a8de20fc7254ec00326e669c41e3fd999014c9fc29d91b93d52c65ec68a35aa42448aacc445521de91ad44da30ba70c8d5
7
+ data.tar.gz: 15f0337c814421702e794364e2fb1f038bd024cdfab7092bad0119e0b749ffb5d2368a2956352014bd7d0175c91cbaa539a26f8b620c3982ed1a24791d35ac21
@@ -5,8 +5,8 @@ jobs:
5
5
  strategy:
6
6
  fail-fast: false
7
7
  matrix:
8
- gemfile: [ rails_6.1, rails_7.0, rails_7.1 ]
9
- ruby: [ '3.0', 3.1, 3.2 ]
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
@@ -1,7 +1,3 @@
1
- appraise "rails-6.1" do
2
- gem "rails", "~>6.1.0"
3
- end
4
-
5
1
  appraise "rails-7.0" do
6
2
  gem "rails", "~>7.0.0"
7
3
  end
@@ -10,3 +6,7 @@ appraise "rails-7.1" do
10
6
  gem "rails", "~>7.1.0"
11
7
  end
12
8
 
9
+ appraise "rails-7.2" do
10
+ gem "rails", "~>7.2.0"
11
+ end
12
+
@@ -5,6 +5,6 @@ source "https://rubygems.org"
5
5
  gem "byebug"
6
6
  gem "puma", "~>5.0"
7
7
  gem "rack", "~>2.0"
8
- gem "rails", "~>6.1.0"
8
+ gem "rails", "~>7.2.0"
9
9
 
10
10
  gemspec path: "../"
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: ", ", name_field: :name
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!(name_field => name)
164
+ klass.find_by!(field => name)
165
165
  end
166
166
  end
167
167
  end
168
168
 
169
- def has_one key, klass=nil, name_field: :name
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!(name_field => name) if name.present?
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
- new(selector, table, session, timeout, block).diff!
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 = { session: session }
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
@@ -1,3 +1,3 @@
1
1
  module Chop
2
- VERSION = "0.28.1"
2
+ VERSION = "0.30.0"
3
3
  end
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.28.1
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-01-29 00:00:00.000000000 Z
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.3
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!