cuke_master 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cuke_master/steps.rb +25 -8
- data/lib/cuke_master/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: 1197cf9d75b0ddac8b26f663f914e89e83e229b2
|
4
|
+
data.tar.gz: b89cfafb7bafb463ae8ab255410dee63b6689261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a339d0512962797337e29b4bb4ca14567aba64f08eb8296ddfa17179cfbf30216092bcd547ec7aa28dd44e1ba2c0918cd5242dd9f7a4fad5641065f79c6a4c6
|
7
|
+
data.tar.gz: dd3a4f027efebe9f4230988b0e35630a116f6b7e351c5e9b9eecad726a1f6a47c8178d1ebe0ababfbe7d9897728293e7801669d52ee300cf2ac4c4077f713bcf
|
data/lib/cuke_master/steps.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# rubocop:disable Lint/Debugger, HandleExceptions
|
2
|
+
# rubocop:disable BlockLength
|
3
|
+
require 'securerandom'
|
2
4
|
|
3
5
|
# 1. ========= BROWSE ACTIONS ===========
|
4
6
|
# 1.1 Visit a URL
|
@@ -221,15 +223,30 @@ When(/^I attach file to field with attribute "([^"]*)" value "([^"]*)" with \
|
|
221
223
|
.querySelector(
|
222
224
|
'input[#{attribute_name}=\"#{attribute_value}\"]'
|
223
225
|
).style.display = 'block';"
|
224
|
-
page.execute_script \
|
225
|
-
"document
|
226
|
-
.querySelector(
|
227
|
-
'input[#{attribute_name}=\"#{attribute_value}\"]'
|
228
|
-
).name = 'uniqueFieldForCapybara';"
|
229
226
|
|
230
|
-
|
231
|
-
|
232
|
-
|
227
|
+
el = first(:xpath,
|
228
|
+
".//input[contains(@#{attribute_name}, '#{attribute_value}')]")
|
229
|
+
unless el
|
230
|
+
raise "No such file field found with \
|
231
|
+
attribute \"#{attribute}\" ~= \"#{value}\""
|
232
|
+
end
|
233
|
+
|
234
|
+
if el['name']
|
235
|
+
attach_file el['name'],
|
236
|
+
"#{root_folder}/uploads/#{file_path}",
|
237
|
+
visible: false
|
238
|
+
else
|
239
|
+
# for input without a name, we will create a name
|
240
|
+
unique_name = SecureRandom.uuid
|
241
|
+
page.execute_script \
|
242
|
+
"document
|
243
|
+
.querySelector(
|
244
|
+
'input[#{attribute_name}=\"#{attribute_value}\"]'
|
245
|
+
).name = 'uploaded_file_#{unique_name}';"
|
246
|
+
attach_file "uploaded_file_#{unique_name}",
|
247
|
+
"#{root_folder}/uploads/#{file_path}",
|
248
|
+
visible: false
|
249
|
+
end
|
233
250
|
end
|
234
251
|
|
235
252
|
# 3.12 Fill in a special tag
|
data/lib/cuke_master/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuke_master
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Huynh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|