rspeckled 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rspeckled/helpers/factories.rb +8 -2
  4. data/lib/rspeckled/helpers/filepaths.rb +30 -22
  5. data/lib/rspeckled/helpers/null_objects.rb +8 -2
  6. data/lib/rspeckled/helpers/patterns.rb +75 -41
  7. data/lib/rspeckled/helpers/responses.rb +8 -2
  8. data/lib/rspeckled/patches.rb +8 -6
  9. data/lib/rspeckled/plugins/configuration/capybara_screenshot.rb +5 -4
  10. data/lib/rspeckled/plugins/configuration/carrier_wave.rb +1 -1
  11. data/lib/rspeckled/plugins/configuration/devise.rb +4 -4
  12. data/lib/rspeckled/plugins/configuration/dox.rb +4 -4
  13. data/lib/rspeckled/plugins/configuration/email_spec.rb +3 -3
  14. data/lib/rspeckled/plugins/configuration/factory_bot.rb +2 -2
  15. data/lib/rspeckled/plugins/configuration/shoulda.rb +2 -2
  16. data/lib/rspeckled/plugins/configuration/vcr.rb +6 -4
  17. data/lib/rspeckled/plugins/configuration/warden.rb +3 -2
  18. data/lib/rspeckled/plugins/extensions/awesome_print.rb +20 -7
  19. data/lib/rspeckled/plugins/extensions/capybara.rb +16 -6
  20. data/lib/rspeckled/plugins/extensions/faraday/middleware/curl_logger.rb +10 -3
  21. data/lib/rspeckled/plugins/extensions/faraday.rb +2 -1
  22. data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/ebay.rb +1 -1
  23. data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/facebook.rb +1 -1
  24. data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/twitter.rb +1 -1
  25. data/lib/rspeckled/plugins/extensions/omniauth.rb +6 -3
  26. data/lib/rspeckled/plugins/extensions/ruby/deferred_garbage_collection.rb +3 -1
  27. data/lib/rspeckled/plugins/extensions/selenium/drivers/chrome.rb +6 -6
  28. data/lib/rspeckled/plugins/extensions/selenium/drivers/firefox.rb +14 -3
  29. data/lib/rspeckled/plugins/extensions/strong_parameters.rb +2 -1
  30. data/lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb +3 -1
  31. data/lib/rspeckled/plugins/extensions/vcr.rb +8 -4
  32. data/lib/rspeckled/plugins/hooks/action_mailer.rb +2 -2
  33. data/lib/rspeckled/plugins/hooks/authentication.rb +87 -61
  34. data/lib/rspeckled/plugins/hooks/bullet.rb +3 -1
  35. data/lib/rspeckled/plugins/hooks/capybara.rb +2 -2
  36. data/lib/rspeckled/plugins/hooks/carrier_wave.rb +2 -2
  37. data/lib/rspeckled/plugins/hooks/database_cleaner.rb +2 -2
  38. data/lib/rspeckled/plugins/hooks/devise.rb +1 -1
  39. data/lib/rspeckled/plugins/hooks/dox.rb +1 -1
  40. data/lib/rspeckled/plugins/hooks/elasticsearch.rb +13 -9
  41. data/lib/rspeckled/plugins/hooks/factory_bot.rb +1 -1
  42. data/lib/rspeckled/plugins/hooks/foreign_keys.rb +21 -13
  43. data/lib/rspeckled/plugins/hooks/garbage_collection.rb +1 -1
  44. data/lib/rspeckled/plugins/hooks/rails.rb +5 -3
  45. data/lib/rspeckled/plugins/hooks/redis.rb +3 -3
  46. data/lib/rspeckled/plugins/hooks/referehencible.rb +2 -2
  47. data/lib/rspeckled/plugins/hooks/request.rb +1 -1
  48. data/lib/rspeckled/plugins/hooks/rspec_mocks.rb +8 -4
  49. data/lib/rspeckled/plugins/hooks/selenium_webdriver.rb +2 -2
  50. data/lib/rspeckled/plugins/hooks/sidekiq.rb +14 -12
  51. data/lib/rspeckled/plugins/hooks/singletons.rb +2 -2
  52. data/lib/rspeckled/plugins/hooks/stripe.rb +5 -3
  53. data/lib/rspeckled/plugins/hooks/timecop.rb +3 -3
  54. data/lib/rspeckled/plugins/hooks/vcr.rb +2 -2
  55. data/lib/rspeckled/plugins/hooks/warden.rb +3 -3
  56. data/lib/rspeckled/plugins/hooks/webmock.rb +3 -3
  57. data/lib/rspeckled/plugins.rb +22 -19
  58. data/lib/rspeckled/reporting/example.rb +10 -8
  59. data/lib/rspeckled/reporting/outputs/csv.rb +2 -0
  60. data/lib/rspeckled/reporting/outputs/text.rb +17 -15
  61. data/lib/rspeckled/reporting/runner.rb +26 -24
  62. data/lib/rspeckled/spec_helpers/active_record_connection_setup.rb +13 -9
  63. data/lib/rspeckled/spec_helpers/rails_engine.rb +2 -2
  64. data/lib/rspeckled/spec_helpers/rspeckled.rb +17 -1
  65. data/lib/rspeckled/support.rb +26 -24
  66. data/lib/rspeckled/tasks/documentation.rake +28 -8
  67. data/lib/rspeckled/version.rb +3 -1
  68. data.tar.gz.sig +0 -0
  69. metadata +29 -28
  70. metadata.gz.sig +0 -0
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- SIDEKIQ_BATCH_CALLBACK_PATTERN = /\Ab\-[a-zA-Z0-9_\-]{14}\z/.freeze
3
+ SIDEKIQ_BATCH_CALLBACK_PATTERN = /\Ab-[a-zA-Z0-9_\-]{14}\z/.freeze
4
4
  SIDEKIQ_BATCH_DATA_PATTERN = /\Abatches\z/.freeze
5
- SIDEKIQ_BATCH_JOBS_PATTERN = /\Ab\-[a-zA-Z0-9_\-]{14}-jids\z/.freeze
5
+ SIDEKIQ_BATCH_JOBS_PATTERN = /\Ab-[a-zA-Z0-9_\-]{14}-jids\z/.freeze
6
6
  SIDEKIQ_LIMITER_DATA_PATTERN = /\Almtr-c-/.freeze
7
7
  SIDEKIQ_LIMITER_JOBS_PATTERN = /\Almtr-cfree-/.freeze
8
8
 
9
- RSpec.configure do |config|
10
- config.before(:each, :queue => lambda { |v| !!v }) do |example|
9
+ # rubocop:disable Metrics/BlockNesting
10
+ ::RSpec.configure do |config| # rubocop:disable Metrics/BlockLength
11
+ config.before(:each, queue: ->(v) { !v.nil? }) do |example| # rubocop:disable Metrics/BlockLength
11
12
  config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
12
13
 
13
14
  # Changes Any Limiters Created to Be Unlimited
@@ -24,9 +25,8 @@ RSpec.configure do |config|
24
25
  ::Sidekiq::Worker.clear_all
25
26
  ::Sidekiq::Queues.clear_all
26
27
 
27
- # rubocop:disable Metrics/BlockNesting
28
28
  ::Sidekiq.redis do |client|
29
- client.keys.each do |key|
29
+ client.each_key do |key|
30
30
  next unless key.match?(SIDEKIQ_BATCH_CALLBACK_PATTERN) ||
31
31
  key.match?(SIDEKIQ_BATCH_DATA_PATTERN) ||
32
32
  key.match?(SIDEKIQ_BATCH_JOBS_PATTERN) ||
@@ -36,22 +36,23 @@ RSpec.configure do |config|
36
36
  client.del(key)
37
37
  end
38
38
  end
39
- # rubocop:enable Metrics/BlockNesting
40
39
 
41
- if [:stub, :fake].include?(example.metadata[:queue])
40
+ # rubocop:disable Lint/DuplicateBranch
41
+ if %i{stub fake}.include?(example.metadata[:queue])
42
42
  ::Sidekiq::Testing.fake!
43
- elsif [:inline, :immediately_execute].include?(example.metadata[:queue])
44
- ::Sidekiq::Testing.inline!
45
- elsif [:system, :feature].include?(example.metadata[:type])
43
+ elsif %i{inline immediately_execute}.include?(example.metadata[:queue]) ||
44
+ %i{system feature}.include?(example.metadata[:type])
45
+
46
46
  ::Sidekiq::Testing.inline!
47
47
  else
48
48
  ::Sidekiq::Testing.fake!
49
49
  end
50
+ # rubocop:enable Lint/DuplicateBranch
50
51
 
51
52
  config.rspeckled_logger.debug("Before Each - End - #{__FILE__}")
52
53
  end
53
54
 
54
- config.after(:each, :queue => lambda { |v| !!v }) do |_example|
55
+ config.after(:each, queue: ->(v) { !v.nil? }) do |_example|
55
56
  config.rspeckled_logger.debug("After Each - Start - #{__FILE__}")
56
57
 
57
58
  ::Sidekiq::Testing.fake!
@@ -59,3 +60,4 @@ RSpec.configure do |config|
59
60
  config.rspeckled_logger.debug("After Each - End - #{__FILE__}")
60
61
  end
61
62
  end
63
+ # rubocop:enable Metrics/BlockNesting
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.configure do |config|
4
- config.around(:each, :singletons => lambda { |v| !!v }) do |example|
4
+ config.around(:each, singletons: ->(v) { !v.nil? }) do |example|
5
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 = described_class if options.is_a?(::TrueClass)
9
9
  singletons_to_reset = Array(options)
10
10
 
11
11
  singletons_to_reset.each do |singleton|
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/BlockNesting
3
4
  RSpec.configure do |config|
4
- config.around(:each, :stripe => true) do |example|
5
+ config.around(:each, stripe: true) do |example|
5
6
  config.rspeckled_logger.debug("Before Each - Start - #{__FILE__}")
6
7
 
7
8
  if defined?(::VCR)
@@ -17,11 +18,11 @@ RSpec.configure do |config|
17
18
  ::StripeMock.start if defined?(::StripeMock)
18
19
 
19
20
  begin
20
- ::Stripe::Plan.all(:count => 100).each do |plan|
21
+ ::Stripe::Plan.all(count: 100).each do |plan|
21
22
  plan.delete if plan.id.match(/test/i) || plan.name.match(/test/i)
22
23
  end
23
24
 
24
- ::Stripe::Customer.all(:count => 100).each(&:delete)
25
+ ::Stripe::Customer.all(count: 100).each(&:delete)
25
26
  ensure
26
27
  ::VCR.turn_on! if defined?(::VCR) && vcr_turned_on
27
28
  ::WebMock.allow_net_connect! if defined?(::WebMock) && webmock_net_connect
@@ -38,3 +39,4 @@ RSpec.configure do |config|
38
39
  config.rspeckled_logger.debug("After Each - End - #{__FILE__}")
39
40
  end
40
41
  end
42
+ # rubocop:enable Metrics/BlockNesting
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.configure do |config|
4
- config.around(:each, :time_mock => lambda { |v| !!v }) do |example|
3
+ ::RSpec.configure do |config|
4
+ config.around(:each, time_mock: ->(v) { !v.nil? }) do |example|
5
5
  config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
6
 
7
7
  options = example.metadata[:time_mock]
8
8
  options = case options
9
9
  when ::Time
10
- { :time => options }
10
+ { time: options }
11
11
  when ::FalseClass
12
12
  false
13
13
  when ::TrueClass
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.configure do |config|
4
- config.around(:each, :vcr => lambda { |v| !!v }) do |example|
3
+ ::RSpec.configure do |config|
4
+ config.around(:each, vcr: ->(v) { !v.nil? }) do |example|
5
5
  config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
6
 
7
7
  ::VCR.configuration.allow_http_connections_when_no_cassette = false
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.configure do |config|
4
- [:system, :feature, :request].each do |type|
5
- config.before(:all, :type => type) do |_example|
3
+ ::RSpec.configure do |config|
4
+ %i{system feature request}.each do |type|
5
+ config.before(:all, type: type) do |_example|
6
6
  config.rspeckled_logger.debug("Before All - Start - #{__FILE__}")
7
7
 
8
8
  ::Warden.test_mode!
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.configure do |config|
4
- config.around(:each, :webmock => lambda { |v| !!v }) do |example|
3
+ ::RSpec.configure do |config|
4
+ config.around(:each, webmock: ->(v) { !v.nil? }) do |example|
5
5
  config.rspeckled_logger.debug("Around Each - Start - #{__FILE__}")
6
6
 
7
7
  options = example.metadata[:webmock]
8
8
  options = case options
9
9
  when ::TrueClass
10
- { :allow_localhost => true }
10
+ { allow_localhost: true }
11
11
  end
12
12
 
13
13
  ::WebMock.disable_net_connect!(options)
@@ -13,13 +13,11 @@ require 'pp'
13
13
  # Below, we throw exceptions for each gem if the user requests that a test use
14
14
  # these gems, but the load failed (due to it not being in the gemspec/Gemfile).
15
15
  #
16
- # rubocop:disable Layout/EmptyLinesAroundExceptionHandlingKeywords
17
16
  begin; require 'email_spec'; rescue LoadError; end
18
17
  begin; require 'timecop'; rescue LoadError; end
19
18
  begin; require 'webmock'; rescue LoadError; end
20
19
  begin; require 'vcr'; rescue LoadError; end
21
20
 
22
- # rubocop:enable Layout/EmptyLinesAroundExceptionHandlingKeywords
23
21
  ################################################################################
24
22
  # Configuration
25
23
  #
@@ -29,6 +27,7 @@ begin; require 'vcr'; rescue LoadError; end
29
27
  # These files do *not* load the ACTUAL gem, but WILL load any RSpec files that
30
28
  # the README says need to be required (but only if necessary).
31
29
  #
30
+ # rubocop:disable Layout/LineLength
32
31
  require 'rspeckled/plugins/configuration/bullet' if defined?(::Bullet)
33
32
  require 'rspeckled/plugins/configuration/capybara' if defined?(::Capybara)
34
33
  require 'rspeckled/plugins/configuration/capybara_screenshot' if defined?(::Capybara::Screenshot)
@@ -68,19 +67,12 @@ require 'rspeckled/plugins/hooks/garbage_collection'
68
67
  require 'rspeckled/plugins/hooks/request'
69
68
  require 'rspeckled/plugins/hooks/timecop'
70
69
 
71
- require 'rspeckled/plugins/hooks/action_mailer' if defined?(::ActionMailer)
72
70
  require 'rspeckled/plugins/hooks/authentication'
73
- require 'rspeckled/plugins/hooks/bullet' if defined?(::Bullet)
74
71
  require 'rspeckled/plugins/hooks/capybara'
75
72
  require 'rspeckled/plugins/hooks/carrier_wave'
76
- require 'rspeckled/plugins/hooks/database_cleaner' if defined?(::DatabaseCleaner)
77
- require 'rspeckled/plugins/hooks/devise' if defined?(::Devise)
78
73
  require 'rspeckled/plugins/hooks/dox'
79
74
  require 'rspeckled/plugins/hooks/elasticsearch'
80
- require 'rspeckled/plugins/hooks/factory_bot' if defined?(::FactoryBot)
81
75
  require 'rspeckled/plugins/hooks/foreign_keys'
82
- require 'rspeckled/plugins/hooks/rails' if defined?(::Rails)
83
- require 'rspeckled/plugins/hooks/redis' if defined?(::Redis)
84
76
  require 'rspeckled/plugins/hooks/referehencible'
85
77
  require 'rspeckled/plugins/hooks/rspec_mocks'
86
78
  require 'rspeckled/plugins/hooks/selenium_webdriver'
@@ -88,9 +80,17 @@ require 'rspeckled/plugins/hooks/sidekiq'
88
80
  require 'rspeckled/plugins/hooks/singletons'
89
81
  require 'rspeckled/plugins/hooks/stripe'
90
82
  require 'rspeckled/plugins/hooks/vcr'
91
- require 'rspeckled/plugins/hooks/warden' if defined?(::Warden)
92
83
  require 'rspeckled/plugins/hooks/webmock'
93
84
 
85
+ require 'rspeckled/plugins/hooks/action_mailer' if defined?(::ActionMailer)
86
+ require 'rspeckled/plugins/hooks/bullet' if defined?(::Bullet)
87
+ require 'rspeckled/plugins/hooks/database_cleaner' if defined?(::DatabaseCleaner)
88
+ require 'rspeckled/plugins/hooks/devise' if defined?(::Devise)
89
+ require 'rspeckled/plugins/hooks/factory_bot' if defined?(::FactoryBot)
90
+ require 'rspeckled/plugins/hooks/rails' if defined?(::Rails)
91
+ require 'rspeckled/plugins/hooks/redis' if defined?(::Redis)
92
+ require 'rspeckled/plugins/hooks/warden' if defined?(::Warden)
93
+
94
94
  ################################################################################
95
95
  # Extensions
96
96
  #
@@ -100,25 +100,27 @@ require 'rspeckled/plugins/hooks/webmock'
100
100
  require 'rspeckled/plugins/extensions/awesome_print'
101
101
 
102
102
  # Properly Configure Puma and Setup Headed/Headless Chrome/Firefix Adapters
103
- require 'rspeckled/plugins/extensions/capybara' if defined?(::Capybara)
103
+ require 'rspeckled/plugins/extensions/capybara' if defined?(::Capybara)
104
104
 
105
105
  # Register a Faraday Middleware for Amazing Request/Response Logging
106
- require 'rspeckled/plugins/extensions/faraday' if defined?(::Faraday::Response::Middleware) &&
107
- defined?(::Faraday::Response)
106
+ require 'rspeckled/plugins/extensions/faraday' if defined?(::Faraday::Response::Middleware) &&
107
+ defined?(::Faraday::Response)
108
108
 
109
- # Registers Fixtures for Mocking OAuth Responses from Common Services (Facebook, Twitter, etc)
110
- require 'rspeckled/plugins/extensions/omniauth' if defined?(::OmniAuth)
109
+ # Registers Fixtures for Mocking OAuth Responses from Common Services (Facebook,
110
+ # Twitter, etc)
111
+ require 'rspeckled/plugins/extensions/omniauth' if defined?(::OmniAuth)
111
112
 
112
- # Setup for APIs by Always Allowing 'id' and Fail Fast By Raising on Unpermitted Parameters
113
- require 'rspeckled/plugins/extensions/strong_parameters' if defined?(::ActionController::Parameters)
113
+ # Setup for APIs by Always Allowing 'id' and Fail Fast By Raising on Unpermitted
114
+ # Parameters
115
+ require 'rspeckled/plugins/extensions/strong_parameters' if defined?(::ActionController::Parameters)
114
116
 
115
117
  # Register Matchers Which Ignore Trailing UUID/GUIDs in URLs
116
- require 'rspeckled/plugins/extensions/vcr' if defined?(::VCR)
118
+ require 'rspeckled/plugins/extensions/vcr' if defined?(::VCR)
117
119
 
118
120
  ################################################################################
119
121
  # Automatic Gem Requirements
120
122
  #
121
- RSpec.configure do |config|
123
+ ::RSpec.configure do |config|
122
124
  config.when_first_matching_example_defined(:email) do
123
125
  fail LoadError, "Add 'email_spec' to your gemspec for Gemfile to use the :email metadata" unless defined?(::EmailSpec)
124
126
  end
@@ -135,3 +137,4 @@ RSpec.configure do |config|
135
137
  fail LoadError, "Add 'webmock' to your gemspec for Gemfile to use the :webmock metadata" unless defined?(::WebMock)
136
138
  end
137
139
  end
140
+ # rubocop:enable Layout/LineLength
@@ -21,6 +21,10 @@ class Example
21
21
  )
22
22
  }xi.freeze
23
23
 
24
+ private_constant :IGNORED_QUERIES_PATTERN
25
+
26
+ ExecutionResult = Struct.new('ExecutionResult', :status, :run_time, :exception)
27
+
24
28
  attr_accessor :counts,
25
29
  :example
26
30
 
@@ -70,7 +74,7 @@ class Example
70
74
  end
71
75
 
72
76
  def log_query(query, start, finish)
73
- return if query[:sql] =~ IGNORED_QUERIES_PATTERN
77
+ return if IGNORED_QUERIES_PATTERN.match?(query[:sql])
74
78
 
75
79
  counts[:query_count] += 1
76
80
  counts[:query_time] += (finish - start)
@@ -88,13 +92,11 @@ class Example
88
92
  end
89
93
 
90
94
  def execution_result
91
- @execution_result ||= begin
92
- if example.execution_result.is_a?(Hash)
93
- OpenStruct.new(example.execution_result) # rubocop:disable Performance/OpenStruct
94
- else
95
- example.execution_result
96
- end
97
- end
95
+ @execution_result ||= if example.execution_result.is_a?(::Hash)
96
+ ExecutionResult.new(example.execution_result)
97
+ else
98
+ example.execution_result
99
+ end
98
100
  end
99
101
  end
100
102
  end
@@ -25,6 +25,8 @@ class Csv
25
25
  description
26
26
  }.freeze
27
27
 
28
+ private_constant :FIELDS
29
+
28
30
  attr_accessor :output
29
31
 
30
32
  def initialize
@@ -7,21 +7,23 @@ module Reporting
7
7
  module Outputs
8
8
  class Text
9
9
  FIELDS = {
10
- :branch => '%-<branch>s',
11
- :commit_hash => '%-8.8<commit_hash>s',
12
- :date => '%-<date>s',
13
- :file => '%-80.80<file>s',
14
- :status => '%-7.7<status>s',
15
- :time => '%7.4<time>f',
16
- :query_count => '%3<query_count>d',
17
- :query_time => '%7.4<query_time>f',
18
- :query_percentage => '%5.2<query_percentage>f%%',
19
- :request_count => '%3<request_count>d',
20
- :request_time => '%7.4<request_time>f',
21
- :request_percentage => '%5.2<request_percentage>f%%',
22
- :description => '%-80.80<description>s',
10
+ branch: '%-<branch>s',
11
+ commit_hash: '%-8.8<commit_hash>s',
12
+ date: '%-<date>s',
13
+ file: '%-80.80<file>s',
14
+ status: '%-7.7<status>s',
15
+ time: '%7.4<time>f',
16
+ query_count: '%3<query_count>d',
17
+ query_time: '%7.4<query_time>f',
18
+ query_percentage: '%5.2<query_percentage>f%%',
19
+ request_count: '%3<request_count>d',
20
+ request_time: '%7.4<request_time>f',
21
+ request_percentage: '%5.2<request_percentage>f%%',
22
+ description: '%-80.80<description>s',
23
23
  }.freeze
24
24
 
25
+ private_constant :FIELDS
26
+
25
27
  attr_accessor :output
26
28
 
27
29
  def initialize
@@ -31,9 +33,9 @@ class Text
31
33
  end
32
34
 
33
35
  def insert(data)
34
- data[:file] = data[:file].gsub(%r{^\./spec/}, './') + ':' + data[:line_number].to_s
36
+ data[:file] = "#{data[:file].gsub(%r{^\./spec/}, './')}:#{data[:line_number]}"
35
37
 
36
- format_string = FIELDS.values.join(' - ') + "\n"
38
+ format_string = "#{FIELDS.values.join(' - ')}\n"
37
39
 
38
40
  output.printf(format_string, data)
39
41
  end
@@ -21,6 +21,8 @@ class Runner
21
21
  description
22
22
  }.freeze
23
23
 
24
+ private_constant :FIELDS
25
+
24
26
  attr_accessor :example,
25
27
  :outputters
26
28
 
@@ -35,42 +37,42 @@ class Runner
35
37
  def start(_notification)
36
38
  return unless defined?(::ActiveSupport::Notifications)
37
39
 
38
- ActiveSupport::Notifications.subscribe('sql.active_record') do |_name, start, finish, _id, query|
39
- example&.log_query(query, start, finish)
40
- end
40
+ ::ActiveSupport::Notifications
41
+ .subscribe('sql.active_record') do |_name, start, finish, _id, query|
42
+ example&.log_query(query, start, finish)
43
+ end
41
44
 
42
- ActiveSupport::Notifications.subscribe('process_action.action_controller') do |_name, start, finish, _id, request|
43
- example&.log_request(request, start, finish)
44
- end
45
+ ::ActiveSupport::Notifications
46
+ .subscribe('process_action.action_controller') do |_name, start, finish, _id, reqst|
47
+ example&.log_request(reqst, start, finish)
48
+ end
45
49
  end
46
50
 
47
51
  def example_started(notification)
48
52
  self.example = Example.new(notification.example)
49
53
  end
50
54
 
51
- # rubocop:disable Metrics/AbcSize
52
- def example_finished(_notification)
55
+ def example_finished(_notification) # rubocop:disable Metrics/AbcSize
53
56
  outputters.each do |outputter|
54
57
  outputter.insert(
55
- :branch => `git rev-parse --abbrev-ref HEAD`.chomp,
56
- :commit_hash => `git rev-parse HEAD`.chomp,
57
- :date => ::Time.parse(`git show -s --format=%ci HEAD`.chomp),
58
- :file => example.file,
59
- :line_number => example.line_number,
60
- :description => example.description,
61
- :status => example.status,
62
- :exception => example.exception,
63
- :time => example.time,
64
- :query_count => example.query_count,
65
- :query_time => example.query_time,
66
- :query_percentage => example.query_time / example.time * 100.0,
67
- :request_count => example.request_count,
68
- :request_time => example.request_time,
69
- :request_percentage => example.request_time / example.time * 100.0
58
+ branch: `git rev-parse --abbrev-ref HEAD`.chomp,
59
+ commit_hash: `git rev-parse HEAD`.chomp,
60
+ date: ::Time.parse(`git show -s --format=%ci HEAD`.chomp),
61
+ file: example.file,
62
+ line_number: example.line_number,
63
+ description: example.description,
64
+ status: example.status,
65
+ exception: example.exception,
66
+ time: example.time,
67
+ query_count: example.query_count,
68
+ query_time: example.query_time,
69
+ query_percentage: example.query_time / example.time * 100.0,
70
+ request_count: example.request_count,
71
+ request_time: example.request_time,
72
+ request_percentage: example.request_time / example.time * 100.0,
70
73
  )
71
74
  end
72
75
  end
73
- # rubocop:enable Metrics/AbcSize
74
76
 
75
77
  alias example_passed example_finished
76
78
  alias example_pending example_finished
@@ -10,15 +10,19 @@ begin
10
10
  rescue Errno::EEXIST
11
11
  end
12
12
 
13
- log_file = File.join(Dir.pwd, 'log', 'activerecord.log')
14
- rails_database_yaml_file_path = File.join(Dir.pwd, 'config', 'database.yml')
15
- rails_engine_database_yaml_file_path = File.join(Dir.pwd, 'spec', 'dummy', 'config', 'database.yml')
16
- database_yaml_file_path = if File.exist? rails_engine_database_yaml_file_path
17
- rails_engine_database_yaml_file_path
18
- else
19
- rails_database_yaml_file_path
20
- end
21
- connection_info = YAML.load_file(database_yaml_file_path)['test']
13
+ log_file = File.join(Dir.pwd, 'log', 'activerecord.log')
14
+ rails_database_yaml_file_path = File.join(Dir.pwd, 'config', 'database.yml')
15
+ rails_engine_database_yaml_file_path = File.join(Dir.pwd,
16
+ 'spec',
17
+ 'dummy',
18
+ 'config',
19
+ 'database.yml')
20
+ database_yaml_file_path = if File.exist? rails_engine_database_yaml_file_path
21
+ rails_engine_database_yaml_file_path
22
+ else
23
+ rails_database_yaml_file_path
24
+ end
25
+ connection_info = YAML.load_file(database_yaml_file_path)['test']
22
26
 
23
27
  ActiveRecord::Base.logger = Logger.new(log_file)
24
28
  ActiveRecord::Base.establish_connection(connection_info)
@@ -8,8 +8,8 @@ require File.join(Dir.pwd, 'spec', 'dummy', 'config', 'environment')
8
8
  require 'rspec/rails'
9
9
 
10
10
  Pathname.glob("#{Dir.pwd}/app/*").each do |directory|
11
- if directory.directory?
12
- $LOAD_PATH.unshift(directory) unless $LOAD_PATH.include?(directory)
11
+ if directory.directory? && $LOAD_PATH.exclude?(directory)
12
+ $LOAD_PATH.unshift(directory)
13
13
  end
14
14
  end
15
15
 
@@ -10,5 +10,21 @@ require 'rspeckled/helpers'
10
10
  require 'rspeckled/patches'
11
11
  require 'rspeckled/plugins'
12
12
 
13
- Dir[File.join(Dir.pwd, 'spec', 'shared', '**', '*_spec.rb')].sort.each { |f| puts "WARNING: You have a shared example file (#{f}) that ends in '_spec'. RSpec will load this twice with a misleading error message if you are explicitly requiring your shared examples (as you should). See: https://github.com/rspec/rspec-core/issues/828" }
13
+ ::RSpec.configure do |config|
14
+ config.include ::Rspeckled::Helpers::Factories
15
+ config.include ::Rspeckled::Helpers::Filepaths
16
+ config.include ::Rspeckled::Helpers::NullObjects
17
+ config.include ::Rspeckled::Helpers::Patterns
18
+ config.include ::Rspeckled::Helpers::Responses
19
+ end
20
+
14
21
  Dir[File.join(Dir.pwd, 'spec', 'support', '**', '*.rb')].sort.each { |f| require f }
22
+
23
+ Dir[File.join(Dir.pwd, 'spec', 'shared', '**', '*_spec.rb')].sort.each do |f|
24
+ puts(<<~HEREDOC).tr("\n", ' ')
25
+ WARNING: You have a shared example file (#{f}) that ends in '_spec'. RSpec
26
+ will load this twice with a misleading error message if you are explicitly
27
+ requiring your shared examples (as you should). See:
28
+ https://github.com/rspec/rspec-core/issues/828"
29
+ HEREDOC
30
+ end
@@ -8,8 +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
12
- RSpec.configure do |config|
11
+ ::RSpec.configure do |config| # rubocop:disable Metrics/BlockLength
13
12
  ##############################################################################
14
13
  # RSPECKLED CONFIGURATION
15
14
  ##############################################################################
@@ -17,10 +16,10 @@ RSpec.configure do |config|
17
16
  default_logger = ::Logger.new($stdout)
18
17
  default_logger.level = ENV.fetch('RSPECKLED_LOG_LEVEL', ::Logger::WARN).to_i
19
18
 
20
- config.add_setting :rspeckled_logger, :default => default_logger
21
- config.add_setting :rspeckled_disabled_plugin_configuration, :default => []
22
- config.add_setting :rspeckled_disabled_plugin_hooks, :default => []
23
- config.add_setting :rspeckled_disabled_plugin_extensions, :default => []
19
+ config.add_setting :rspeckled_logger, default: default_logger
20
+ config.add_setting :rspeckled_disabled_plugin_configuration, default: []
21
+ config.add_setting :rspeckled_disabled_plugin_hooks, default: []
22
+ config.add_setting :rspeckled_disabled_plugin_extensions, default: []
24
23
 
25
24
  ##############################################################################
26
25
  # RSPEC 4 PREP
@@ -36,7 +35,9 @@ RSpec.configure do |config|
36
35
  config.infer_base_class_for_anonymous_controllers = true
37
36
  config.use_transactional_fixtures = true
38
37
 
39
- config.infer_spec_type_from_file_location! if config.respond_to?(:infer_spec_type_from_file_location!)
38
+ if config.respond_to?(:infer_spec_type_from_file_location!)
39
+ config.infer_spec_type_from_file_location!
40
+ end
40
41
  end
41
42
 
42
43
  ##############################################################################
@@ -90,26 +91,28 @@ RSpec.configure do |config|
90
91
  ##############################################################################
91
92
 
92
93
  # Pending Specs
93
- config.alias_example_to :pit, :pending => true
94
+ config.alias_example_to :pit, pending: true
94
95
 
95
96
  # Focused Specs
96
97
  config.filter_run_when_matching :focused
97
- config.alias_example_to :fit, :focused => true
98
+ config.alias_example_to :fit, focused: true
98
99
 
99
100
  # Focus and Force Selenium
100
- config.alias_example_to :sit, :focused => true,
101
- :autofocus => true,
102
- :js => true,
103
- :debug => true,
104
- :delay => 0,
105
- :driver => :firefox
106
-
107
- config.alias_example_to :sscenario, :focused => true,
108
- :autofocus => true,
109
- :js => true,
110
- :debug => true,
111
- :delay => 0,
112
- :driver => :firefox
101
+ config.alias_example_to :sit,
102
+ focused: true,
103
+ autofocus: true,
104
+ js: true,
105
+ debug: true,
106
+ delay: 0,
107
+ driver: :firefox
108
+
109
+ config.alias_example_to :sscenario,
110
+ focused: true,
111
+ autofocus: true,
112
+ js: true,
113
+ debug: true,
114
+ delay: 0,
115
+ driver: :firefox
113
116
 
114
117
  config.order = 'random'
115
118
  config.silence_filter_announcements = true
@@ -121,7 +124,7 @@ RSpec.configure do |config|
121
124
  # CUSTOM METADATA TYPES
122
125
  ##############################################################################
123
126
 
124
- config.define_derived_metadata(:file_path => %r{spec/(jobs|workers)}) do |metadata|
127
+ config.define_derived_metadata(file_path: %r{spec/(jobs|workers)}) do |metadata|
125
128
  metadata[:queue] = true if metadata[:queue].nil?
126
129
  end
127
130
 
@@ -150,4 +153,3 @@ RSpec.configure do |config|
150
153
  end
151
154
  end
152
155
  end
153
- # rubocop:enable Layout/MultilineMethodArgumentLineBreaks