chop 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chop/form.rb +46 -2
- data/lib/chop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc848f74bcfa21d1caf3f92ba4dbadb50ef7e997
|
4
|
+
data.tar.gz: 4fcee119a37213af484023b70ee200af27e25251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a917cfb02a2d1cdd17c7385d9efb73ff6fef248a91e101073c6a1ea52e4e55d2d17123503ce5076047945eb33ea4ad2766a227f683169c7188c2cb00389ce3f0
|
7
|
+
data.tar.gz: 13b5f38fab386835e0993949d9f906ce19de928abaa9c8885cae3e344afa6554d36fdc8cbf8acc4b7937522ad541d58e0c41515d0a04adb3e249b684e326fc02
|
data/lib/chop/form.rb
CHANGED
@@ -52,9 +52,37 @@ module Chop
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
class MultipleCheckbox < Field
|
56
|
+
def matches?
|
57
|
+
field[:type] == "checkbox" && field[:name].to_s.end_with?("[]")
|
58
|
+
end
|
59
|
+
|
60
|
+
def fill_in!
|
61
|
+
checkboxes.each do |checkbox|
|
62
|
+
if checkbox_label_in_values? checkbox
|
63
|
+
session.check(checkbox[:id])
|
64
|
+
else
|
65
|
+
session.uncheck(checkbox[:id])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def checkboxes
|
73
|
+
session.all("[name='#{field[:name]}']")
|
74
|
+
end
|
75
|
+
|
76
|
+
def checkbox_label_in_values? checkbox
|
77
|
+
values = value.split(", ")
|
78
|
+
labels = session.all("label[for='#{checkbox[:id]}']").map(&:text)
|
79
|
+
(values & labels).any?
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
55
83
|
class Checkbox < Field
|
56
84
|
def matches?
|
57
|
-
field[:type] == "checkbox"
|
85
|
+
field[:type] == "checkbox" && !field[:name].to_s.end_with?("[]")
|
58
86
|
end
|
59
87
|
|
60
88
|
def fill_in!
|
@@ -72,7 +100,23 @@ module Chop
|
|
72
100
|
end
|
73
101
|
|
74
102
|
def fill_in!
|
75
|
-
|
103
|
+
if nonstandard_labelling?
|
104
|
+
session.choose value
|
105
|
+
else
|
106
|
+
session.choose label
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def nonstandard_labelling?
|
113
|
+
value_field[:name] == field[:name]
|
114
|
+
end
|
115
|
+
|
116
|
+
def value_field
|
117
|
+
session.find_field(value)
|
118
|
+
rescue Capybara::ElementNotFound
|
119
|
+
{}
|
76
120
|
end
|
77
121
|
end
|
78
122
|
|
data/lib/chop/version.rb
CHANGED
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.12.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: 2017-03-
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|