ci_logger 0.4.0 → 0.5.1

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: de52e260b632de6a46a6a19b69e566b0549edaa2b78e839251c2b954d6fbb1d0
4
- data.tar.gz: 4c005a4e2417d12bada68fbd4165a2b0e00c6ad93df4a8516bda206c810e2d8d
3
+ metadata.gz: d378e44c124952aecefaada042e51ca49bde9f126970a7ed5b8e04a9f4523a4f
4
+ data.tar.gz: cb5d471262303a7b6075979c5c4d411424fa1783742e1a2c67aea4630ed5166e
5
5
  SHA512:
6
- metadata.gz: 9048488a216c30c627a7a303891331cc8489b40467fc0fdd698b747ee2bd5911e0fa1d23a33574549bf44f36b42b979e1de2feaeb25474fd7c32c31bc58365be
7
- data.tar.gz: ff957687392a4b2438ccb736e2b7696c47dd3784fd673ac34206ae5e176b136b2251febbe273cc05414465d36ccb2cd15a4a465f427eb5c41d6a93090a9dbcfa
6
+ metadata.gz: 40f1589c2767df171705caa124a03afe67b793e043f9ec94a2d4dc0552029bdca4c5cbca2dafe1b9182b6b6d00afec6821a9dea1b4024c6585c04ee1a560b9da
7
+ data.tar.gz: fbe15cfa23c67256a4b8a71fb2871b7da2dc0b236d913537d2ae49a70a4b4e2738ec0eff000013c2b921d24894e28f240018986ef02ba20b007c8dab1bfd07f3
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # CiLogger
2
2
 
3
- We run a large number of tests with CI every day. When a test fails, we have to investigate the log, but as it is, the log output is so large that it is difficult to investigate the cause of the failed test.
3
+ We perform a significant number of tests using CI on a daily basis. Whenever a test fails, we need to examine the log. However, the current log output is excessively large, making it challenging to identify the root cause of the failed test.
4
4
 
5
- CiLogger outputs only the log of failed tests. This is useful when investigating the cause of a failed test.
5
+ CiLogger specifically generates logs for failed tests, which proves invaluable during the investigation of test failures.
6
6
 
7
7
  ## prerequisite
8
8
 
@@ -0,0 +1,14 @@
1
+ module CiLogger
2
+ module ExampleGroupMethods
3
+ # original from https://github.com/rspec/rspec-rails/blob/229f5f7ca9c0de0c7bca452450416d988f7cf612/lib/rspec/rails/example/system_example_group.rb#L28-L37
4
+ def passed?
5
+ return false if RSpec.current_example.exception
6
+ return true unless defined?(::RSpec::Expectations::FailureAggregator)
7
+
8
+ failure_notifier = ::RSpec::Support.failure_notifier
9
+ return true unless failure_notifier.is_a?(::RSpec::Expectations::FailureAggregator)
10
+
11
+ failure_notifier.failures.empty? && failure_notifier.other_errors.empty?
12
+ end
13
+ end
14
+ end
@@ -4,16 +4,30 @@ module CiLogger
4
4
  config.ci_logger.enabled = false
5
5
 
6
6
  config.before_initialize do
7
- if config.ci_logger.enabled
7
+ if Rails.application.config.ci_logger.enabled
8
8
  Rails.logger = CiLogger::Logger.new(Rails.logger)
9
- require "ci_logger/rspec_formatter"
9
+ require "rspec/core"
10
+ require "ci_logger/example_group_methods"
10
11
 
11
12
  RSpec.configure do |config|
12
- config.add_formatter 'progress' if config.formatters.empty?
13
- config.add_formatter ::CiLogger::RspecFormatter
14
- config.before do |example|
13
+ config.include CiLogger::ExampleGroupMethods
14
+
15
+ config.prepend_before do |example|
16
+ next unless Rails.application.config.ci_logger.enabled
17
+
15
18
  Rails.logger.debug("start example at #{example.location}")
16
19
  end
20
+
21
+ config.append_after do |example|
22
+ if !Rails.application.config.ci_logger.enabled
23
+ Rails.logger.sync
24
+ elsif passed?
25
+ Rails.logger.clear
26
+ else
27
+ Rails.logger.debug("finish example at #{example.location}")
28
+ Rails.logger.sync
29
+ end
30
+ end
17
31
  end
18
32
  end
19
33
  end
@@ -1,3 +1,3 @@
1
1
  module CiLogger
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - willnet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -63,9 +63,9 @@ files:
63
63
  - README.md
64
64
  - Rakefile
65
65
  - lib/ci_logger.rb
66
+ - lib/ci_logger/example_group_methods.rb
66
67
  - lib/ci_logger/logger.rb
67
68
  - lib/ci_logger/railtie.rb
68
- - lib/ci_logger/rspec_formatter.rb
69
69
  - lib/ci_logger/version.rb
70
70
  - lib/tasks/ci_logger_tasks.rake
71
71
  homepage: https://github.com/willnet/ci_logger
@@ -1,37 +0,0 @@
1
- require "rspec/core"
2
-
3
- module CiLogger
4
- class RspecFormatter
5
- RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed
6
-
7
- def initialize(_out)
8
- @out = _out
9
- end
10
-
11
- def example_failed(notification)
12
- if Rails.application.config.ci_logger.enabled
13
- example = notification.example
14
- Rails.logger.debug("finish example at #{example.location}")
15
- Rails.logger.sync
16
- else
17
- Rails.logger.sync_with_original_level
18
- end
19
- end
20
-
21
- def example_passed(_notification)
22
- if Rails.application.config.ci_logger.enabled
23
- Rails.logger.clear
24
- else
25
- Rails.logger.sync_with_original_level
26
- end
27
- end
28
-
29
- def example_pending(_notification)
30
- if Rails.application.config.ci_logger.enabled
31
- Rails.logger.clear
32
- else
33
- Rails.logger.sync_with_original_level
34
- end
35
- end
36
- end
37
- end