chop 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/lib/chop/definition_list.rb +6 -2
- data/lib/chop/form.rb +45 -3
- 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: 9437969c21a2222e26cbd07267a976fa19c58fac
|
4
|
+
data.tar.gz: 84762ef6d1eca1f80a823e10e9c62e20cfeea707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c37f4af27957e08a63433b72917e2258e0d8e64190d97e8ec30796eb804a5ca022e92ad56597dc746b603fb8e9aacb22d2155ca0e88ab7538429a5f5402e897
|
7
|
+
data.tar.gz: 011669ab54baa0009368cf7db428d1a08122e99f72a909939bbcd0bb753760192307e4aff07a9b5877a9da889b3aff6a943fcb2670fc53eb74455043ddf63707
|
data/Gemfile
CHANGED
data/lib/chop/definition_list.rb
CHANGED
@@ -3,8 +3,12 @@ require "chop/diff"
|
|
3
3
|
module Chop
|
4
4
|
class DefinitionList < Diff
|
5
5
|
self.default_selector = "dl"
|
6
|
-
self.rows_finder = ->(root)
|
7
|
-
|
6
|
+
self.rows_finder = ->(root) do
|
7
|
+
root.all("dt,dd").slice_before do |node|
|
8
|
+
node.tag_name == "dt"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
self.cells_finder = ->(row) { row }
|
8
12
|
|
9
13
|
def column index, &block
|
10
14
|
transformation do |rows|
|
data/lib/chop/form.rb
CHANGED
@@ -7,6 +7,13 @@ 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, &block
|
11
|
+
actual = session.find("form").all("input, textarea, select").map do |field|
|
12
|
+
[field.label, field.value]
|
13
|
+
end
|
14
|
+
table.diff! actual, surplus_row: false
|
15
|
+
end
|
16
|
+
|
10
17
|
def fill_in!
|
11
18
|
table.rows_hash.each do |label, value|
|
12
19
|
Field.for(session, label, value, path).fill_in!
|
@@ -110,13 +117,48 @@ module Chop
|
|
110
117
|
end
|
111
118
|
end
|
112
119
|
|
113
|
-
class
|
120
|
+
class SingleFile < Field
|
114
121
|
def matches?
|
115
|
-
field[:type] == "file"
|
122
|
+
field[:type] == "file" && !field[:multiple]
|
116
123
|
end
|
117
124
|
|
118
125
|
def fill_in!
|
119
|
-
|
126
|
+
assert_single_file!
|
127
|
+
field.set file_path
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
def file_path
|
133
|
+
::File.join(path, value).tap do |path|
|
134
|
+
::File.open(path){} # raise Errno::ENOENT if file doesn't exist
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def assert_single_file!
|
139
|
+
if value.include?(" ")
|
140
|
+
raise TypeError.new("Cannot attach multiple files to file field '#{label}' without the multiple attribute present")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
class MultipleFile < Field
|
146
|
+
def matches?
|
147
|
+
field[:type] == "file" && field[:multiple]
|
148
|
+
end
|
149
|
+
|
150
|
+
def fill_in!
|
151
|
+
field.set file_paths
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
def file_paths
|
157
|
+
value.split(" ").map do |filename|
|
158
|
+
::File.join(path, filename).tap do |path|
|
159
|
+
::File.open(path){} # raise Errno::ENOENT if file doesn't exist
|
160
|
+
end
|
161
|
+
end
|
120
162
|
end
|
121
163
|
end
|
122
164
|
|
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.18.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-
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|