effective_test_bot 1.1.36 → 1.2.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4b11fd2fb320e9749fb22973e5a83b3b66d40c4bc250f41c8e753f351b9ebf8
|
4
|
+
data.tar.gz: d9f59e7a13b07a2c0584009ad587dd018ab3a1f44e7515e74ae62e2a80b4087e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae3c9fe2c536236be682607375c9767e8cb752764d24cc766a0d56f53b08dade662bbe6fb4ffc45622fcf4ec6fdded9434135306cbb2d8b208b1e1aa8f69fb1a
|
7
|
+
data.tar.gz: ffef5bfd26a4708d87b328ebd9a9f5056c455a5380402c7825aa8f979bc8a1562a1ddfde1bcd1078fcc3a1615e0c2678a6e24c232f3a8335e2916f3d9fb7ec84
|
data/lib/effective_test_bot.rb
CHANGED
@@ -5,26 +5,23 @@ require 'effective_test_bot/middleware'
|
|
5
5
|
require 'effective_test_bot/version'
|
6
6
|
|
7
7
|
module EffectiveTestBot
|
8
|
-
mattr_accessor :
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def self.setup
|
26
|
-
yield self
|
27
|
-
end
|
8
|
+
mattr_accessor :passed_tests
|
9
|
+
|
10
|
+
def self.config_keys
|
11
|
+
[
|
12
|
+
:user,
|
13
|
+
:except, :only,
|
14
|
+
:fail_fast,
|
15
|
+
:form_fills,
|
16
|
+
:screenshots, :autosave_animated_gif_on_failure,
|
17
|
+
:tour_mode, :tour_mode_extreme,
|
18
|
+
:animated_gif_delay, :animated_gif_background_color,
|
19
|
+
:image_processing_class_name,
|
20
|
+
:backtrace_lines, :silence_skipped_routes
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
include EffectiveGem
|
28
25
|
|
29
26
|
# Test could be something like "crud_test", "crud_test (documents#new)", "documents", documents#new"
|
30
27
|
# Assertion will be page_title, or flash
|
@@ -10,13 +10,14 @@ module EffectiveTestBotAssertions
|
|
10
10
|
def assert_signed_in(message: 'Expected @current_user to be present when signed in')
|
11
11
|
visit(root_path)
|
12
12
|
assert_page_normal
|
13
|
-
|
13
|
+
|
14
|
+
assert assigns[current_user_assigns_key].present?, message
|
14
15
|
end
|
15
16
|
|
16
17
|
def assert_signed_out(message: 'Expected @current_user to be blank when signed out')
|
17
18
|
visit(root_path)
|
18
19
|
assert_page_normal
|
19
|
-
assert assigns[
|
20
|
+
assert assigns[current_user_assigns_key].blank?, message
|
20
21
|
end
|
21
22
|
|
22
23
|
def assert_no_exceptions(message: "(no_exceptions) Unexpected rails server exception:\n:exception:")
|
@@ -11,10 +11,12 @@ module EffectiveTestBotLoginHelper
|
|
11
11
|
def sign_in(user)
|
12
12
|
if user.kind_of?(String)
|
13
13
|
login_as(devise_user_class.find_by_email!(user))
|
14
|
-
elsif user.
|
14
|
+
elsif user.class.name.end_with?('User')
|
15
15
|
raise 'user must be persisted' unless user.persisted?
|
16
16
|
user.reload
|
17
|
-
|
17
|
+
|
18
|
+
devise_scope = user.class.name.underscore.gsub('/', '_').to_sym
|
19
|
+
login_as(user, scope: devise_scope)
|
18
20
|
elsif user == false
|
19
21
|
true # Do nothing
|
20
22
|
else
|
@@ -34,7 +36,7 @@ module EffectiveTestBotLoginHelper
|
|
34
36
|
username = (user_or_email.respond_to?(:username) ? user_or_email.username : user_or_email)
|
35
37
|
login = (user_or_email.respond_to?(:login) ? user_or_email.login : user_or_email)
|
36
38
|
|
37
|
-
within('form
|
39
|
+
within('form[id^=new][id$=user]') do
|
38
40
|
fill_form(email: email, password: password, username: username, login: login)
|
39
41
|
submit_novalidate_form
|
40
42
|
end
|
@@ -43,7 +45,7 @@ module EffectiveTestBotLoginHelper
|
|
43
45
|
def sign_up(email: Faker::Internet.email, password: Faker::Internet.password, **options)
|
44
46
|
visit (respond_to?(:new_user_registration_path) ? new_user_registration_path : '/users/sign_up')
|
45
47
|
|
46
|
-
within('form
|
48
|
+
within('form[id^=new][id$=user]') do
|
47
49
|
fill_form({email: email, password: password, password_confirmation: password}.merge(options))
|
48
50
|
submit_novalidate_form
|
49
51
|
end
|
@@ -52,12 +54,14 @@ module EffectiveTestBotLoginHelper
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def current_user
|
55
|
-
|
56
|
-
|
57
|
+
user_id = assigns.dig(current_user_assigns_key, 'id')
|
58
|
+
return if user_id.blank?
|
59
|
+
|
60
|
+
devise_user_class.where(id: user_id).first
|
57
61
|
end
|
58
62
|
|
59
63
|
def devise_user_class
|
60
|
-
User
|
64
|
+
(current_user_assigns_class || User)
|
61
65
|
end
|
62
66
|
|
63
67
|
end
|
@@ -93,6 +93,14 @@ module EffectiveTestBotTestHelper
|
|
93
93
|
key ? assigns[key.to_s] : assigns
|
94
94
|
end
|
95
95
|
|
96
|
+
def current_user_assigns_key
|
97
|
+
assigns.keys.find { |key| key.start_with?('current_') && key.end_with?('_user') } || 'current_user'
|
98
|
+
end
|
99
|
+
|
100
|
+
def current_user_assigns_class
|
101
|
+
current_user_assigns_key.sub('current_').gsub('_', '::').classify.safe_constantize
|
102
|
+
end
|
103
|
+
|
96
104
|
def access_denied_exception
|
97
105
|
return nil unless (page.evaluate_script('window.effective_test_bot.access_denied') rescue nil).present?
|
98
106
|
|
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.
|
4
|
+
version: 1.2.0
|
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: 2021-02-
|
11
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|