effective_test_bot 1.1.30 → 1.1.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_test_bot_controller_helper.rb +2 -2
- data/lib/effective_test_bot/version.rb +1 -1
- data/test/support/effective_test_bot_assertions.rb +21 -3
- data/test/support/effective_test_bot_form_filler.rb +18 -3
- data/test/support/effective_test_bot_form_helper.rb +2 -2
- data/test/support/effective_test_bot_test_helper.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc72acbdf713f34184e3b5ad7f5667632d0f6328a106de14042c74cf5f4905f6
|
4
|
+
data.tar.gz: 436bf4dee3250bb087ba2cb9119d48e7a4853078f0509cd9558feedb37114083
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fb77d02cfa0da8f3b940fa697d7dcfa935f7a3c08003108a850a83d4073290e242bba9f448962f31bf27193879350a0f3e35c69e61c26b50193f4e751b68c96
|
7
|
+
data.tar.gz: 3778d54b3764389c71b9438b327218b56e55d9220b431062b8d1816d7c470e0d16a9215e92e7549c05cb45f76824c249329fa8d6d4434d2184d74652fe527ff3
|
@@ -58,10 +58,10 @@ module EffectiveTestBotControllerHelper
|
|
58
58
|
case object
|
59
59
|
when ActiveRecord::Base
|
60
60
|
assigns[key] = object.attributes
|
61
|
-
assigns[key][:errors] = object.errors.messages.
|
61
|
+
assigns[key][:errors] = object.errors.messages.select { |_, v| v.present? } if object.errors.present?
|
62
62
|
when (ActiveModel::Model rescue nil)
|
63
63
|
assigns[key] = object.respond_to?(:attributes) ? object.attributes : { present_but_not_serialized: true }
|
64
|
-
assigns[key][:errors] = object.errors.messages.
|
64
|
+
assigns[key][:errors] = object.errors.messages.select { |_, v| v.present? } if object.errors.present?
|
65
65
|
when TrueClass, FalseClass, NilClass, String, Symbol, Numeric
|
66
66
|
assigns[key] = object
|
67
67
|
else
|
@@ -217,16 +217,34 @@ module EffectiveTestBotAssertions
|
|
217
217
|
assert diff.blank?, "(assert_no_email) #{diff.length} unexpected emails delivered: #{diff}"
|
218
218
|
end
|
219
219
|
|
220
|
+
# assert_effective_log { click_on('download.txt') }
|
221
|
+
def assert_effective_log(status: nil)
|
222
|
+
raise('EffectiveLogging is not defined') unless defined?(EffectiveLogging)
|
223
|
+
raise('expected a block') unless block_given?
|
224
|
+
|
225
|
+
logs = (status.present? ? Effective::Log.where(status: status).all : Effective::Log.all)
|
226
|
+
|
227
|
+
before = logs.count
|
228
|
+
yield
|
229
|
+
after = logs.count
|
230
|
+
|
231
|
+
assert (after - before == 1), "(assert_effective_log) Expected one log to have been created"
|
232
|
+
end
|
233
|
+
|
220
234
|
# assert_email :new_user_sign_up
|
221
235
|
# assert_email :new_user_sign_up, to: 'newuser@example.com'
|
222
236
|
# assert_email from: 'admin@example.com'
|
223
|
-
def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil, &block)
|
237
|
+
def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil, count: nil, &block)
|
224
238
|
if block_given?
|
225
239
|
before = ActionMailer::Base.deliveries.length
|
226
240
|
yield
|
227
|
-
|
241
|
+
difference = (ActionMailer::Base.deliveries.length - before)
|
228
242
|
|
229
|
-
|
243
|
+
if count.present?
|
244
|
+
assert (difference == count), "(assert_email) Expected #{count} email to have been delivered, but #{difference} were instead"
|
245
|
+
else
|
246
|
+
assert (difference > 0), "(assert_email) Expected at least one email to have been delivered"
|
247
|
+
end
|
230
248
|
end
|
231
249
|
|
232
250
|
if (action || to || from || subject || body).nil?
|
@@ -37,7 +37,7 @@ module EffectiveTestBotFormFiller
|
|
37
37
|
save_test_bot_screenshot
|
38
38
|
|
39
39
|
tab_href = '#' + tab['href'].to_s.split('#').last
|
40
|
-
|
40
|
+
within_if('div' + tab_href) { fill_form_fields(fills) }
|
41
41
|
end
|
42
42
|
|
43
43
|
# If there is no visible submits, go back to the first tab
|
@@ -193,8 +193,23 @@ module EffectiveTestBotFormFiller
|
|
193
193
|
save_test_bot_screenshot
|
194
194
|
end
|
195
195
|
|
196
|
-
if
|
197
|
-
|
196
|
+
if value == :unselect
|
197
|
+
return close_effective_select(field)
|
198
|
+
end
|
199
|
+
|
200
|
+
if field.all('option:enabled', wait: false).length == 0
|
201
|
+
return close_effective_select(field)
|
202
|
+
end
|
203
|
+
|
204
|
+
# Must be some options
|
205
|
+
Array(value).each do |value|
|
206
|
+
option = field.all("option:enabled[value=\"#{value}\"]", wait: false).first
|
207
|
+
option ||= field.all('option:enabled', wait: false).find { |field| field.text == value }
|
208
|
+
|
209
|
+
if option.present?
|
210
|
+
option.select_option
|
211
|
+
else
|
212
|
+
# This will most likely raise an error that it cant be found
|
198
213
|
field.select(value.to_s, match: :first, disabled: false)
|
199
214
|
end
|
200
215
|
end
|
@@ -106,7 +106,7 @@ module EffectiveTestBotFormHelper
|
|
106
106
|
# This kind of sucks, as we want to simulate mouse movements with the tour
|
107
107
|
# Instead we manually trigger submit buttons and use the data-disable-with to
|
108
108
|
# make the 'submit form' step look nice
|
109
|
-
def click_submit(label = nil, last: false, debug: false)
|
109
|
+
def click_submit(label = nil, last: false, synchronize: true, debug: false)
|
110
110
|
submit = find_submit(label, last: last)
|
111
111
|
|
112
112
|
if EffectiveTestBot.screenshots?
|
@@ -128,7 +128,7 @@ module EffectiveTestBotFormHelper
|
|
128
128
|
submit.click
|
129
129
|
end
|
130
130
|
|
131
|
-
synchronize!
|
131
|
+
synchronize ? synchronize! : sleep(2)
|
132
132
|
|
133
133
|
save_test_bot_screenshot if EffectiveTestBot.screenshots? && page.current_path.present?
|
134
134
|
|
@@ -57,7 +57,7 @@ module EffectiveTestBotTestHelper
|
|
57
57
|
|
58
58
|
# Calls capybara within do .. end if selector is present and bool is true
|
59
59
|
def within_if(selector, bool = true, &block)
|
60
|
-
(selector.
|
60
|
+
(all(selector).length > 0 && bool) ? within(first(selector)) { yield } : yield
|
61
61
|
end
|
62
62
|
|
63
63
|
def within_each(selector, &block)
|
@@ -73,7 +73,8 @@ module EffectiveTestBotTestHelper
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def effective_bootstrap_custom_data_confirm?
|
76
|
-
(page.evaluate_script('$.rails.effective_bootstrap_custom_data_confirm') rescue nil)
|
76
|
+
(page.evaluate_script('$.rails.effective_bootstrap_custom_data_confirm') rescue nil) ||
|
77
|
+
(page.evaluate_script('window.Rails.effective_bootstrap_custom_data_confirm') rescue nil)
|
77
78
|
end
|
78
79
|
|
79
80
|
# EffectiveTestBot includes an after_filter on ApplicationController to set an http header
|
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: 1.1.
|
4
|
+
version: 1.1.35
|
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:
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|