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 +4 -4
- data/Gemfile.lock +2 -1
- data/README.md +52 -6
- data/lib/rspec_table_formatter/configuration.rb +27 -0
- data/lib/rspec_table_formatter/version.rb +1 -1
- data/lib/rspec_table_formatter.rb +9 -1
- data/lib/table_builder.rb +7 -7
- data/rspec_table_formatter.gemspec +4 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 426fd4e25e8d1ab26edf8352bd0e41c5cf00a828d4f85402e79af8f9c0c35f52
|
4
|
+
data.tar.gz: b289d69ab7ff91c1d95fa87f203f28191d3bdaa60ce07903cad03b5c85c8c30a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '053811037ae1d12a747402f474f790f43351588bdb0ee26d28bb024dadf8c18cda14dcb1bc4f5302efa976b14e37745d435e3430eb9f5faea497947c4b9146a4'
|
7
|
+
data.tar.gz: '094ebce9f66d254a454407929630977ef9eb3f758f415871ef5b0e066e652b7dcc8578104d1284179e9f0a6ddc97f81d9be9f797f6a0f51c4de405aff43d3a12'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# RspecTableFormatter
|
2
2
|
|
3
|
-
|
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
|
-
|
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/
|
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
|
@@ -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 =
|
14
|
+
t.headings = @configs.headers
|
14
15
|
t.rows = map_examples(@examples)
|
15
|
-
t.style =
|
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
|
-
|
37
|
+
@configs.passed_message
|
38
38
|
when :failed
|
39
|
-
|
39
|
+
@configs.failed_message
|
40
40
|
when :pending
|
41
|
-
|
41
|
+
@configs.pending_message
|
42
42
|
else
|
43
43
|
''
|
44
44
|
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.
|
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:
|
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
|