rspec_overview 0.2.0 → 0.3.0

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
  SHA1:
3
- metadata.gz: 91ecf4bf56b43ba4727d25899adcc5523827de5c
4
- data.tar.gz: 3b280c205f00035b4455644041daf5bbdb73fd55
3
+ metadata.gz: 287a96d1c9135913ae99f63bd6e8ef9128f2c11d
4
+ data.tar.gz: 5c11b17f834b44e79e296cd361255834cabea3ab
5
5
  SHA512:
6
- metadata.gz: 48e0d3b44f2cd9e4d71c8978df408e884560123c1c51bf053f316f2f8a3385de27a6f6eebdcc836b1bda9571a3bb041b6c1ae9e9f5d3989bccae9a2a22f87119
7
- data.tar.gz: c524cde83bcf2ba4c857787132c1d7d685b10a32d1f6afb0cb336f2c6add205bb8fb7b96c894a0f2abac580b3011172bb29093ddd767fced9e1832a2b2c465a2
6
+ metadata.gz: 31a462e3d5b8a5a002aff2c05ead867a4b095a0b920abab8482b6613b41b112685c3a0ea47215b550b5ee6204bbaaa32827182c35c2a59297c8fef9b95c15bf4
7
+ data.tar.gz: c7de28741f24ed646d18cad7fe2ee7a3003afebc340a0060b1ac5340666a7610344a9e8ced8e4427212cfdb062fcf3b49ff471de93e7c2f86a721e1e09619bc2
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.3.0
4
+ - Switch default format to a markdown table
5
+ - Drops `terminal-table` dependency
6
+ - Fix missing require when using the CSV formatter
7
+
3
8
  ## v0.2.0
4
9
  - Add CSV format support
5
10
 
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec_overview (0.2.0)
4
+ rspec_overview (0.3.0)
5
5
  rspec-core (~> 3.0)
6
- terminal-table (~> 1.6)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
@@ -32,9 +31,6 @@ GEM
32
31
  diff-lcs (>= 1.2.0, < 2.0)
33
32
  rspec-support (~> 3.7.0)
34
33
  rspec-support (3.7.0)
35
- terminal-table (1.8.0)
36
- unicode-display_width (~> 1.1, >= 1.1.1)
37
- unicode-display_width (1.3.0)
38
34
 
39
35
  PLATFORMS
40
36
  ruby
data/README.md CHANGED
@@ -45,52 +45,46 @@ Run against [thoughtbot/administrate][administrate]:
45
45
  [administrate]: https://github.com/thoughtbot/administrate
46
46
 
47
47
  ```
48
- Randomized with seed 40301
49
- ................................................................................
48
+ Randomized with seed 16132
50
49
  ................................................................................
51
50
  ................................................................................
52
51
  ................................................................................
53
- ...........................................
52
+ ......................................................................
53
+
54
+ Finished in 15.03 seconds (files took 6.02 seconds to load)
55
+ 310 examples, 0 failures
54
56
 
55
- Finished in 19.36 seconds (files took 3.99 seconds to load)
56
- 363 examples, 0 failures
57
+ # Summary by Type or Subfolder
57
58
 
58
- +---------------------+---------------+--------------+-------------------------+
59
- | Summary by Type or Subfolder |
60
- +---------------------+---------------+--------------+-------------------------+
61
59
  | Type or Subfolder | Example count | Duration (s) | Average per example (s) |
62
- +---------------------+---------------+--------------+-------------------------+
63
- | feature | 83 | 9.88 | 0.11905 |
64
- | controller | 46 | 3.56 | 0.07738 |
65
- | generator | 73 | 2.49 | 0.03408 |
66
- | ./spec/lib | 95 | 1.02 | 0.0107 |
67
- | ./spec/i18n_spec.rb | 2 | 0.93344 | 0.46672 |
68
- | view | 15 | 0.75198 | 0.05013 |
69
- | model | 28 | 0.33824 | 0.01208 |
70
- | ./spec/administrate | 5 | 0.06623 | 0.01325 |
71
- | helper | 7 | 0.02385 | 0.00341 |
72
- | ./spec/dashboards | 9 | 0.01684 | 0.00187 |
73
- +---------------------+---------------+--------------+-------------------------+
74
-
75
- +-------------------------------------------------------------+---------------+--------------+-------------------------+
76
- | Summary by File |
77
- +-------------------------------------------------------------+---------------+--------------+-------------------------+
60
+ |---------------------|---------------|--------------|-------------------------|
61
+ | feature | 72 | 9.28 | 0.12889 |
62
+ | generator | 65 | 1.83 | 0.0282 |
63
+ | controller | 32 | 1.69 | 0.05293 |
64
+ | view | 14 | 0.68246 | 0.04875 |
65
+ | ./spec/i18n_spec.rb | 2 | 0.58921 | 0.2946 |
66
+ | ./spec/lib | 79 | 0.33908 | 0.00429 |
67
+ | model | 28 | 0.29078 | 0.01038 |
68
+ | ./spec/administrate | 5 | 0.03813 | 0.00763 |
69
+ | ./spec/dashboards | 9 | 0.024 | 0.00267 |
70
+ | helper | 4 | 0.01062 | 0.00265 |
71
+
72
+
73
+ # Summary by File
74
+
78
75
  | File | Example count | Duration (s) | Average per example (s) |
79
- +-------------------------------------------------------------+---------------+--------------+-------------------------+
80
- | ./spec/features/index_page_spec.rb | 11 | 2.09 | 0.1899 |
81
- | ./spec/controllers/admin/blog/posts_controller_spec.rb | 16 | 1.64 | 0.1025 |
82
- | ./spec/features/orders_form_spec.rb | 7 | 1.28 | 0.1825 |
83
- | ./spec/i18n_spec.rb | 2 | 0.93344 | 0.46672 |
84
- | ./spec/generators/routes_generator_spec.rb | 8 | 0.87447 | 0.10931 |
85
- | ./spec/controllers/admin/log_entries_controller_spec.rb | 6 | 0.84819 | 0.14137 |
86
- | ./spec/generators/dashboard_generator_spec.rb | 21 | 0.8094 | 0.03854 |
87
- | ./spec/features/show_page_spec.rb | 9 | 0.79038 | 0.08782 |
88
- | ./spec/lib/fields/date_time_spec.rb | 8 | 0.703 | 0.08787 |
89
- | ./spec/features/orders_index_spec.rb | 6 | 0.67226 | 0.11204 |
90
- | ./spec/features/log_entries_index_spec.rb | 6 | 0.66303 | 0.11051 |
91
- | ./spec/features/search_spec.rb | 3 | 0.6555 | 0.2185 |
92
- | <abridged> | <abridged> | <abridged> | <abridged> |
93
- +-------------------------------------------------------------+---------------+--------------+-------------------------+
76
+ |-------------------------------------------------------------|---------------|--------------|-------------------------|
77
+ | ./spec/features/index_page_spec.rb | 11 | 2.76 | 0.25125 |
78
+ | ./spec/controllers/admin/customers_controller_spec.rb | 15 | 1.11 | 0.07432 |
79
+ | ./spec/features/form_errors_spec.rb | 2 | 1.1 | 0.54813 |
80
+ | ./spec/generators/dashboard_generator_spec.rb | 20 | 1.06 | 0.05293 |
81
+ | ./spec/features/orders_form_spec.rb | 7 | 1.01 | 0.14472 |
82
+ | ./spec/features/show_page_spec.rb | 10 | 0.67528 | 0.06753 |
83
+ | ./spec/i18n_spec.rb | 2 | 0.58921 | 0.2946 |
84
+ | ./spec/features/search_spec.rb | 3 | 0.57751 | 0.1925 |
85
+ | ./spec/features/orders_index_spec.rb | 6 | 0.57129 | 0.09521 |
86
+ | ./spec/features/products_index_spec.rb | 4 | 0.54049 | 0.13512 |
87
+ | <abridged> | | | |
94
88
 
95
89
  Randomized with seed 40301
96
90
  ```
@@ -1,5 +1,3 @@
1
- require "rspec_overview/formatter"
2
- require "rspec_overview/formatter_csv"
3
1
  require "rspec_overview/version"
4
2
 
5
3
  module RspecOverview
@@ -1,5 +1,5 @@
1
1
  require "rspec/core"
2
- require_relative "output/table"
2
+ require_relative "output/markdown_table"
3
3
  require_relative "result"
4
4
 
5
5
  module RspecOverview
@@ -43,12 +43,12 @@ module RspecOverview
43
43
  column_name, "Example count", "Duration (s)", "Average per example (s)"
44
44
  ]
45
45
 
46
- output_format.generate(
47
- output: output,
48
- title: "Summary by #{column_name}",
46
+ output.puts "\n# Summary by #{column_name}\n\n"
47
+ output.puts output_format.new(
49
48
  headings: headings,
50
49
  rows: results_as_rows(results),
51
50
  )
51
+ output.puts "\n"
52
52
  end
53
53
 
54
54
  def extract_subfolder(file_path)
@@ -63,7 +63,7 @@ module RspecOverview
63
63
  end
64
64
 
65
65
  def output_format
66
- RspecOverview::Output::Table.new
66
+ RspecOverview::Output::MarkdownTable
67
67
  end
68
68
  end
69
69
  end
@@ -1,3 +1,4 @@
1
+ require_relative "formatter"
1
2
  require_relative "output/csv"
2
3
 
3
4
  module RspecOverview
@@ -7,7 +8,7 @@ module RspecOverview
7
8
  private
8
9
 
9
10
  def output_format
10
- RspecOverview::Output::Csv.new
11
+ RspecOverview::Output::Csv
11
12
  end
12
13
  end
13
14
  end
@@ -3,17 +3,25 @@ require "csv"
3
3
  module RspecOverview
4
4
  module Output
5
5
  class Csv
6
- def generate(output:, title:, headings:, rows:)
7
- csv_string = CSV.generate(**csv_options, headers: headings) do |csv|
8
- rows.each { |row| csv << row }
9
- end
6
+ def initialize(headings:, rows:)
7
+ @headings = headings
8
+ @rows = rows
9
+ end
10
10
 
11
- output.puts title
12
- output.puts csv_string
11
+ def to_s
12
+ csv_content
13
13
  end
14
14
 
15
15
  private
16
16
 
17
+ attr_reader :headings, :rows
18
+
19
+ def csv_content
20
+ CSV.generate(**csv_options, headers: headings) do |csv|
21
+ rows.each { |row| csv << row }
22
+ end
23
+ end
24
+
17
25
  def csv_options
18
26
  { write_headers: true, force_quotes: true }
19
27
  end
@@ -0,0 +1,56 @@
1
+ require "matrix"
2
+
3
+ module RspecOverview
4
+ module Output
5
+ class MarkdownTable
6
+ BORDER_SEPERATOR = "|".freeze
7
+ NOT_BORDER_SEPERATOR = /[^#{BORDER_SEPERATOR}]/
8
+ HEADING_SEPERATOR = "-".freeze
9
+
10
+ def initialize(headings:, rows:)
11
+ @matrix = Matrix.rows([headings] + rows)
12
+ end
13
+
14
+ def to_s
15
+ render_table
16
+ end
17
+
18
+ def column(index)
19
+ matrix.column(index).to_a
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :matrix
25
+
26
+ def render_table
27
+ lines = matrix.row_vectors.map(&method(:render_row))
28
+ lines.insert(1, create_heading_divider(lines.first))
29
+ lines.join("\n") + "\n"
30
+ end
31
+
32
+ def render_row(data_row)
33
+ table_row = [BORDER_SEPERATOR]
34
+
35
+ data_row.each_with_index do |value, column_index|
36
+ table_row << " #{pad_value(value, column_index)} #{BORDER_SEPERATOR}"
37
+ end
38
+
39
+ table_row.join
40
+ end
41
+
42
+ def create_heading_divider(line)
43
+ line.gsub(NOT_BORDER_SEPERATOR, HEADING_SEPERATOR)
44
+ end
45
+
46
+ def pad_value(value, column_index)
47
+ column_width = width_of_column(column_index)
48
+ value.to_s.ljust(column_width, " ")
49
+ end
50
+
51
+ def width_of_column(index)
52
+ column(index).max_by{ |value| value.to_s.length }.length
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module RspecOverview
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "rspec-core", "~> 3.0"
23
- spec.add_dependency "terminal-table", "~> 1.6"
24
23
 
25
24
  spec.add_development_dependency "bundler", "~> 1.16"
26
25
  spec.add_development_dependency "pry-byebug", "~> 3.5"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_overview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oli Peate
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-09 00:00:00.000000000 Z
11
+ date: 2018-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
- - !ruby/object:Gem::Dependency
28
- name: terminal-table
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.6'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.6'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -117,7 +103,7 @@ files:
117
103
  - lib/rspec_overview/formatter.rb
118
104
  - lib/rspec_overview/formatter_csv.rb
119
105
  - lib/rspec_overview/output/csv.rb
120
- - lib/rspec_overview/output/table.rb
106
+ - lib/rspec_overview/output/markdown_table.rb
121
107
  - lib/rspec_overview/result.rb
122
108
  - lib/rspec_overview/version.rb
123
109
  - rspec_overview.gemspec
@@ -1,16 +0,0 @@
1
- require "terminal-table"
2
-
3
- module RspecOverview
4
- module Output
5
- class Table
6
- def generate(output:, title:, headings:, rows:)
7
- output.puts "\n"
8
- output.puts Terminal::Table.new(
9
- title: title,
10
- headings: headings,
11
- rows: rows,
12
- )
13
- end
14
- end
15
- end
16
- end