effective_test_bot 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e527752317f5fa4794ff447b856c3d975d4bf88
4
- data.tar.gz: c4fd0acdfbc5bbb1d6435dd9cf01eaf3673b3320
3
+ metadata.gz: 1af9730f46872f097b9d825a6d6e084aa9b152ff
4
+ data.tar.gz: 3180d006dd3ff2fef23e86e68e8561f855bad160
5
5
  SHA512:
6
- metadata.gz: 783e6c019ce1fa4316c894d2cbddf121ea0986b2d00ad55f770fed20dd5da220b437194d66d3e5bc1504b3d7724fc016a4a969bdd208f801a851cb46b71ca17a
7
- data.tar.gz: fe44090e65b67525eb9ae2b2456a661307cce75b4c81ac701353d785e30fccc22df9554e03d4107796a1c78fc582d726ee59a341c4383446cf1f43e04983b921
6
+ metadata.gz: a1d4f26b996ebb47642951ef294656e0526bdc676163c5d25291696d661295fbe7091b6d4ee93e3bc344e232e7b44c167d34ed15aa3452552bac612a17df34ed
7
+ data.tar.gz: 53d3c71075a40210e2ace8507497562cfbf9ca856396b2e6dca459ea47ea222359c3a453249351c8dc57e83c461a571f8655c6ca43823e8b642dec0a043a951a
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.5.2'.freeze
3
3
  end
@@ -37,6 +37,12 @@ module EffectiveTestBotFormFiller
37
37
  within('div' + tab['href']) { fill_form_fields(fills) }
38
38
  end
39
39
 
40
+ # If there is no visible submits, go back to the first tab
41
+ if all(:css, "input[type='submit']").length == 0
42
+ tabs.first.click()
43
+ synchronize!
44
+ save_test_bot_screenshot
45
+ end
40
46
  end
41
47
 
42
48
  # Only fills in visible fields
@@ -217,6 +223,15 @@ module EffectiveTestBotFormFiller
217
223
  def value_for_input_checkbox_field(field, fill_value)
218
224
  if fill_value.present?
219
225
  fill_values = Array(fill_value) # Allow an array of fill values to be passed
226
+
227
+ if ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(fill_value)
228
+ fill_values = ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.to_a
229
+ end
230
+
231
+ if ::ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(fill_value)
232
+ fill_values = ::ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.to_a
233
+ end
234
+
220
235
  (fill_values.include?(field['value']) || fill_values.include?(field.find(:xpath, '..').text))
221
236
  elsif field['value'] == 'true'
222
237
  true
@@ -261,6 +276,10 @@ module EffectiveTestBotFormFiller
261
276
  number = Random.new.rand(min..max)
262
277
  number = (number.kind_of?(Float) ? number.round(2) : number)
263
278
 
279
+ if (field['step'] == '1' || field['class'].to_s.split(' ').include?('integer'))
280
+ number = number.to_i
281
+ end
282
+
264
283
  return number if field['max'].blank?
265
284
 
266
285
  shared_max_fields = all(selector)
@@ -64,22 +64,21 @@ module EffectiveTestBotFormHelper
64
64
  # Instead we manually trigger submit buttons and use the data-disable-with to
65
65
  # make the 'submit form' step look nice
66
66
  def click_submit(label)
67
- if EffectiveTestBot.screenshots?
68
- page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.disableFormElement($(this)); });"
69
- save_test_bot_screenshot
70
- page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.enableFormElement($(this)); });"
71
- end
72
-
73
67
  if label.present?
74
68
  submit = find(:link_or_button, label)
75
69
  assert submit.present?, "TestBotError: Unable to find a visible submit link or button on #{page.current_path} with the label #{label}"
76
- submit.click
77
70
  else
78
71
  submit = first(:css, "input[type='submit']")
79
72
  assert submit.present?, "TestBotError: Unable to find a visible input[type='submit'] on #{page.current_path}"
80
- submit.click
81
73
  end
82
74
 
75
+ if EffectiveTestBot.screenshots?
76
+ page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.disableFormElement($(this)); });"
77
+ save_test_bot_screenshot
78
+ page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.enableFormElement($(this)); });"
79
+ end
80
+
81
+ submit.click
83
82
  synchronize!
84
83
  true
85
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_test_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-16 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails