effective_test_bot 0.6.12 → 0.6.13
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_mailer_helper.rb +2 -2
- data/lib/effective_test_bot/version.rb +1 -1
- data/test/support/effective_test_bot_assertions.rb +13 -2
- data/test/support/effective_test_bot_form_helper.rb +25 -9
- data/test/support/effective_test_bot_test_helper.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab19f5103e6d6a08812c3a1fe04f64e679576ff5
|
4
|
+
data.tar.gz: 814dd84b78ee40413853d9188c9b0f7d8455c85f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd823aa344c7c77d33b51b809a342472a7b2ecc9e2359aa64a0e9db3c0fd96a2504a27f1b59ee5426abec0214690fcd12e37ae1ad4cf0683bf6d2a298b1fbf1
|
7
|
+
data.tar.gz: 4efb3e6bd1a5b92684096bb87cc183cc2c1f25623eef4d40fd247241144d475a190d85dca9e28683b9e4b4fb47a6d5a24d8a1eee49ec2450b89b797dae2fa2d1
|
@@ -2,7 +2,7 @@ module EffectiveTestBotMailerHelper
|
|
2
2
|
# This is included to ActionMailer::Base an after_filter
|
3
3
|
# And allows the assert_email assertion to work
|
4
4
|
def assign_test_bot_mailer_info
|
5
|
-
|
6
|
-
|
5
|
+
actions = ActionMailer::Base.instance_variable_get(:@mailer_actions)
|
6
|
+
ActionMailer::Base.instance_variable_set(:@mailer_actions, Array(actions) + [action_name])
|
7
7
|
end
|
8
8
|
end
|
@@ -93,6 +93,16 @@ module EffectiveTestBotAssertions
|
|
93
93
|
assert (active.blank? || active.zero?), message.sub(':count:', active.to_s)
|
94
94
|
end
|
95
95
|
|
96
|
+
def assert_no_active_jobs(message = "(no_active_jobs) :count: Unexpected ActiveJob jobs present")
|
97
|
+
jobs = if defined?(SuckerPunch)
|
98
|
+
SuckerPunch::Queue.all.length
|
99
|
+
else
|
100
|
+
ActiveJob::Base.queue_adapter.enqueued_jobs.count
|
101
|
+
end
|
102
|
+
|
103
|
+
assert (jobs == 0), message.sub(':count:', jobs.to_s)
|
104
|
+
end
|
105
|
+
|
96
106
|
def assert_no_js_errors(message = nil)
|
97
107
|
errors = page.driver.error_messages
|
98
108
|
assert errors.blank?, message || "(no_js_errors) Unexpected javascript error:\n#{errors.first.to_s}"
|
@@ -184,16 +194,17 @@ module EffectiveTestBotAssertions
|
|
184
194
|
# assert_email :new_user_sign_up, to: 'newuser@example.com'
|
185
195
|
# assert_email from: 'admin@example.com'
|
186
196
|
def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil)
|
187
|
-
|
188
197
|
if (action || to || from || subject || body).nil?
|
189
198
|
assert ActionMailer::Base.deliveries.present?, message || "(assert_email) Expected email to have been delivered"
|
190
199
|
return
|
191
200
|
end
|
192
201
|
|
202
|
+
actions = ActionMailer::Base.instance_variable_get(:@mailer_actions)
|
203
|
+
|
193
204
|
ActionMailer::Base.deliveries.each do |message|
|
194
205
|
matches = true
|
195
206
|
|
196
|
-
matches &&= (
|
207
|
+
matches &&= (actions.include?(action.to_s)) if action
|
197
208
|
matches &&= (Array(message.to).include?(to)) if to
|
198
209
|
matches &&= (Array(message.from).include?(from)) if from
|
199
210
|
matches &&= (message.subject == subject) if subject
|
@@ -64,14 +64,7 @@ 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, last: false, debug: false)
|
67
|
-
|
68
|
-
submit = find(:link_or_button, label, match: :first)
|
69
|
-
assert submit.present?, "TestBotError: Unable to find a visible submit link or button on #{page.current_path} with the label #{label}"
|
70
|
-
else
|
71
|
-
submit = find("input[type='submit'],button[type='submit']", match: :first)
|
72
|
-
submit = all("input[type='submit'],button[type='submit']").last if last
|
73
|
-
assert submit.present?, "TestBotError: Unable to find a visible input[type='submit'] or button[type='submit'] on #{page.current_path}"
|
74
|
-
end
|
67
|
+
submit = find_submit(label, last: last)
|
75
68
|
|
76
69
|
if EffectiveTestBot.screenshots?
|
77
70
|
page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.disableFormElement($(this)); });"
|
@@ -80,7 +73,7 @@ module EffectiveTestBotFormHelper
|
|
80
73
|
end
|
81
74
|
|
82
75
|
if debug
|
83
|
-
puts "Clicking: <#{submit.tag_name} id='#{submit['id']}' class='#{submit['class']}' name='#{submit['name']}' value='#{submit['value']}' />"
|
76
|
+
puts "Clicking: <#{submit.tag_name} id='#{submit['id']}' class='#{submit['class']}' name='#{submit['name']}' value='#{submit['value']}' href='#{submit['href']}' />"
|
84
77
|
end
|
85
78
|
|
86
79
|
submit.click
|
@@ -91,6 +84,29 @@ module EffectiveTestBotFormHelper
|
|
91
84
|
true
|
92
85
|
end
|
93
86
|
|
87
|
+
# Keys are :value, should be one of :count, :minimum, :maximum, :between, :text, :id, :class, :visible, :exact, :exact_text, :match, :wait, :filter_se
|
88
|
+
def find_submit(label, last: false)
|
89
|
+
submit = nil
|
90
|
+
|
91
|
+
if label.present?
|
92
|
+
submit = (find("input[type='submit'][value='#{label}'],button[type='submit'][value='#{label}']", match: :first) rescue nil)
|
93
|
+
submit ||= find(:link_or_button, label, match: :first)
|
94
|
+
|
95
|
+
if last
|
96
|
+
submit = all("input[type='submit'][value='#{label}'],button[type='submit'][value='#{label}']").last
|
97
|
+
submit ||= all('a', text: label).last
|
98
|
+
end
|
99
|
+
|
100
|
+
assert submit.present?, "TestBotError: Unable to find a visible submit link or button on #{page.current_path} with the label #{label}"
|
101
|
+
else
|
102
|
+
submit = find("input[type='submit'],button[type='submit']", match: :first)
|
103
|
+
submit = all("input[type='submit'],button[type='submit']").last if last
|
104
|
+
assert submit.present?, "TestBotError: Unable to find a visible input[type='submit'] or button[type='submit'] on #{page.current_path}"
|
105
|
+
end
|
106
|
+
|
107
|
+
submit
|
108
|
+
end
|
109
|
+
|
94
110
|
def with_raised_unpermitted_params_exceptions(&block)
|
95
111
|
action = nil
|
96
112
|
|
@@ -16,6 +16,20 @@ module EffectiveTestBotTestHelper
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def wait_for_active_job
|
20
|
+
begin
|
21
|
+
Timeout.timeout(Capybara.default_max_wait_time * 2) do
|
22
|
+
if defined?(SuckerPunch)
|
23
|
+
loop until SuckerPunch::Queue.all.length == 0
|
24
|
+
else
|
25
|
+
loop until ActiveJob::Base.queue_adapter.enqueued_jobs.count == 0
|
26
|
+
end
|
27
|
+
end
|
28
|
+
rescue => e
|
29
|
+
assert_no_active_jobs
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
19
33
|
def finished_all_ajax_requests?
|
20
34
|
ajax_request_count = page.evaluate_script('jQuery.active')
|
21
35
|
ajax_request_count.blank? || ajax_request_count.zero?
|
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.6.
|
4
|
+
version: 0.6.13
|
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: 2017-11-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|