rspeckled 1.4.0 → 2.0.0

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: b69c97782152e63b5901760748e17d6c77ef9d4d65c1c2d0f6ba7e14a081d0c3
4
- data.tar.gz: ef011710d66446c9011293e1b749c1360c38923bf49df6acd9ff11f33bc71611
3
+ metadata.gz: d288b7a4cfcb9c31f083ccdcda53a5044a67913683ec417b329b60558f830279
4
+ data.tar.gz: 951b9ca7a32c6e41640095f408f26690573ff1accacb2158c22fa92519d58ffc
5
5
  SHA512:
6
- metadata.gz: d988561d065da0754efcc0f89c5c80990864b18660c96326b1f26a9eb67969cfbd503f100b168c7a173ada02e4e1d350f5668c51721586b69482cf7211c54b63
7
- data.tar.gz: 851ea16b0d5b2ac9c7275f165b8b7c00ba54ba941987dec20afdcd99ceace828869d6b800cd90bdfae8b359647c42117e425b6b888535fbfeb4d4a69c9ff889b
6
+ metadata.gz: 311e01fa6a1cf8ec430f4c2c12f410819ed80609439112890fc6744b9425301f9a92a7cdfb2d9d6c1f798ec716ac1bc76c4e148de77acd2d122f885b217bf043
7
+ data.tar.gz: 0dc8b984bc18d767493020e8b04e7a5cda23972dbd6abb1c2e0e54c67efff6dd7c3a8a74b79dd53dea2f4309639f8a63a8bacef5e759f0e96646feeb7b514d2b
@@ -1 +1,3 @@
1
- ������Z��j�׿�s�|D`�/�a(��dYG�.����Gw틸Ė�V=�Ⰻ�:��aլ�D�׶���՘2���BW>��GJB1]�('1fr���n\j�YG�9���퀡�5�V�+�z ϙ�?��_x�6�������'F��Vg��%xѾ�M2���'�rW>��Ɯ����dJ�c���7�ks$�H+�pI��)�J�����'�b��`��O�ݘ1�S� 6z�~h���ڣ�7� h����a j?7ӭ���#\��t�G�Ѓ}��{�`���C-*QՇsϾ�1��lz_P����dU8��i�^�%^ӈ�@�n�n)���ps`�,�]G��H�Rj�xܣZ�t�1#B�G�g��^��4�0��jN�
1
+ ��v��{��foQhI���6���7u�V�IgFh�:�F�|�y��t(
2
+ �u�Ŧf��I~�W�V�T� +j�_7�Hk<��b�k$30����d����o����3��m���t����]
3
+ ��X�T�gv��g��3�1u"vx=i��P��5mā��wٗ�֘�]��B�8�A����^P���Ԕͽ\ ��I_%�؅ٞa{�m$�m|�{��S)O���oZ�ۢ�?
data.tar.gz.sig CHANGED
Binary file
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2016 The Kompanee, Ltd
1
+ Copyright (c) 2010-2019 The Kompanee, Ltd
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -79,6 +79,7 @@ require 'rspeckled/plugins/hooks/dox'
79
79
  require 'rspeckled/plugins/hooks/elasticsearch'
80
80
  require 'rspeckled/plugins/hooks/factory_bot' if defined?(::FactoryBot)
81
81
  require 'rspeckled/plugins/hooks/foreign_keys'
82
+ require 'rspeckled/plugins/hooks/rails' if defined?(::Rails)
82
83
  require 'rspeckled/plugins/hooks/redis' if defined?(::Redis)
83
84
  require 'rspeckled/plugins/hooks/referehencible'
84
85
  require 'rspeckled/plugins/hooks/rspec_mocks'
@@ -23,7 +23,6 @@ RSpec.configure do |config|
23
23
  .name[/(?:.*::)?(\w+)\z/, 1]
24
24
  .gsub(/([a-z])([A-Z])/, '\1_\2')
25
25
  .downcase
26
-
27
26
  defaults = {
28
27
  :type => :json_web_token,
29
28
  :authentication_method => :"authenticate_#{class_name_underscored}!",
@@ -38,14 +37,12 @@ RSpec.configure do |config|
38
37
  }
39
38
 
40
39
  options = defaults.deep_merge(options)
41
-
42
40
  instance = case options[:strategy]
43
41
  when :factory
44
42
  ::FactoryBot.create(class_name_underscored.to_sym, *options[:class_instance_traits], options[:class_instance_overrides])
45
43
  when :instance
46
44
  options[:class].new(options[:class_instance_overrides])
47
45
  end
48
-
49
46
  authentication_result = options[:successful?] ? instance : nil
50
47
 
51
48
  case options[:type]
@@ -1,13 +1,5 @@
1
1
  # frozen_string_literal: true
2
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
3
  RSpec.configure do |config|
12
4
  config.before(:suite) do
13
5
  config.rspeckled_logger.debug("Before Suite - Start - #{__FILE__}")
@@ -20,7 +12,7 @@ RSpec.configure do |config|
20
12
  config.around(:each) do |example|
21
13
  config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
22
14
 
23
- ::DatabaseCleaner.strategy = if example.metadata[:js] || %i{mongoid}.include?(autodetected)
15
+ ::DatabaseCleaner.strategy = if example.metadata[:js]
24
16
  [:truncation, :except => %w{ar_internal_metadata}]
25
17
  else
26
18
  :transaction
@@ -16,50 +16,48 @@ RSpec.configure do |config|
16
16
  { :tables => :all }
17
17
  end
18
18
 
19
- foreign_key_names_sql = <<~HEREDOC
19
+ foreign_key_trigger_disable_statements_sql = <<~HEREDOC
20
20
  SELECT
21
- "constraint_column_usage"."constraint_name",
22
- "pg_class"."relname" AS "local_table_name",
23
- "constraint_column_usage"."table_name" AS "foreign_table_name",
24
- "constraint_column_usage"."column_name" AS "foreign_column_name"
21
+ 'ALTER TABLE "' || "pg_namespace"."nspname" || '"."' || "pg_class"."relname" || '" DISABLE TRIGGER "' || "pg_trigger"."tgname" || '";' AS "statement"
25
22
  FROM
26
- "information_schema"."constraint_column_usage"
27
- INNER JOIN
28
- "pg_constraint"
29
- ON
30
- "constraint_column_usage"."constraint_name" = "pg_constraint"."conname"
23
+ "pg_trigger"
31
24
  INNER JOIN
32
25
  "pg_class"
33
- ON
34
- "pg_class"."oid" = "pg_constraint"."conrelid"
26
+ ON
27
+ "pg_trigger"."tgrelid" = "pg_class"."oid"
28
+ INNER JOIN
29
+ "pg_namespace"
30
+ ON
31
+ "pg_class"."relnamespace" = "pg_namespace"."oid"
32
+ INNER JOIN
33
+ "pg_proc"
34
+ ON
35
+ "pg_trigger"."tgfoid" = "pg_proc"."oid"
35
36
  WHERE
36
- "pg_constraint"."contype" = 'f'
37
- AND
38
- "pg_constraint"."condeferrable" = 't'
37
+ regexp_match("pg_proc"."proname", '.*_FKey_.*') IS NOT NULL
39
38
  HEREDOC
40
39
 
41
40
  unless options[:tables] == :all
42
- foreign_key_names_sql += " AND\n"
41
+ foreign_key_trigger_disable_statements_sql += " AND\n "
43
42
 
44
43
  table_constraint_sql = options[:tables]
45
44
  .map { |table_name| "'#{table_name}'" }
46
45
  .join(', ')
47
46
 
48
- foreign_key_names_sql += %Q{ "pg_class"."relname" IN (#{table_constraint_sql})}
47
+ foreign_key_trigger_disable_statements_sql += %Q{ "pg_class"."relname" IN (#{table_constraint_sql})}
49
48
  end
50
49
 
51
- foreign_keys_to_disable = ::ActiveRecord::Base.connection.select_values(foreign_key_names_sql).join(',')
50
+ foreign_key_trigger_disable_statements = ::ActiveRecord::Base.connection.select_values(foreign_key_trigger_disable_statements_sql).join(' ')
52
51
 
53
- if foreign_keys_to_disable.blank?
54
- puts 'You asked to disable foreign keys but there were no foreign keys found to disable'
55
- else
56
- ::ActiveRecord::Base.connection.execute('SET CONSTRAINTS %<key_pattern>s DEFERRED' % { :key_pattern => foreign_keys_to_disable })
57
- end
58
-
59
- example.run
52
+ ::ActiveRecord::Base.transaction do
53
+ if foreign_key_trigger_disable_statements.blank?
54
+ puts 'You asked to disable foreign keys but there were no foreign keys found to disable'
55
+ else
56
+ ::ActiveRecord::Base.connection.execute(foreign_key_trigger_disable_statements)
57
+ end
60
58
 
61
- # Remember we don't have to re-enable foreign keys because database cleaner
62
- # will do that for us when it rolls back the transaction
59
+ example.run
60
+ end
63
61
 
64
62
  config.rspeckled_logger.debug("Around Each - End - #{__FILE__}")
65
63
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.around(:each, :debug => true) do |example|
5
+ config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
+
7
+ debug_rails_logger = ::ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout))
8
+ debug_rails_logger.level = :debug
9
+
10
+ current_rails_configuration_logger = ::Rails.configuration.logger
11
+ current_rails_configuration_logger_level = ::Rails.configuration.log_level
12
+
13
+ current_action_cable_logger = ::ActionCable.server.config.logger if defined?(::ActionCable)
14
+ current_action_controller_logger = ::ActionController::Base.logger if defined?(::ActionController)
15
+ current_action_mailer_logger = ::ActionMailer::Base.logger if defined?(::ActionMailer)
16
+ current_action_view_logger = ::ActionView::Base.logger if defined?(::ActionView)
17
+ current_active_job_logger = ::ActiveJob::Base.logger if defined?(::ActiveJob)
18
+ current_active_record_logger = ::ActiveRecord::Base.logger if defined?(::ActiveRecord)
19
+ current_active_storage_logger = ::ActiveStorage.logger if defined?(::ActiveStorage)
20
+ current_rails_logger = ::Rails.logger if defined?(::Rails)
21
+
22
+ ::Rails.configuration.log_level = debug_rails_logger.level
23
+ ::Rails.configuration.logger = debug_rails_logger
24
+
25
+ ::ActionCable.server.config.logger = debug_rails_logger if defined?(::ActionCable)
26
+ ::ActionController::Base.logger = debug_rails_logger if defined?(::ActionController)
27
+ ::ActionMailer::Base.logger = debug_rails_logger if defined?(::ActionMailer)
28
+ ::ActionView::Base.logger = debug_rails_logger if defined?(::ActionView)
29
+ ::ActiveJob::Base.logger = debug_rails_logger if defined?(::ActiveJob)
30
+ ::ActiveRecord::Base.logger = debug_rails_logger if defined?(::ActiveRecord)
31
+ ::ActiveStorage.logger = debug_rails_logger if defined?(::ActiveStorage)
32
+ ::Rails.logger = debug_rails_logger if defined?(::Rails)
33
+
34
+ example.run
35
+
36
+ ::Rails.configuration.logger = current_rails_configuration_logger
37
+ ::Rails.configuration.log_level = current_rails_configuration_logger_level
38
+
39
+ ::ActionCable.server.config.logger = current_action_cable_logger if defined?(::ActionCable)
40
+ ::ActionController::Base.logger = current_action_controller_logger if defined?(::ActionController)
41
+ ::ActionMailer::Base.logger = current_action_mailer_logger if defined?(::ActionMailer)
42
+ ::ActionView::Base.logger = current_action_view_logger if defined?(::ActionView)
43
+ ::ActiveJob::Base.logger = current_active_job_logger if defined?(::ActiveJob)
44
+ ::ActiveRecord::Base.logger = current_active_record_logger if defined?(::ActiveRecord)
45
+ ::ActiveStorage.logger = current_active_storage_logger if defined?(::ActiveStorage)
46
+ ::Rails.logger = current_rails_logger if defined?(::Rails)
47
+
48
+ config.rspeckled_logger.debug("Around Each - End - #{__FILE__}") if defined?(config)
49
+ end
50
+ end
@@ -11,16 +11,13 @@ rescue Errno::EEXIST
11
11
  end
12
12
 
13
13
  log_file = File.join(Dir.pwd, 'log', 'activerecord.log')
14
-
15
14
  rails_database_yaml_file_path = File.join(Dir.pwd, 'config', 'database.yml')
16
15
  rails_engine_database_yaml_file_path = File.join(Dir.pwd, 'spec', 'dummy', 'config', 'database.yml')
17
-
18
16
  database_yaml_file_path = if File.exist? rails_engine_database_yaml_file_path
19
17
  rails_engine_database_yaml_file_path
20
18
  else
21
19
  rails_database_yaml_file_path
22
20
  end
23
-
24
21
  connection_info = YAML.load_file(database_yaml_file_path)['test']
25
22
 
26
23
  ActiveRecord::Base.logger = Logger.new(log_file)
@@ -8,6 +8,7 @@ require 'logger'
8
8
  #
9
9
  abort('DATABASE_URL environment variable is set') if ENV['DATABASE_URL']
10
10
 
11
+ # rubocop:disable Layout/MultilineMethodArgumentLineBreaks
11
12
  RSpec.configure do |config|
12
13
  ##############################################################################
13
14
  # RSPECKLED CONFIGURATION
@@ -149,3 +150,4 @@ RSpec.configure do |config|
149
150
  end
150
151
  end
151
152
  end
153
+ # rubocop:enable Layout/MultilineMethodArgumentLineBreaks
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rspeckled
4
- VERSION = '1.4.0'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspeckled
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -36,7 +36,7 @@ cert_chain:
36
36
  6ZCHhOtYwlYSqOmGfPSsB7i1W4YABE86ZQaPEwhuPkkdvqSFUSryDLpcB8S/2fp4
37
37
  bHTbBi7YQCFxKay21QDo3HPPRBq4YQ+Xy9w=
38
38
  -----END CERTIFICATE-----
39
- date: 2019-08-16 00:00:00.000000000 Z
39
+ date: 2020-03-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
@@ -165,6 +165,7 @@ files:
165
165
  - lib/rspeckled/plugins/hooks/factory_bot.rb
166
166
  - lib/rspeckled/plugins/hooks/foreign_keys.rb
167
167
  - lib/rspeckled/plugins/hooks/garbage_collection.rb
168
+ - lib/rspeckled/plugins/hooks/rails.rb
168
169
  - lib/rspeckled/plugins/hooks/redis.rb
169
170
  - lib/rspeckled/plugins/hooks/referehencible.rb
170
171
  - lib/rspeckled/plugins/hooks/request.rb
@@ -215,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  - !ruby/object:Gem::Version
216
217
  version: '0'
217
218
  requirements: []
218
- rubygems_version: 3.0.4
219
+ rubygems_version: 3.0.3
219
220
  signing_key:
220
221
  specification_version: 4
221
222
  summary: Stop Copying and Pasting Your RSpec Configuration
metadata.gz.sig CHANGED
Binary file