chop 0.36.5 → 0.36.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/lib/chop/diff.rb +1 -1
- data/lib/chop/dsl.rb +2 -5
- data/lib/chop/form.rb +24 -34
- data/lib/chop/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4d477e3610880a15f5ab315ad6c2f3a212f28f443147e363edc79508c7316b8
|
|
4
|
+
data.tar.gz: c0cdf43b5a9415e21216d1ed4babddee3a141d9651bf593d6ffac484b1d1140c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3c86c9f999bdb1c9b2cbb8c721affa85008ae8cd65947311d182bdd1c5923d0aeedd14f4e2e75a6820c211a7e477a599e18628c2230c26dc6ef75530728d6ec
|
|
7
|
+
data.tar.gz: e51e524727d4a813a0e19756fdc9c82a389e2e30404eac8de13fd7f512fd4edf218ca96787b5c9a63e56e2dc2557115add2851cb2d408adfc0c6399de35e4185
|
data/lib/chop/diff.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Chop
|
|
|
8
8
|
class Diff < Struct.new(:selector, :table, :session, :timeout, :block)
|
|
9
9
|
def self.diff! selector, table, session: Capybara.current_session, timeout: Capybara.default_max_wait_time, errors: [], **kwargs, &block
|
|
10
10
|
errors += session.driver.invalid_element_errors
|
|
11
|
-
errors += [
|
|
11
|
+
errors += [Cucumber::MultilineArgument::DataTable::Different]
|
|
12
12
|
session.document.synchronize timeout, errors: errors do
|
|
13
13
|
new(selector, table, session, timeout, block).diff! **kwargs
|
|
14
14
|
end
|
data/lib/chop/dsl.rb
CHANGED
|
@@ -9,19 +9,16 @@ module Chop
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def diff! selector, table, session: Capybara.current_session, as: nil, timeout: nil, **kwargs, &block
|
|
12
|
-
sync_timeout = timeout || Capybara.default_max_wait_time
|
|
13
12
|
class_name = if as
|
|
14
13
|
as.to_s
|
|
15
14
|
elsif selector.respond_to?(:tag_name)
|
|
16
15
|
selector.tag_name
|
|
17
16
|
else
|
|
18
|
-
session.
|
|
19
|
-
session.find(selector).tag_name
|
|
20
|
-
end
|
|
17
|
+
session.find(selector).tag_name
|
|
21
18
|
end.camelize
|
|
22
19
|
klass = const_get("Chop::#{class_name}")
|
|
23
20
|
kwargs[:session] = session
|
|
24
|
-
kwargs[:timeout] = timeout if timeout
|
|
21
|
+
kwargs[:timeout] = timeout if timeout.present?
|
|
25
22
|
klass.diff! selector, table, **kwargs, &block
|
|
26
23
|
end
|
|
27
24
|
|
data/lib/chop/form.rb
CHANGED
|
@@ -7,34 +7,26 @@ module Chop
|
|
|
7
7
|
new(table, session, path).fill_in!
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def self.diff! selector, table, session: Capybara.current_session,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
else
|
|
17
|
-
session.find(selector, wait: timeout)
|
|
18
|
-
end
|
|
19
|
-
rescue Capybara::ElementNotFound
|
|
20
|
-
raise unless @allow_not_found
|
|
21
|
-
Node("")
|
|
10
|
+
def self.diff! selector, table, session: Capybara.current_session, &block
|
|
11
|
+
root = begin
|
|
12
|
+
if selector.is_a?(Capybara::Node::Element)
|
|
13
|
+
selector
|
|
14
|
+
else
|
|
15
|
+
session.find(selector)
|
|
22
16
|
end
|
|
17
|
+
rescue Capybara::ElementNotFound
|
|
18
|
+
raise unless @allow_not_found
|
|
19
|
+
Node("")
|
|
20
|
+
end
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
actual = root.all(Field.combined_css_selector, allow_reload: true)
|
|
23
|
+
.filter_map { |field_element| Field.from(session, field_element) }
|
|
24
|
+
.select(&:should_include_in_diff?)
|
|
25
|
+
.uniq { |field| field.field[:name] }
|
|
26
|
+
.filter_map(&:to_diff_row)
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
raise Capybara::ElementNotFound, "No form fields found in #{selector.inspect}"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
block.call(actual, root) if block_given?
|
|
36
|
-
table.diff! actual, surplus_row: false, misplaced_col: false
|
|
37
|
-
end
|
|
28
|
+
block.call(actual, root) if block_given?
|
|
29
|
+
table.diff! actual, surplus_row: false, misplaced_col: false
|
|
38
30
|
end
|
|
39
31
|
|
|
40
32
|
|
|
@@ -54,15 +46,13 @@ module Chop
|
|
|
54
46
|
return nil if locator.nil?
|
|
55
47
|
|
|
56
48
|
@locator = locator.to_s
|
|
57
|
-
@session.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
raise_not_found
|
|
65
|
-
end
|
|
49
|
+
@all_fields = @session.all(@css_selector)
|
|
50
|
+
|
|
51
|
+
find_by_direct_attributes ||
|
|
52
|
+
find_by_aria_label ||
|
|
53
|
+
find_by_associated_label ||
|
|
54
|
+
find_by_wrapping_label ||
|
|
55
|
+
raise_not_found
|
|
66
56
|
end
|
|
67
57
|
|
|
68
58
|
private
|
data/lib/chop/version.rb
CHANGED