effective_test_bot 1.1.31 → 1.1.36
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 +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_login_helper.rb +11 -6
- 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: 8b48d94a0636a8e399c6d2d70e26f5cc49e2071e34b8a81be179dc3334c52c9b
|
4
|
+
data.tar.gz: 4dbfa94a3c171506de7dcd51af8b7999573ab3017ef3984ffdf53e9530f731a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd447674df972509839eefcefa0cd04b9d10e058fe236dceabf6dc340f8df9ed50fe439177d15b8367b1966071c66c7ac60237bbd15ae1a58a19a29bd961c9e6
|
7
|
+
data.tar.gz: 2446921073f5b4b4be0f893f026cdc9526070f951cf4005fc145bf9c5ce3f7910a03f98efd98b3a4672887e7087db16373100693b271fa3c07f9faf5230bb0af
|
@@ -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
|
@@ -10,8 +10,8 @@ module EffectiveTestBotLoginHelper
|
|
10
10
|
# This is currently hardcoded to use the warden login_as test helper
|
11
11
|
def sign_in(user)
|
12
12
|
if user.kind_of?(String)
|
13
|
-
login_as(
|
14
|
-
elsif user.kind_of?(
|
13
|
+
login_as(devise_user_class.find_by_email!(user))
|
14
|
+
elsif user.kind_of?(devise_user_class)
|
15
15
|
raise 'user must be persisted' unless user.persisted?
|
16
16
|
user.reload
|
17
17
|
login_as(user)
|
@@ -28,7 +28,7 @@ module EffectiveTestBotLoginHelper
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def sign_in_manually(user_or_email, password = nil)
|
31
|
-
visit new_user_session_path
|
31
|
+
visit (respond_to?(:new_user_session_path) ? new_user_session_path : '/users/sign_in')
|
32
32
|
|
33
33
|
email = (user_or_email.respond_to?(:email) ? user_or_email.email : user_or_email)
|
34
34
|
username = (user_or_email.respond_to?(:username) ? user_or_email.username : user_or_email)
|
@@ -41,18 +41,23 @@ module EffectiveTestBotLoginHelper
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def sign_up(email: Faker::Internet.email, password: Faker::Internet.password, **options)
|
44
|
-
visit new_user_registration_path
|
44
|
+
visit (respond_to?(:new_user_registration_path) ? new_user_registration_path : '/users/sign_up')
|
45
45
|
|
46
46
|
within('form#new_user') do
|
47
47
|
fill_form({email: email, password: password, password_confirmation: password}.merge(options))
|
48
48
|
submit_novalidate_form
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
devise_user_class.find_by_email(email)
|
52
52
|
end
|
53
53
|
|
54
54
|
def current_user
|
55
|
-
|
55
|
+
return nil unless (assigns['current_user'] && assigns['current_user']['id'])
|
56
|
+
devise_user_class.where(id: assigns['current_user']['id']).first
|
57
|
+
end
|
58
|
+
|
59
|
+
def devise_user_class
|
60
|
+
User
|
56
61
|
end
|
57
62
|
|
58
63
|
end
|
@@ -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.36
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|