rspeckled 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rspeckled/{plugins/rails/engine.rb → patches/rails/namespaced_engine_controller_route_fix.rb} +2 -0
  4. data/lib/rspeckled/patches.rb +10 -0
  5. data/lib/rspeckled/plugins/configuration/bullet.rb +5 -0
  6. data/lib/rspeckled/plugins/configuration/capybara.rb +22 -0
  7. data/lib/rspeckled/plugins/configuration/capybara_screenshot.rb +17 -0
  8. data/lib/rspeckled/plugins/configuration/carrier_wave.rb +13 -0
  9. data/lib/rspeckled/plugins/configuration/database_cleaner.rb +7 -0
  10. data/lib/rspeckled/plugins/configuration/devise.rb +18 -0
  11. data/lib/rspeckled/plugins/{dox.rb → configuration/dox.rb} +1 -8
  12. data/lib/rspeckled/plugins/configuration/elasticsearch.rb +3 -0
  13. data/lib/rspeckled/plugins/configuration/email_spec.rb +7 -0
  14. data/lib/rspeckled/plugins/configuration/factory_bot.rb +13 -0
  15. data/lib/rspeckled/plugins/{fakeredis.rb → configuration/fakeredis.rb} +0 -0
  16. data/lib/rspeckled/plugins/{mongoid.rb → configuration/mongoid.rb} +1 -1
  17. data/lib/rspeckled/plugins/configuration/omniauth.rb +5 -0
  18. data/lib/rspeckled/plugins/{recaptcha.rb → configuration/recaptcha.rb} +1 -1
  19. data/lib/rspeckled/plugins/configuration/selenium_webdriver.rb +3 -0
  20. data/lib/rspeckled/plugins/configuration/shoulda.rb +36 -0
  21. data/lib/rspeckled/plugins/{test_after_commit.rb → configuration/sidekiq.rb} +1 -1
  22. data/lib/rspeckled/plugins/{simple_cov.rb → configuration/simple_cov.rb} +2 -2
  23. data/lib/rspeckled/plugins/configuration/test_after_commit.rb +3 -0
  24. data/lib/rspeckled/plugins/configuration/vcr.rb +26 -0
  25. data/lib/rspeckled/plugins/configuration/warden.rb +7 -0
  26. data/lib/rspeckled/plugins/configuration/webmock.rb +3 -0
  27. data/lib/rspeckled/plugins/{wisper.rb → configuration/wisper.rb} +1 -1
  28. data/lib/rspeckled/plugins/{awesome_print.rb → extensions/awesome_print.rb} +6 -6
  29. data/lib/rspeckled/plugins/extensions/capybara.rb +30 -0
  30. data/lib/rspeckled/{factories → plugins/extensions/factory_bot}/sequences.rb +4 -4
  31. data/lib/rspeckled/plugins/{faraday.rb → extensions/faraday/middleware/curl_logger.rb} +1 -3
  32. data/lib/rspeckled/plugins/extensions/faraday.rb +5 -0
  33. data/lib/rspeckled/{mock_authentications/omniauth → plugins/extensions/omniauth/mock_authentications}/ebay.rb +3 -1
  34. data/lib/rspeckled/{mock_authentications/omniauth → plugins/extensions/omniauth/mock_authentications}/facebook.rb +3 -1
  35. data/lib/rspeckled/{mock_authentications/omniauth → plugins/extensions/omniauth/mock_authentications}/twitter.rb +3 -1
  36. data/lib/rspeckled/plugins/extensions/omniauth.rb +12 -0
  37. data/lib/rspeckled/{rails → plugins/extensions/rails}/railtie.rb +3 -1
  38. data/lib/rspeckled/plugins/{garbage_collection.rb → extensions/ruby/deferred_garbage_collection.rb} +7 -15
  39. data/lib/rspeckled/{selenium → plugins/extensions/selenium}/drivers/chrome.rb +1 -1
  40. data/lib/rspeckled/{selenium → plugins/extensions/selenium}/drivers/firefox.rb +1 -1
  41. data/lib/rspeckled/plugins/extensions/strong_parameters.rb +13 -0
  42. data/lib/rspeckled/{vcr_matchers → plugins/extensions/vcr/matchers}/uri_without_trailing_id.rb +4 -12
  43. data/lib/rspeckled/plugins/extensions/vcr.rb +13 -0
  44. data/lib/rspeckled/plugins/hooks/action_mailer.rb +15 -0
  45. data/lib/rspeckled/plugins/{authentication.rb → hooks/authentication.rb} +12 -4
  46. data/lib/rspeckled/plugins/hooks/bullet.rb +22 -0
  47. data/lib/rspeckled/plugins/hooks/capybara.rb +44 -0
  48. data/lib/rspeckled/plugins/{carrier_wave.rb → hooks/carrier_wave.rb} +4 -12
  49. data/lib/rspeckled/plugins/hooks/database_cleaner.rb +37 -0
  50. data/lib/rspeckled/plugins/hooks/devise.rb +11 -0
  51. data/lib/rspeckled/plugins/hooks/dox.rb +8 -0
  52. data/lib/rspeckled/plugins/hooks/elasticsearch.rb +37 -0
  53. data/lib/rspeckled/plugins/hooks/factory_bot.rb +21 -0
  54. data/lib/rspeckled/plugins/{foreign_keys.rb → hooks/foreign_keys.rb} +10 -6
  55. data/lib/rspeckled/plugins/hooks/garbage_collection.rb +21 -0
  56. data/lib/rspeckled/plugins/hooks/referehencible.rb +18 -0
  57. data/lib/rspeckled/plugins/{request.rb → hooks/request.rb} +4 -0
  58. data/lib/rspeckled/plugins/hooks/rspec_mocks.rb +20 -0
  59. data/lib/rspeckled/plugins/hooks/selenium_webdriver.rb +15 -0
  60. data/lib/rspeckled/plugins/hooks/sidekiq.rb +49 -0
  61. data/lib/rspeckled/plugins/{singleton.rb → hooks/singletons.rb} +6 -4
  62. data/lib/rspeckled/plugins/hooks/stripe.rb +30 -0
  63. data/lib/rspeckled/plugins/{timecop.rb → hooks/timecop.rb} +11 -9
  64. data/lib/rspeckled/plugins/hooks/vcr.rb +15 -0
  65. data/lib/rspeckled/plugins/hooks/warden.rb +13 -0
  66. data/lib/rspeckled/plugins/hooks/webmock.rb +21 -0
  67. data/lib/rspeckled/plugins.rb +92 -73
  68. data/lib/rspeckled/spec_helpers/rspeckled.rb +2 -2
  69. data/lib/rspeckled/support.rb +22 -12
  70. data/lib/rspeckled/tasks/documentation.rake +2 -2
  71. data/lib/rspeckled/version.rb +1 -1
  72. data/lib/rspeckled.rb +1 -1
  73. data.tar.gz.sig +4 -3
  74. metadata +65 -44
  75. metadata.gz.sig +0 -0
  76. data/lib/rspeckled/mock_authentications/omniauth.rb +0 -3
  77. data/lib/rspeckled/plugins/bullet.rb +0 -18
  78. data/lib/rspeckled/plugins/capybara.rb +0 -127
  79. data/lib/rspeckled/plugins/database_cleaner.rb +0 -35
  80. data/lib/rspeckled/plugins/devise.rb +0 -24
  81. data/lib/rspeckled/plugins/elasticsearch.rb +0 -27
  82. data/lib/rspeckled/plugins/email.rb +0 -25
  83. data/lib/rspeckled/plugins/factory_bot.rb +0 -23
  84. data/lib/rspeckled/plugins/mocks.rb +0 -16
  85. data/lib/rspeckled/plugins/omniauth.rb +0 -39
  86. data/lib/rspeckled/plugins/rails/strong_parameters.rb +0 -13
  87. data/lib/rspeckled/plugins/referehencible.rb +0 -14
  88. data/lib/rspeckled/plugins/shoulda.rb +0 -36
  89. data/lib/rspeckled/plugins/sidekiq.rb +0 -38
  90. data/lib/rspeckled/plugins/stripe.rb +0 -26
  91. data/lib/rspeckled/plugins/vcr.rb +0 -38
  92. data/lib/rspeckled/plugins/webmock.rb +0 -19
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id'
4
+
5
+ ::VCR.configure do |config|
6
+ config.register_request_matcher :uri_without_trailing_guid do |request, vcr_cassette_request|
7
+ ::Rspeckled::Vcr::Matchers::UriWithoutTrailingId.new(%r(/[a-f0-9\-]{32,36}/?\z)).call(request, vcr_cassette_request)
8
+ end
9
+
10
+ config.register_request_matcher :uri_without_trailing_id do |request, vcr_cassette_request|
11
+ ::Rspeckled::Vcr::Matchers::UriWithoutTrailingId.new(%r{/\d+/?\z}).call(request, vcr_cassette_request)
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each, :email => true) do
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
7
+ if ::ActionMailer::Base.delivery_method == :cache
8
+ mailer.clear_cache
9
+ else
10
+ deliveries.clear
11
+ end
12
+
13
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
14
+ end
15
+ end
@@ -3,7 +3,9 @@
3
3
  # rubocop:disable Layout/IndentHash
4
4
  RSpec.configure do |config|
5
5
  config.around(:each, :authentication => lambda { |v| !!v }) do |example|
6
- options = if example.metadata[:authentication].is_a?(Hash)
6
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
7
+
8
+ options = if example.metadata[:authentication].is_a?(::Hash)
7
9
  example.metadata[:authentication]
8
10
  else
9
11
  {
@@ -40,7 +42,7 @@ RSpec.configure do |config|
40
42
 
41
43
  instance = case options[:strategy]
42
44
  when :factory
43
- FactoryBot.create(class_name_underscored.to_sym, *options[:class_instance_traits], options[:class_instance_overrides])
45
+ ::FactoryBot.create(class_name_underscored.to_sym, *options[:class_instance_traits], options[:class_instance_overrides])
44
46
  when :instance
45
47
  options[:class].new(options[:class_instance_overrides])
46
48
  end
@@ -71,9 +73,9 @@ RSpec.configure do |config|
71
73
  'aid' => options[:token][:audience_id] || instance['account_id'] || instance['id'],
72
74
  'aud' => options[:token][:audience] || instance.class.name,
73
75
  'exp' => options[:token][:expired_at] || 1.day.from_now.utc.to_i,
74
- 'iat' => options[:token][:issued_at] || Time.now.utc.to_i,
76
+ 'iat' => options[:token][:issued_at] || ::Time.now.utc.to_i,
75
77
  'iss' => options[:token][:issuer] || 'rspeckled',
76
- 'jti' => options[:token][:token_id] || SecureRandom.uuid,
78
+ 'jti' => options[:token][:token_id] || ::SecureRandom.uuid,
77
79
  'nbf' => options[:token][:not_before] || 1.day.ago.utc.to_i,
78
80
  'rol' => options[:token][:roles] || 'standard',
79
81
  'sid' => options[:token][:subject_id],
@@ -91,10 +93,16 @@ RSpec.configure do |config|
91
93
  end
92
94
 
93
95
  instance.delete unless options[:strategy] == :instance
96
+
97
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
94
98
  end
95
99
 
96
100
  config.before(:each, :authentication => lambda { |v| !!v }) do |_example|
101
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
102
+
97
103
  request.env['X_JSON_WEB_TOKEN'] = @token_data
104
+
105
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
98
106
  end
99
107
  end
100
108
  # rubocop:enable Layout/IndentHash
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each) do
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
7
+ ::Bullet.start_request if ::Bullet.enable?
8
+
9
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
10
+ end
11
+
12
+ config.after(:each) do
13
+ config.rspeckled_logger.debug("After Each - Start - #{__FILE__}")
14
+
15
+ if ::Bullet.enable?
16
+ ::Bullet.perform_out_of_channel_notifications if ::Bullet.notification?
17
+ ::Bullet.end_request
18
+ end
19
+
20
+ config.rspeckled_logger.debug("After Each - End - #{__FILE__}")
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each, :js => true) do
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
7
+ page.driver.reset!
8
+
9
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
10
+ end
11
+
12
+ # Focus The Browser on Activation
13
+ config.around(:each, :js => true, :autofocus => true) do |example|
14
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
15
+
16
+ browser_name = example.metadata[:driver].to_s.capitalize
17
+
18
+ ::Thread.new do
19
+ sleep 1.5
20
+
21
+ `
22
+ osascript -e '
23
+ tell the application named "#{browser_name}"
24
+ activate
25
+
26
+ set theWindow to the first item of windows
27
+
28
+ if index of theWindow is not 1 then
29
+ set index to 1
30
+ set visible to false
31
+ set visible to true
32
+ end if
33
+ end tell
34
+ ' > /dev/null
35
+ `
36
+ end
37
+
38
+ example.run
39
+
40
+ sleep example.metadata[:delay]
41
+
42
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
43
+ end
44
+ end
@@ -1,19 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'carrierwave/test/matchers'
4
-
5
- RSpec.configure do |config|
6
- config.include CarrierWave::Test::Matchers, :file_attachment => true
7
- end
8
-
9
- CarrierWave.configure do |config|
10
- config.storage = :file
11
- config.root = File.expand_path('./tmp')
12
- config.enable_processing = false
13
- end
14
-
15
3
  RSpec.configure do |config|
16
4
  config.around(:each, :file_attachment => true) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
17
7
  previous_carrierwave_processing_mode = subject.class.enable_processing
18
8
  previous_carrierwave_storage_mode = subject.class.storage
19
9
 
@@ -24,5 +14,7 @@ RSpec.configure do |config|
24
14
 
25
15
  subject.class.storage = previous_carrierwave_storage_mode
26
16
  subject.class.enable_processing = previous_carrierwave_processing_mode
17
+
18
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
27
19
  end
28
20
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ autodetected = ::DatabaseCleaner::Base.new.__send__(:autodetect)
5
+ rescue ::DatabaseCleaner::NoORMDetected
6
+ autodetected = false
7
+ end
8
+
9
+ return unless autodetected
10
+
11
+ RSpec.configure do |config|
12
+ config.before(:suite) do
13
+ config.rspeckled_logger.debug("Before Suite - Start - #{__FILE__}")
14
+
15
+ ::DatabaseCleaner.clean_with(:truncation, :except => %w{ar_internal_metadata})
16
+
17
+ config.rspeckled_logger.debug("Before Suite - End - #{__FILE__}")
18
+ end
19
+
20
+ config.around(:each) do |example|
21
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
22
+
23
+ ::DatabaseCleaner.strategy = if example.metadata[:js] || %i{mongoid}.include?(autodetected)
24
+ [:truncation, :except => %w{ar_internal_metadata}]
25
+ else
26
+ :transaction
27
+ end
28
+
29
+ ::DatabaseCleaner.start
30
+
31
+ example.run
32
+
33
+ ::DatabaseCleaner.clean
34
+
35
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each, :type => :controller) do |_example|
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
7
+ @request.env['devise.mapping'] = ::Devise.mappings[:user]
8
+
9
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.after(:each, :dox) do |example|
5
+ example.metadata[:request] = request
6
+ example.metadata[:response] = response
7
+ end
8
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:all, :elasticsearch => lambda { |v| !!v }) do
5
+ config.rspeckled_logger.debug("Before All - Start - #{__FILE__}")
6
+
7
+ ::Elasticsearch::Extensions::Test::Cluster.start(:port => 9200) unless ::Elasticsearch::Extensions::Test::Cluster.running?
8
+
9
+ config.rspeckled_logger.debug("Before All - End - #{__FILE__}")
10
+ end
11
+
12
+ config.around(:each, :elasticsearch => lambda { |v| !!v }) do |example|
13
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
14
+
15
+ model = case example.metadata[:elasticsearch]
16
+ when ::String
17
+ example.metadata[:elasticsearch].constantize
18
+ end
19
+
20
+ model.__elasticsearch__.client.indices.delete :index => '_all'
21
+ model.__elasticsearch__.create_index! :index => model.index_name
22
+
23
+ example.run
24
+
25
+ model.__elasticsearch__.client.indices.delete :index => '_all'
26
+
27
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
28
+ end
29
+
30
+ config.after(:all, :elasticsearch => lambda { |v| !!v }) do
31
+ config.rspeckled_logger.debug("After All - Start - #{__FILE__}")
32
+
33
+ ::Elasticsearch::Extensions::Test::Cluster.stop(:port => 9200) if ::Elasticsearch::Extensions::Test::Cluster.running?
34
+
35
+ config.rspeckled_logger.debug("After All - End - #{__FILE__}")
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:suite) do
5
+ config.rspeckled_logger.debug("Before Suite - Start - #{__FILE__}")
6
+
7
+ ::FactoryBot.reload
8
+
9
+ load 'rspeckled/plugins/extensions/factory_bot/sequences.rb'
10
+
11
+ config.rspeckled_logger.debug("Before Suite - End - #{__FILE__}")
12
+ end
13
+
14
+ config.before(:each) do
15
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
16
+
17
+ ::FactoryBot.rewind_sequences if ::FactoryBot.respond_to?(:rewind_sequences)
18
+
19
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
20
+ end
21
+ end
@@ -2,15 +2,17 @@
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.around(:each, :disable_foreign_keys => lambda { |v| !!v }) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
5
7
  options = example.metadata[:disable_foreign_keys]
6
8
  options = case options
7
- when Array
9
+ when ::Array
8
10
  { :tables => options.map(&:to_s) }
9
- when String, Symbol
11
+ when ::String, ::Symbol
10
12
  { :tables => [options.to_s] }
11
- when FalseClass
13
+ when ::FalseClass
12
14
  { :tables => [] }
13
- when TrueClass
15
+ when ::TrueClass
14
16
  { :tables => :all }
15
17
  end
16
18
 
@@ -48,17 +50,19 @@ RSpec.configure do |config|
48
50
  foreign_key_names_sql += ')'
49
51
  end
50
52
 
51
- foreign_keys_to_disable = ActiveRecord::Base.connection.select_values(foreign_key_names_sql).join(',')
53
+ foreign_keys_to_disable = ::ActiveRecord::Base.connection.select_values(foreign_key_names_sql).join(',')
52
54
 
53
55
  if foreign_keys_to_disable.blank?
54
56
  puts 'You asked to disable foreign keys but there were no foreign keys found to disable'
55
57
  else
56
- ActiveRecord::Base.connection.execute('SET CONSTRAINTS %<key_pattern>s DEFERRED' % { :key_pattern => foreign_keys_to_disable }) unless foreign_keys_to_disable.empty?
58
+ ::ActiveRecord::Base.connection.execute('SET CONSTRAINTS %<key_pattern>s DEFERRED' % { :key_pattern => foreign_keys_to_disable }) unless foreign_keys_to_disable.empty?
57
59
  end
58
60
 
59
61
  example.run
60
62
 
61
63
  # Remember we don't have to re-enable foreign keys because database cleaner
62
64
  # will do that for us when it rolls back the transaction
65
+
66
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
63
67
  end
64
68
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspeckled/plugins/extensions/ruby/deferred_garbage_collection'
4
+
5
+ RSpec.configure do |config|
6
+ config.before(:all) do
7
+ config.rspeckled_logger.debug("Before All - Start - #{__FILE__}")
8
+
9
+ ::Rspeckled::Ruby::DeferredGarbageCollection.start
10
+
11
+ config.rspeckled_logger.debug("Before All - End - #{__FILE__}")
12
+ end
13
+
14
+ config.after(:all) do
15
+ config.rspeckled_logger.debug("After All - Start - #{__FILE__}")
16
+
17
+ ::Rspeckled::Ruby::DeferredGarbageCollection.reconsider
18
+
19
+ config.rspeckled_logger.debug("After All - End - #{__FILE__}")
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each, :mock_refs => lambda { |v| !!v }) do |example|
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
7
+ reference = if example.metadata[:mock_refs].is_a? ::TrueClass
8
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
9
+ else
10
+ example.metadata[:mock_refs]
11
+ end
12
+
13
+ allow(::Referehencible).to receive(:reference_number)
14
+ .and_return(reference)
15
+
16
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
17
+ end
18
+ end
@@ -2,6 +2,10 @@
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.before(:each, :type => :controller) do
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
5
7
  request.headers['accept'] = 'application/json'
8
+
9
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
6
10
  end
7
11
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.around(:each, :verify => false) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
7
+ verify_partial = ::RSpec::Mocks.configuration.instance_variable_get(:@verify_partial_doubles)
8
+ verify_constant = ::RSpec::Mocks.configuration.instance_variable_get(:@verify_doubled_constant_names)
9
+
10
+ ::RSpec::Mocks.configuration.verify_partial_doubles = example.metadata[:verify]
11
+ ::RSpec::Mocks.configuration.verify_doubled_constant_names = example.metadata[:verify]
12
+
13
+ example.run
14
+
15
+ ::RSpec::Mocks.configuration.verify_partial_doubles = verify_partial
16
+ ::RSpec::Mocks.configuration.verify_doubled_constant_names = verify_constant
17
+
18
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.around(:each, :js => true, :debug => true) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
7
+ ::Selenium::WebDriver.logger.level = :debug
8
+
9
+ example.run
10
+
11
+ ::Selenium::WebDriver.logger.level = :warn
12
+
13
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
14
+ end
15
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each, :queue => lambda { |v| !!v }) do |example|
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
7
+ # Clears out the jobs for tests using the fake testing
8
+ ::Sidekiq::Worker.clear_all
9
+ ::Sidekiq::Queues.clear_all
10
+
11
+ # Sidekiq Enterprise Doesn't Like Having the Cache Cleared Between Runs
12
+ # rubocop:disable Metrics/BlockNesting
13
+ unless defined?(::Sidekiq::Enterprise)
14
+ ::Sidekiq.redis do |client|
15
+ connection = client.__send__(:instance_variable_get, :@redis) ||
16
+ client.__send__(:instance_variable_get, :@client)
17
+
18
+ connection.call([:flushdb])
19
+ end
20
+
21
+ ::Sidekiq.redis do |client|
22
+ client.keys.each do |key|
23
+ client.del(key)
24
+ end
25
+ end
26
+ end
27
+ # rubocop:enable Metrics/BlockNesting
28
+
29
+ if [:stub, :fake].include?(example.metadata[:queue])
30
+ ::Sidekiq::Testing.fake!
31
+ elsif [:inline, :immediately_execute].include?(example.metadata[:queue])
32
+ ::Sidekiq::Testing.inline!
33
+ elsif [:system, :feature].include?(example.metadata[:type])
34
+ ::Sidekiq::Testing.inline!
35
+ else
36
+ ::Sidekiq::Testing.fake!
37
+ end
38
+
39
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
40
+ end
41
+
42
+ config.after(:each, :queue => lambda { |v| !!v }) do |_example|
43
+ config.rspeckled_logger.debug("After Each - Start - #{__FILE__}")
44
+
45
+ ::Sidekiq::Testing.fake!
46
+
47
+ config.rspeckled_logger.debug("After Each - End - #{__FILE__}")
48
+ end
49
+ end
@@ -2,20 +2,22 @@
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.around(:each, :singletons => lambda { |v| !!v }) do |example|
5
- require 'singleton'
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
6
 
7
7
  options = example.metadata[:singletons]
8
- options = options.is_a?(TrueClass) ? described_class : options
8
+ options = options.is_a?(::TrueClass) ? described_class : options
9
9
  singletons_to_reset = Array(options)
10
10
 
11
11
  singletons_to_reset.each do |singleton|
12
- Singleton.__init__(singleton)
12
+ ::Singleton.__init__(singleton)
13
13
  end
14
14
 
15
15
  example.run
16
16
 
17
17
  singletons_to_reset.each do |singleton|
18
- Singleton.__init__(singleton)
18
+ ::Singleton.__init__(singleton)
19
19
  end
20
+
21
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
20
22
  end
21
23
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each, :stripe => true) do
5
+ config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
+
7
+ if defined?(::VCR)
8
+ vcr_turned_on = ::VCR.turned_on?
9
+ ::VCR.turn_off!
10
+ end
11
+
12
+ if defined?(::WebMock)
13
+ webmock_net_connect = ::WebMock.net_connect_allowed?
14
+ ::WebMock.allow_net_connect!
15
+ end
16
+
17
+ begin
18
+ ::Stripe::Plan.all(:count => 100).each do |plan|
19
+ plan.delete if plan.id.match(/test/i) || plan.name.match(/test/i)
20
+ end
21
+
22
+ ::Stripe::Customer.all(:count => 100).each(&:delete)
23
+ ensure
24
+ ::VCR.turn_on! if defined?(::VCR) && vcr_turned_on
25
+ ::WebMock.allow_net_connect! if defined?(::WebMock) && webmock_net_connect
26
+ end
27
+
28
+ config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
29
+ end
30
+ end
@@ -1,30 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'timecop'
4
-
5
3
  RSpec.configure do |config|
6
4
  config.around(:each, :time_mock => lambda { |v| !!v }) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
7
7
  options = example.metadata[:time_mock]
8
8
  options = case options
9
- when Time
9
+ when ::Time
10
10
  { :time => options }
11
- when FalseClass
11
+ when ::FalseClass
12
12
  false
13
- when TrueClass
13
+ when ::TrueClass
14
14
  {}
15
15
  end
16
16
 
17
17
  if options
18
18
  mock_type = options.fetch(:type, :freeze)
19
- time = options.fetch(:time, Time.utc(2012, 7, 26, 18, 0, 0))
19
+ time = options.fetch(:time, ::Time.utc(2012, 7, 26, 18, 0, 0))
20
20
 
21
- Timecop.public_send(mock_type, time)
21
+ ::Timecop.public_send(mock_type, time)
22
22
  else
23
- Timecop.return
23
+ ::Timecop.return
24
24
  end
25
25
 
26
26
  example.run
27
27
 
28
- Timecop.return
28
+ ::Timecop.return
29
+
30
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
29
31
  end
30
32
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.around(:each, :vcr => lambda { |v| !!v }) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
7
+ ::VCR.configuration.allow_http_connections_when_no_cassette = false
8
+
9
+ example.run
10
+
11
+ ::VCR.configuration.allow_http_connections_when_no_cassette = true
12
+
13
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ [:system, :feature, :request].each do |type|
5
+ config.before(:all, :type => type) do |_example|
6
+ config.rspeckled_logger.debug("Before All - Start - #{__FILE__}")
7
+
8
+ ::Warden.test_mode!
9
+
10
+ config.rspeckled_logger.debug("Before All - End - #{__FILE__}")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.around(:each, :webmock => lambda { |v| !!v }) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
7
+ options = example.metadata[:webmock]
8
+ options = case options
9
+ when ::TrueClass
10
+ { :allow_localhost => true }
11
+ end
12
+
13
+ ::WebMock.disable_net_connect!(options)
14
+
15
+ example.run
16
+
17
+ ::WebMock.allow_net_connect!
18
+
19
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
20
+ end
21
+ end