effective_test_bot 0.4.8 → 0.4.9

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: b74466446800d58bfb33f2216c378cf5528adc4d
4
- data.tar.gz: 1ca9bacaae0a77a4df55a81542afd425e0a5b797
3
+ metadata.gz: 6cf4d62267c1a02ff2a0bd22303f3ee9910e16ba
4
+ data.tar.gz: 9c971d7950781d4195c2e13b0dd2af2dd4ebe7eb
5
5
  SHA512:
6
- metadata.gz: 5b945654383760acb1fb5dc44a3f43acf72f760f97b2d49491b4d8d57c37ba36310b96c37629b552445254d9358512bc044474529a16b0d5bc652707759963be
7
- data.tar.gz: cd991c7acf1fed501e492d664407cc2e9383d627f371d54527d0c30a52b2eda79a8d4f5236eb23d068b11bc983459574167d01cf6bd0fdf322605ae7fcb26f61
6
+ metadata.gz: e78e8b4eca28808362fd52db931bb236d26571a814d7dabf372a6c268899b853d9c2c2cc405c5b53013250854f692717e1d7cf1c9b822e13649fcbd19f3aeb65
7
+ data.tar.gz: 9ac142dffbfc8288e6ebe00d9335f4d7c5b8a69d470be8dd32503232e42859bebaa945688715ebc8d9083f0998a30f020e4a920217e6926c865b66e8331df27b
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '0.4.8'.freeze
2
+ VERSION = '0.4.9'.freeze
3
3
  end
@@ -119,7 +119,6 @@ module TestBotable
119
119
 
120
120
  # Instance Methods
121
121
 
122
-
123
122
  # Using reverse_merge! in the dsl action_tests makes sure that the
124
123
  # class level can assign a current_test variable
125
124
  # wheras the action level ones it's not present.
@@ -130,11 +129,17 @@ module TestBotable
130
129
  self.class.normalize_test_bot_options!(options)
131
130
  end
132
131
 
133
- lets.each { |k, v| self.class.let(k) { v } } # Using the minitest spec let(:foo) { 'bar' } syntax
132
+ # Clear any previously defined memoized values
133
+ @_memoized = nil # This clears the minitest let! syntax memoized values
134
134
 
135
- # test_bot may leak some lets from one test to the next, if they're not overridden
136
- # I take special care to undefine just current test so far
137
- self.class.let(:current_test) { nil } if options[:current_test].blank?
135
+ # Using the minitest spec let(:foo) { 'bar' } syntax
136
+ lets.each do |key, value|
137
+ if value.kind_of?(Hash) && !value.kind_of?(HashWithIndifferentAccess)
138
+ self.class.let(key) { HashWithIndifferentAccess.new(value) }
139
+ else
140
+ self.class.let(key) { value }
141
+ end
142
+ end
138
143
 
139
144
  lets
140
145
  end
@@ -80,8 +80,9 @@ module EffectiveTestBotAssertions
80
80
 
81
81
  # This must be run after submit_form()
82
82
  # It ensures there are no HTML5 validation errors that would prevent the form from being submit
83
+ # Browsers seem to only consider visible fields, so we will to
83
84
  def assert_no_html5_form_validation_errors(message = nil)
84
- errors = all(':invalid', visible: false).map { |field| field['name'] }
85
+ errors = all(':invalid', visible: true).map { |field| field['name'] }
85
86
  assert errors.blank?, message || "(no_html5_form_validation_errors) Unable to submit form, unexpected HTML5 validation error present on the following fields:\n#{errors.join("\n")}"
86
87
  end
87
88
 
@@ -128,7 +129,7 @@ module EffectiveTestBotAssertions
128
129
  assert errors.blank?, message || "(no_assigns_errors) Unexpected @#{key} rails validation errors:\n#{errors}"
129
130
  else
130
131
  assigns.each do |key, value|
131
- errors = value['errors']
132
+ errors = value['errors'] if value.respond_to?(:[])
132
133
  assert errors.blank?, message || "(no_assigns_errors) Unexpected @#{key} rails validation errors:\n#{errors}"
133
134
  end
134
135
  end
@@ -5,7 +5,7 @@ module EffectiveTestBotFormFiller
5
5
  LETTERS = ('A'..'Z').to_a
6
6
 
7
7
  # Fill a boostrap tabs based form
8
- def fill_bootstrap_tabs_form(fills = {}, boostrap_tab_elements = nil)
8
+ def fill_bootstrap_tabs_form(fills = HashWithIndifferentAccess.new, boostrap_tab_elements = nil)
9
9
  fills = HashWithIndifferentAccess.new(fills) unless fills.kind_of?(HashWithIndifferentAccess)
10
10
 
11
11
  tabs = boostrap_tab_elements || all("a[data-toggle='tab']")
@@ -42,7 +42,7 @@ module EffectiveTestBotFormFiller
42
42
 
43
43
  # Only fills in visible fields
44
44
  # fill_form(:email => 'somethign@soneone.com', :password => 'blahblah', 'user.last_name' => 'hlwerewr')
45
- def fill_form_fields(fills = {})
45
+ def fill_form_fields(fills = HashWithIndifferentAccess.new)
46
46
  fills = HashWithIndifferentAccess.new(fills) unless fills.kind_of?(HashWithIndifferentAccess)
47
47
 
48
48
  save_test_bot_screenshot
@@ -191,10 +191,14 @@ module EffectiveTestBotFormFiller
191
191
  d[0] + d[1] + d[2] + '-' + d[3] + d[4] + d[5] + '-' + d[6] + d[7] + d[8] + d[9]
192
192
  when 'textarea'
193
193
  Faker::Lorem.paragraph
194
- when 'input_checkbox'
195
- [true, false].sample
196
- when 'input_radio'
197
- [true, false].sample
194
+ when 'input_checkbox', 'input_radio'
195
+ if field['value'] == 'true'
196
+ true
197
+ elsif field['value'] == 'false'
198
+ false
199
+ else
200
+ [true, false].sample
201
+ end
198
202
  when 'input_file'
199
203
  "#{File.dirname(__FILE__)}/important_documents._test"
200
204
  else
@@ -3,15 +3,16 @@ require 'timeout'
3
3
  module EffectiveTestBotFormHelper
4
4
  # Intelligently fills a form with Faker based randomish input
5
5
  # Delegates the form fill logic to effective_test_bot_form_filler
6
- def fill_form(fills = {})
7
- fills = HashWithIndifferentAccess.new(fills) unless fills.kind_of?(HashWithIndifferentAccess)
6
+ def fill_form(local_fills = {})
7
+ # The fills here are from a let!(:fills) { 'Something' } as defined in an _action test
8
+ fill_values = ((fills if defined?(fills)) || HashWithIndifferentAccess.new).merge(local_fills)
8
9
 
9
10
  bootstrap_tabs = all("a[data-toggle='tab']")
10
11
 
11
12
  if bootstrap_tabs.length > 1
12
- fill_bootstrap_tabs_form(fills, bootstrap_tabs)
13
+ fill_bootstrap_tabs_form(fill_values, bootstrap_tabs)
13
14
  else
14
- fill_form_fields(fills)
15
+ fill_form_fields(fill_values)
15
16
  end
16
17
  true
17
18
  end
@@ -29,6 +29,10 @@ module EffectiveTestBotTestHelper
29
29
  end
30
30
  end
31
31
 
32
+ def click_first(label)
33
+ click_link(label, match: :first)
34
+ end
35
+
32
36
  # EffectiveTestBot includes an after_filter on ApplicationController to set an http header
33
37
  # These values are 'from the last page submit or refresh'
34
38
  def flash
@@ -19,10 +19,17 @@ module WizardTest
19
19
  submit_form
20
20
  end
21
21
 
22
- break if page.current_path == to_path
22
+ if to_path.present?
23
+ # Keep going till we hit a certain to_path
24
+ break if page.current_path == to_path
25
+ else
26
+ # Keep going till there's no more submit buttons
27
+ break if all("input[type='submit']").blank?
28
+ end
29
+
23
30
  end
24
31
 
25
- assert_current_path to_path
32
+ assert_current_path(to_path) if to_path.present?
26
33
  end
27
34
 
28
35
  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.4.8
4
+ version: 0.4.9
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: 2015-11-20 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails