rspec_table_formatter 0.1.10 → 0.1.13

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: 985a4059b3bcf9df233c90f265fa19606218d9bb8b83169269ebccdd5b06fe43
4
- data.tar.gz: df93e3fadd9ce4c33c519aeedda74b625308f1bbe81a55e3e58b5ffece659c71
3
+ metadata.gz: 4f39e2b40a66011610fadf9d63c87bbff51d661a50e43a8ffc8b3570edb9b499
4
+ data.tar.gz: 6df8b9788937c4038d304846f4d0df4a9dabe3b09d9daca892650fcb1cc8f261
5
5
  SHA512:
6
- metadata.gz: 9347c9cabaf9176d92cacd0ca62241aaf73d282c80a7426a34f559bbbb826705c1081752cfed933f1a5ee523183c0dd1fd90df6f5fae7b9e2164488bbc9d74f9
7
- data.tar.gz: 95af5e0491de6f5c07d4d774aaad6ac613bf19cf6f97bc0412ecc180ea3dc7c1b1edcd025363a75c8db4b9ae03b9da3993087d2fa16459a93ca72b90ed5987fc
6
+ metadata.gz: 3e38a74845c5f7a08ba9aa23fe13e7fd1fc1df0aa2ac72dafc6bd9eab4cb2c7eeb586b005a61489f0b6106a114ab5a69764a8aec123733241748085dc936a28b
7
+ data.tar.gz: be4ebd1ad4aa7915a3c27ebb0464c5b96857ec30e2a0f8451bf2859fc73446c54d03ef5d427de3e92f7ca2f028294172d734a7d5dc0fbd084a194f297734700e
@@ -22,6 +22,12 @@ jobs:
22
22
  with:
23
23
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
24
24
 
25
+ - name: Unset bundler deployment mode
26
+ run: bundle config unset deployment
27
+
28
+ - name: Install dependencies
29
+ run: bundle install --jobs 4
30
+
25
31
  - name: Publish to RubyGems
26
32
  # if: contains(github.ref, 'refs/tags/v')
27
33
  run: |
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec_table_formatter (0.1.10)
4
+ rspec_table_formatter (0.1.13)
5
5
  terminal-table (~> 3.0.2)
6
6
 
7
7
  GEM
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.10'
5
+ VERSION = '0.1.13'
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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_table_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.13
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
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: terminal-table
@@ -50,6 +50,7 @@ files:
50
50
  - bin/console
51
51
  - bin/setup
52
52
  - lib/rspec_table_formatter.rb
53
+ - lib/rspec_table_formatter/configuration.rb
53
54
  - lib/rspec_table_formatter/version.rb
54
55
  - lib/table_builder.rb
55
56
  - rspec_table_formatter.gemspec