rspec_table_formatter 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94b51d726c20d5cfbf82f5b5571478d952020bfe610646392785c0ca6035d4a3
4
- data.tar.gz: 0abd12e21a4e9762c22c79a7d6d37e2ab7be2a4706a17c696f7ae7008646d81f
3
+ metadata.gz: 426fd4e25e8d1ab26edf8352bd0e41c5cf00a828d4f85402e79af8f9c0c35f52
4
+ data.tar.gz: b289d69ab7ff91c1d95fa87f203f28191d3bdaa60ce07903cad03b5c85c8c30a
5
5
  SHA512:
6
- metadata.gz: 52a6f106be0bf557c3fa12f3e2aaa1989fe601fefc2f55f0963ab135f1079cf8a2f218bc7cea52c63fa904f74931dfe479ecd289700adcfc18b438127c832d5b
7
- data.tar.gz: 10122b23103422f2b33cb4755f0b1ef7c4dd23a50f25cd2b7fa50782bebad8cfc255b348c908ede7fcfa568b3cbfd0e3914fd1f1c03d93c1052e373b94c43d42
6
+ metadata.gz: '053811037ae1d12a747402f474f790f43351588bdb0ee26d28bb024dadf8c18cda14dcb1bc4f5302efa976b14e37745d435e3430eb9f5faea497947c4b9146a4'
7
+ data.tar.gz: '094ebce9f66d254a454407929630977ef9eb3f758f415871ef5b0e066e652b7dcc8578104d1284179e9f0a6ddc97f81d9be9f797f6a0f51c4de405aff43d3a12'
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec_table_formatter (0.1.9)
4
+ rspec_table_formatter (0.1.11)
5
+ terminal-table (~> 3.0.2)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # RspecTableFormatter
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec_table_formatter`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
-
6
- I have created this gem to be used specifially confluvance, it might not work on other tableformaters
3
+ `RspecTableFormatter` is a customizable formatter for displaying RSpec test results in a table format with customizable headers, messages, and styles.
7
4
 
8
5
  ## Installation
9
6
 
@@ -23,7 +20,56 @@ Or install it yourself as:
23
20
 
24
21
  ## Usage
25
22
 
26
- TODO: Write usage instructions here
23
+ So to use the formatter
24
+
25
+ ```
26
+ rspec --format RspecTableFormatter
27
+ ```
28
+
29
+ or if always want the formatter to be used, add the following to end of your `.rspec` file
30
+
31
+ ```
32
+ --format RspecTableFormatter
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ You can configure `RspecTableFormatter` to display custom messages and headers for your test results. You can also set the table style using a hash.
38
+
39
+ To configure the formatter, use the `configure` method and pass in a block. In the block, you can customize the following options:
40
+
41
+ - `passed_message`: The message displayed for passed tests.
42
+ - `failed_message`: The message displayed for failed tests.
43
+ - `pending_message`: The message displayed for pending tests.
44
+ - `test_case_header`: The header for the test case column.
45
+ - `expected_result_header`: The header for the expected result column.
46
+ - `status_header`: The header for the status column.
47
+ - `table_style`: A hash defining the table style.
48
+
49
+ ### Example:
50
+
51
+ ```ruby
52
+ # Configuration example
53
+ RspecTableFormatter.configure do |config|
54
+ # Customize status messages
55
+ config.passed_message = '✔️ Test Passed'
56
+ config.failed_message = '❌ Test Failed'
57
+ config.pending_message = '⚠️ Test Pending'
58
+
59
+ # Customize table headers
60
+ config.test_case_header = 'Test Description'
61
+ config.expected_result_header = 'Expected Outcome'
62
+ config.status_header = 'Test Status'
63
+
64
+ # Customize table style
65
+ config.table_style = { border_left: true, border_right: true, border: :ascii }
66
+ end
67
+ ```
68
+
69
+ #### Table Style
70
+ We use [terminal-table](https://github.com/tj/terminal-table) to render the table.
71
+ Any of the styles supported by `terminal-table` can be used.
72
+
27
73
 
28
74
  ## Development
29
75
 
@@ -42,4 +88,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
42
88
 
43
89
  ## Code of Conduct
44
90
 
45
- Everyone interacting in the RspecTableFormatter project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rspec_table_formatter/blob/master/CODE_OF_CONDUCT.md).
91
+ Everyone interacting in the RspecTableFormatter project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nijeesh4all/rspec_table_formatter/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,27 @@
1
+ module RspecTableFormatter
2
+ class Configurations
3
+
4
+ attr_accessor :passed_message, :failed_message, :pending_message,
5
+ :test_case_header, :expected_result_header, :status_header,
6
+ :table_style
7
+
8
+ def initialize
9
+ # messages to be displayed in the status column
10
+ @passed_message = '✔️ Passed'
11
+ @failed_message = '❌ Failed'
12
+ @pending_message = '⚠️ Test case pending'
13
+
14
+ # headers for the table
15
+ @test_case_header = 'Test Case'
16
+ @expected_result_header = 'Expected result'
17
+ @status_header = 'Status'
18
+
19
+ # table style
20
+ @table_style = { border_left: false, border_right: false, border: :markdown }
21
+ end
22
+
23
+ def headers
24
+ [@test_case_header, @expected_result_header, @status_header]
25
+ end
26
+ end
27
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  class RspecTableFormatter
4
4
  module Version
5
- VERSION = '0.1.9'
5
+ VERSION = '0.1.11'
6
6
  end
7
7
  end
@@ -7,6 +7,8 @@ require_relative './table_builder'
7
7
  class RspecTableFormatter
8
8
  class Error < StandardError; end
9
9
 
10
+ @configs = Configurations.new
11
+
10
12
  RSpec::Core::Formatters.register self, :dump_summary
11
13
 
12
14
  def initialize(output)
@@ -15,6 +17,12 @@ class RspecTableFormatter
15
17
 
16
18
  def dump_summary(notification)
17
19
  examples = notification.examples
18
- @output << TableBuilder.new(examples).generate_table.to_s + "\n"
20
+ @output << TableBuilder.new(examples, @configs).generate_table.to_s + "\n"
21
+ end
22
+
23
+ class << self
24
+ def configure
25
+ yield @configs if block_given?
26
+ end
19
27
  end
20
28
  end
data/lib/table_builder.rb CHANGED
@@ -4,15 +4,16 @@ require 'terminal-table'
4
4
 
5
5
  # converts the examples array to a table string
6
6
  class TableBuilder
7
- def initialize(examples)
7
+ def initialize(examples, configs)
8
8
  @examples = examples
9
+ @configs = configs
9
10
  end
10
11
 
11
12
  def generate_table
12
13
  Terminal::Table.new do |t|
13
- t.headings = ['Test Case', 'Expected result', 'status']
14
+ t.headings = @configs.headers
14
15
  t.rows = map_examples(@examples)
15
- t.style = { border_left: false, border_right: false, border: :markdown }
16
+ t.style = @configs.table_style
16
17
  end
17
18
  end
18
19
 
@@ -31,14 +32,13 @@ class TableBuilder
31
32
  end
32
33
 
33
34
  def execution_status(example)
34
- puts example.execution_result.status
35
35
  case example.execution_result.status
36
36
  when :passed
37
- '✔️ Passed'
37
+ @configs.passed_message
38
38
  when :failed
39
- '❌ Failed'
39
+ @configs.failed_message
40
40
  when :pending
41
- '⚠️ Test case pending'
41
+ @configs.pending_message
42
42
  else
43
43
  ''
44
44
  end
@@ -27,4 +27,8 @@ Gem::Specification.new do |spec|
27
27
  spec.bindir = 'exe'
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
+
31
+
32
+ # dependencies
33
+ spec.add_dependency 'terminal-table', '~>3.0.2'
30
34
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_table_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nijeesh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: terminal-table
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.2
13
27
  description: a simple gem to output the rspec run summery in markdown table formatso
14
28
  you can copy paste the content to any documentation of your choice
15
29
  email:
@@ -36,6 +50,7 @@ files:
36
50
  - bin/console
37
51
  - bin/setup
38
52
  - lib/rspec_table_formatter.rb
53
+ - lib/rspec_table_formatter/configuration.rb
39
54
  - lib/rspec_table_formatter/version.rb
40
55
  - lib/table_builder.rb
41
56
  - rspec_table_formatter.gemspec