effective_test_bot 1.2.1 → 1.2.6

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
  SHA256:
3
- metadata.gz: '0194c94d76317a97cbe650d2fc39d45251f31febd79299621cd413046f4ef971'
4
- data.tar.gz: 34856863e5091e025ccf1b7e2d7d55bc244e5f41f1a7ee5bee816cb3395f9db2
3
+ metadata.gz: 83aaba6d40e5903bc270d3ef7d15eb9c5988e15069e4722b38b593926925ce62
4
+ data.tar.gz: 818e2304b4bbb87596dfea19bf4cfc4fb0e3affeaf21c0b6f1eeb5453d4818cb
5
5
  SHA512:
6
- metadata.gz: ab9002a4165085540bf180faf9a4c1a39fe87b0c807c2852e07e6204200fae69ee062b62fa86dea183a22833e4ce0b3d24ec3c24c2eab4468946c1c81be377df
7
- data.tar.gz: 52259548060269f60e142998096f3773b19527c84788ba4d10c8817109a7e78b132db54dcf2c030fbe42c18805bcac50629252c7467e329cccabb5b193040901
6
+ metadata.gz: 7f770b7229aeef54a7dc3ec5ed6ee56cb16b270cfd4904a8378415431e064369ae4df54493fe8bba897f030e1a2f9eea715829af57ad27567b95ccbf9a04d7cf
7
+ data.tar.gz: 6e2c57ee42b40bc4a76b994df92ba3cec32acc7c0647846e71b7e116e90c040b24323cb45940cf5a234d837899e17f7c90b4f02fa4f0a798e54e46b530aeb49f
@@ -3,6 +3,7 @@ require 'effective_test_bot/engine'
3
3
  require 'effective_test_bot/dsl'
4
4
  require 'effective_test_bot/middleware'
5
5
  require 'effective_test_bot/version'
6
+ require 'timecop'
6
7
 
7
8
  module EffectiveTestBot
8
9
  mattr_accessor :passed_tests
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.2.6'.freeze
3
3
  end
@@ -1,4 +1,5 @@
1
1
  module EffectiveTestBotAssertions
2
+
2
3
  def assert_page_content(content, message: "(page_content) Expected page content :content: to be present")
3
4
  assert page.has_text?(/#{Regexp.escape(content)}/i, wait: 0), message.sub(':content:', content)
4
5
  end
@@ -234,15 +235,23 @@ module EffectiveTestBotAssertions
234
235
  retval
235
236
  end
236
237
 
238
+
239
+ #include ActiveJob::TestHelper if defined?(ActiveJob::TestHelper)
240
+ def assert_email_perform_enqueued_jobs
241
+ perform_enqueued_jobs if respond_to?(:perform_enqueued_jobs)
242
+ end
243
+
237
244
  # assert_email :new_user_sign_up
238
245
  # assert_email :new_user_sign_up, to: 'newuser@example.com'
239
246
  # assert_email from: 'admin@example.com'
240
- def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil, count: nil, &block)
247
+ def assert_email(action = nil, perform: true, to: nil, from: nil, subject: nil, body: nil, message: nil, count: nil, &block)
241
248
  retval = nil
242
249
 
243
250
  if block_given?
244
251
  before = ActionMailer::Base.deliveries.length
252
+ assert_email_perform_enqueued_jobs if perform
245
253
  retval = yield
254
+
246
255
  difference = (ActionMailer::Base.deliveries.length - before)
247
256
 
248
257
  if count.present?
@@ -250,6 +259,8 @@ module EffectiveTestBotAssertions
250
259
  else
251
260
  assert (difference > 0), "(assert_email) Expected at least one email to have been delivered"
252
261
  end
262
+ else
263
+ assert_email_perform_enqueued_jobs if perform
253
264
  end
254
265
 
255
266
  if (action || to || from || subject || body).nil?
@@ -9,7 +9,7 @@ module EffectiveTestBotFormFiller
9
9
  tabs = all("a[data-toggle='tab']", wait: false)
10
10
 
11
11
  # If there's only 1 tab, just fill it out
12
- (fill_form_fields(fills) and return) unless tabs.length > 1
12
+ return fill_form_fields(fills) unless tabs.length > 1
13
13
 
14
14
  # If there's more than one tab:
15
15
  # We first fill in all fields that are outside of the tab-content
@@ -50,9 +50,10 @@ module EffectiveTestBotFormFiller
50
50
 
51
51
  # Only fills in visible fields
52
52
  # fill_form(:email => 'somethign@soneone.com', :password => 'blahblah', 'user.last_name' => 'hlwerewr')
53
- def fill_form_fields(fills = {}, debug: false)
53
+ def fill_form_fields(fills = {})
54
54
  save_test_bot_screenshot
55
55
 
56
+ debug = fills.delete(:debug)
56
57
  seen = {}
57
58
 
58
59
  5.times do
@@ -68,6 +68,18 @@ module EffectiveTestBotTestHelper
68
68
  Array(all(selector).first).each { |field| within(field) { yield } }
69
69
  end
70
70
 
71
+ def within_tab(name, &block)
72
+ first("a.nav-link#tab-#{name.parameterize}").click
73
+ within_first("div.tab-pane##{name.parameterize}") { yield }
74
+ end
75
+
76
+ def with_time_travel(date, &block)
77
+ Timecop.travel(date)
78
+ retval = yield
79
+ Timecop.return
80
+ retval
81
+ end
82
+
71
83
  def click_first(label)
72
84
  click_link(label, match: :first)
73
85
  end
@@ -98,7 +110,7 @@ module EffectiveTestBotTestHelper
98
110
  end
99
111
 
100
112
  def current_user_assigns_class
101
- current_user_assigns_key.sub('current_').gsub('_', '::').classify.safe_constantize
113
+ current_user_assigns_key.sub('current_', '').gsub('_', '::').classify.safe_constantize
102
114
  end
103
115
 
104
116
  def access_denied_exception
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.2.1
4
+ version: 1.2.6
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-03-16 00:00:00.000000000 Z
11
+ date: 2021-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: timecop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: A shared library of rails model & system tests that should pass in every
126
140
  Rails application.
127
141
  email: