cuke_master 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb2250806db91cdb21f214bd0cb36c59893337a9
4
- data.tar.gz: 30b89b34c02f1657e3fd594efe5e7efb82bd49da
3
+ metadata.gz: 1197cf9d75b0ddac8b26f663f914e89e83e229b2
4
+ data.tar.gz: b89cfafb7bafb463ae8ab255410dee63b6689261
5
5
  SHA512:
6
- metadata.gz: 0ec4276d601dcb77e8d88a118f5cbce34a02c20334ec37cb93b45e9ad9332cbdd259470856627993aeb6603794f8e530578e1f155d7413021cecb5aa93840418
7
- data.tar.gz: 56ce9324c4a24dadb65c02f652f7eed06b1a18872ae6f56224be6771a1454912eb656b2479105079a01bb02c069d5918535fe4bf342f5728b3f547daf3298225
6
+ metadata.gz: 7a339d0512962797337e29b4bb4ca14567aba64f08eb8296ddfa17179cfbf30216092bcd547ec7aa28dd44e1ba2c0918cd5242dd9f7a4fad5641065f79c6a4c6
7
+ data.tar.gz: dd3a4f027efebe9f4230988b0e35630a116f6b7e351c5e9b9eecad726a1f6a47c8178d1ebe0ababfbe7d9897728293e7801669d52ee300cf2ac4c4077f713bcf
@@ -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
- attach_file 'uniqueFieldForCapybara',
231
- "#{root_folder}/uploads/#{file_path}",
232
- visible: false
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
@@ -1,3 +1,3 @@
1
1
  module CukeMaster
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
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.2
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-18 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler