effective_test_bot 1.1.21 → 1.1.26

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: cc600a312b75b6dfa9685c68125529212b3ae7f7d2a872800df53c3e2a76ad7b
4
- data.tar.gz: 4985ddb1e4e53867aa1ad6d9bb0a9351d5e22c9795499a93cc364905cbb24b75
3
+ metadata.gz: 056f99bc5e086db92fb0373956e50f9ce4c3abeb60da858f987fa944833084ef
4
+ data.tar.gz: a596e8409bac6e4962c29f5dee5f91a6e7e6f20ddcd00bb43507ae1ac681adae
5
5
  SHA512:
6
- metadata.gz: 2f851eddff76895cca9ed33f414e31bafd33ed0cc9a8e1d45671844737a5c2510932796f91e07a2c0e8f932cd4c900cde293edf7b77d72f5a33baa49b6fbf2df
7
- data.tar.gz: c0f0bf0689371be1229d79ab32dbeb24f988b46885dace4f847c46fa7eefc72297779de07d1370112480e4979d73d89f6a6c6773d1ce26928ae7e321c0145a80
6
+ metadata.gz: 6c70fe070b2150e45c10530a85b5bfb35be59194e98a1148e201cd5638a9db5db854f8baafa0be9a1cbf73ca0c6953d267ba5339e5d00b32195dc260f945ae0a
7
+ data.tar.gz: af8ddb81a52f914792a3ddd150274b74980951f08d4b8e134d3e7c40b702d142878e2a9a387bb1bcb089a8aeec4a6f19e4619d79bd6f05c67ced4d3cd013a824
@@ -2,6 +2,7 @@ ENV['RAILS_ENV'] ||= 'test'
2
2
  require_relative '../config/environment'
3
3
 
4
4
  require 'rails/test_help'
5
+ require 'minitest/mock'
5
6
  require 'minitest/spec'
6
7
  require 'minitest/reporters'
7
8
  require 'minitest/fail_fast' if EffectiveTestBot.fail_fast?
@@ -10,6 +11,8 @@ class ActiveSupport::TestCase
10
11
  # Run tests in parallel with specified workers
11
12
  # parallelize(workers: :number_of_processors) if respond_to?(:parallelize)
12
13
 
14
+ include EffectiveTestBot::DSL
15
+
13
16
  fixtures :all # Loads all fixtures in test/fixtures/*.yml
14
17
  extend Minitest::Spec::DSL # For the let syntax
15
18
  end
@@ -66,7 +66,7 @@ module EffectiveTestBot
66
66
  end
67
67
 
68
68
  def self.gifs?
69
- image_processing_class.present?
69
+ screenshots? && image_processing_class.present?
70
70
  end
71
71
 
72
72
  def self.image_processing_class
@@ -97,7 +97,7 @@ module EffectiveTestBot
97
97
  if ENV['TOUR'].present?
98
98
  ENV['TOUR'].to_s != 'false'
99
99
  else
100
- screenshots? && (tour_mode != false)
100
+ gifs? && (tour_mode != false)
101
101
  end
102
102
  end
103
103
 
@@ -106,7 +106,7 @@ module EffectiveTestBot
106
106
  if ENV['TOUR'].present?
107
107
  ['extreme', 'debug'].include?(ENV['TOUR'].to_s.downcase)
108
108
  else
109
- screenshots? && ['extreme', 'debug'].include?(tour_mode.to_s)
109
+ gifs? && ['extreme', 'debug'].include?(tour_mode.to_s)
110
110
  end
111
111
  end
112
112
 
@@ -3,6 +3,7 @@ module EffectiveTestBot
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
+ # test/support/
6
7
  include EffectiveTestBotAssertions
7
8
  include EffectiveTestBotFormFaker
8
9
  include EffectiveTestBotFormFiller
@@ -12,6 +13,8 @@ module EffectiveTestBot
12
13
  include EffectiveTestBotScreenshotsHelper
13
14
  include EffectiveTestBotTestHelper
14
15
 
16
+ BasicObject.send :include, EffectiveTestBotMocks
17
+
15
18
  # test/test_botable/
16
19
  include BaseTest
17
20
  include CrudTest
@@ -2,10 +2,17 @@ module EffectiveTestBot
2
2
  class Engine < ::Rails::Engine
3
3
  engine_name 'effective_test_bot'
4
4
 
5
- config.autoload_paths += Dir["#{config.root}/test/test_botable/", "#{config.root}/test/concerns/", "#{config.root}/test/support/"]
6
- # config.autoload_paths += Dir["#{config.root}/test/test_botable/**/"]
7
- # config.autoload_paths += Dir["#{config.root}/test/concerns/**/"]
8
- # config.autoload_paths += Dir["#{config.root}/test/support/**/"]
5
+ config.autoload_paths += Dir[
6
+ "#{config.root}/test/test_botable/",
7
+ "#{config.root}/test/concerns/",
8
+ "#{config.root}/test/support/"
9
+ ]
10
+
11
+ config.eager_load_paths += Dir[
12
+ "#{config.root}/test/test_botable/",
13
+ "#{config.root}/test/concerns/",
14
+ "#{config.root}/test/support/"
15
+ ]
9
16
 
10
17
  # Set up our default configuration options.
11
18
  initializer 'effective_test_bot.defaults', before: :load_config_initializers do |app|
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '1.1.21'.freeze
2
+ VERSION = '1.1.26'.freeze
3
3
  end
@@ -218,7 +218,15 @@ module EffectiveTestBotAssertions
218
218
  # assert_email :new_user_sign_up
219
219
  # assert_email :new_user_sign_up, to: 'newuser@example.com'
220
220
  # assert_email from: 'admin@example.com'
221
- def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil)
221
+ def assert_email(action = nil, to: nil, from: nil, subject: nil, body: nil, message: nil, &block)
222
+ if block_given?
223
+ before = ActionMailer::Base.deliveries.length
224
+ yield
225
+ after = ActionMailer::Base.deliveries.length
226
+
227
+ assert (after - before == 1), "(assert_email) Expected one email to have been delivered"
228
+ end
229
+
222
230
  if (action || to || from || subject || body).nil?
223
231
  assert ActionMailer::Base.deliveries.present?, message || "(assert_email) Expected email to have been delivered"
224
232
  return
@@ -5,6 +5,8 @@ require 'faker'
5
5
  module EffectiveTestBotFormFaker
6
6
  DIGITS = ('1'..'9').to_a
7
7
  LETTERS = %w(A B C E G H J K L M N P R S T V X Y) # valid letters of a canadian postal code, eh?
8
+ TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON']
9
+ FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF']
8
10
 
9
11
  # Generates an appropriately pseudo-random value for the given field
10
12
  # Pass in a Hash of fills to define pre-selected values
@@ -269,19 +271,11 @@ module EffectiveTestBotFormFaker
269
271
  end
270
272
 
271
273
  def truthy?(value)
272
- if defined?(::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES) # Rails 5
273
- ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(value)
274
- else
275
- ActiveRecord::Type::Boolean.new.cast(value)
276
- end
274
+ TRUE_VALUES.include?(value)
277
275
  end
278
276
 
279
277
  def falsey?(value)
280
- if defined?(::ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES) # Rails 5
281
- ::ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value)
282
- else
283
- ::ActiveRecord::Type::Boolean.new.cast(value) == false
284
- end
278
+ FALSE_VALUES.include?(value)
285
279
  end
286
280
 
287
281
  end
@@ -19,7 +19,8 @@ module EffectiveTestBotFormFiller
19
19
  active_tab = all("li.active > a[data-toggle='tab']", wait: false).first
20
20
 
21
21
  tab_content = if active_tab && active_tab['href'].present?
22
- find('div' + active_tab['href']).find(:xpath, '..')
22
+ tab_href = '#' + active_tab['href'].split('#').last
23
+ find('div' + tab_href).find(:xpath, '..')
23
24
  end
24
25
 
25
26
  excluding_fields_with_parent(tab_content) { fill_form_fields(fills) }
@@ -129,6 +130,7 @@ module EffectiveTestBotFormFiller
129
130
  @filled_country_fields = nil
130
131
 
131
132
  save_test_bot_screenshot
133
+ true
132
134
  end
133
135
 
134
136
  def fill_input_text(field, value)
@@ -0,0 +1,31 @@
1
+ # https://github.com/codeodor/minitest-stub_any_instance
2
+
3
+ # included on BasicObject when test_helper calls include EffectiveTestBot::DSL
4
+ module EffectiveTestBotMocks
5
+ def stub_any_instance(name, val_or_callable = nil, &block)
6
+ new_name = "__minitest_any_instance_stub__#{name}"
7
+ owns_method = instance_method(name).owner == self
8
+
9
+ class_eval do
10
+ alias_method new_name, name if owns_method
11
+
12
+ define_method(name) do |*args|
13
+ if val_or_callable.respond_to? :call then
14
+ instance_exec(*args, &val_or_callable)
15
+ else
16
+ val_or_callable
17
+ end
18
+ end
19
+ end
20
+
21
+ yield
22
+ ensure
23
+ class_eval do
24
+ remove_method name
25
+ if owns_method
26
+ alias_method name, new_name
27
+ remove_method new_name
28
+ end
29
+ end
30
+ end
31
+ end
@@ -7,17 +7,15 @@ module EffectiveTestBotScreenshotsHelper
7
7
  end
8
8
 
9
9
  def save_test_bot_screenshot
10
- return unless EffectiveTestBot.screenshots?
10
+ return unless EffectiveTestBot.gifs?
11
11
  return unless page.current_path.present?
12
-
12
+
13
13
  page.save_screenshot("#{current_test_temp_path}/#{current_test_screenshot_id}.png")
14
14
  true
15
15
  end
16
16
 
17
17
  def save_test_bot_failure_gif
18
- return unless EffectiveTestBot.screenshots?
19
18
  return unless EffectiveTestBot.gifs?
20
-
21
19
  return unless save_test_bot_screenshot
22
20
 
23
21
  Dir.mkdir(current_test_failure_path) unless File.exist?(current_test_failure_path)
@@ -28,7 +26,6 @@ module EffectiveTestBotScreenshotsHelper
28
26
  end
29
27
 
30
28
  def save_test_bot_tour_gif
31
- return unless EffectiveTestBot.screenshots?
32
29
  return unless EffectiveTestBot.gifs?
33
30
  return unless (@test_bot_screenshot_id || 0) > 0
34
31
 
@@ -42,9 +39,12 @@ module EffectiveTestBotScreenshotsHelper
42
39
  def without_screenshots(&block)
43
40
  original = EffectiveTestBot.screenshots
44
41
 
45
- EffectiveTestBot.screenshots = false
46
- yield
47
- EffectiveTestBot.screenshots = original
42
+ begin
43
+ EffectiveTestBot.screenshots = false
44
+ yield
45
+ ensure
46
+ EffectiveTestBot.screenshots = original
47
+ end
48
48
  end
49
49
 
50
50
  protected
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.21
4
+ version: 1.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -160,6 +160,7 @@ files:
160
160
  - test/support/effective_test_bot_form_helper.rb
161
161
  - test/support/effective_test_bot_login_helper.rb
162
162
  - test/support/effective_test_bot_minitest_helper.rb
163
+ - test/support/effective_test_bot_mocks.rb
163
164
  - test/support/effective_test_bot_screenshots_helper.rb
164
165
  - test/support/effective_test_bot_test_helper.rb
165
166
  - test/test_bot/system/application_test.rb
@@ -175,7 +176,7 @@ homepage: https://github.com/code-and-effect/effective_test_bot
175
176
  licenses:
176
177
  - MIT
177
178
  metadata: {}
178
- post_install_message:
179
+ post_install_message:
179
180
  rdoc_options: []
180
181
  require_paths:
181
182
  - lib
@@ -190,8 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  - !ruby/object:Gem::Version
191
192
  version: '0'
192
193
  requirements: []
193
- rubygems_version: 3.0.3
194
- signing_key:
194
+ rubygems_version: 3.1.2
195
+ signing_key:
195
196
  specification_version: 4
196
197
  summary: A shared library of rails model & system tests that should pass in every
197
198
  Rails application.