spec_selector 0.1.4 → 0.1.8

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: 80ae5c42cb85a3c4b3e8f0c03dc798f8e5f15e7f381d9b62266914aa470379a9
4
- data.tar.gz: c062e730cead5ff989daaea538b610f692adf9329fcf997aad8da0e5fc53add8
3
+ metadata.gz: d5ebcfc2cf3d1b1779bab9de9470bf160c00566c830cebaf290c44f26ba7351b
4
+ data.tar.gz: e80c880103bf8f7cc80701804fe227bff7d3c4de6cad50208c31a00ae6924ec4
5
5
  SHA512:
6
- metadata.gz: 152df563a0e99607d8e24954e16dab41d7e8e6db49c29d97ea0087a6827431a5d38b7739ba880f7e08db15e6d4ee29c849bc412a615934e52e481186acbcbe07
7
- data.tar.gz: 7fa3821bea0d8e20a6eeb5c562e5bec887d7bcdd767110733321c4652ed68b4cf192aaf9c15422d5df09e5ca26d21e2ba23b5d6c2b37c4eeb256bc64b6977cea
6
+ metadata.gz: f0a033f8cdc4a013e303ddfb00e942c117cca3a887792be54e7cc04e63561eb836f88b1e728b8fb7845fc2f9a6979a926d061df9d75f1db098a5de4e203e410d
7
+ data.tar.gz: f463910ca22286b2b605d08d29894004bdea3319e4f4c6b6b89412400a1dfb0576406ee76bbadf068d706638e655c0b7b007c2a512ca4cda523e417023319353
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -2,20 +2,26 @@
2
2
 
3
3
  SpecSelector is an RSpec formatter that opens a utility menu in your terminal window when you run tests (rather than just printing static text). The utility allows you to select, view, filter, and rerun specific test results with simple key controls.
4
4
 
5
- **view test results**
5
+ <br>
6
6
 
7
- Upon finishing the test run, the test result tree appears as a formatted list of top-level example groups. Select an example group to view its subgroups, select a subgroup to view its examples, and so on. You can view your test results with the selection tool, or just press T to immediately view the top failed test.
7
+ **View test results**
8
8
 
9
- **filter and rerun test results**
9
+ Upon finishing the test run, the test result tree appears as a formatted list of top-level example groups. Select an example group to view its subgroups, select a subgroup to view its examples, and so on. You can view your test results with the selection tool, or just press t to immediately view the top failed test.
10
+
11
+ <br>
12
+
13
+ **Filter and rerun test results**
10
14
 
11
15
  Using the selection tool, press M to add the selected group or example to the inclusion filter. Press R to rerun RSpec with only selected tests.
12
16
 
13
- Without using the selection tool, press F to rerun only failed tests. Press SHIFT + T to rerun only the top failed test.
17
+ Without using the selection tool, press F to rerun only failed tests. Press T to rerun only the top failed test.
14
18
 
15
19
  Press C to clear the inclusion filter. Press A to clear the inclusion filter and rerun RSpec with all tests.
16
20
 
17
21
  Press V to view the inclusion filter as a selection list.
18
22
 
23
+ <br>
24
+
19
25
  _Filter Modes_
20
26
 
21
27
  Whenever the inclusion filter is not empty, the filter mode will display at the top center of the terminal window.
@@ -24,6 +30,40 @@ There are two filter modes: _description_ and _location_.
24
30
 
25
31
  The filter always uses description matching by default, but will use location (line number) matching if examples without descriptions (i.e. "one-liners") are selected for inclusion.
26
32
 
33
+ <br>
34
+
35
+ **Usage notes**
36
+
37
+ _Text color_
38
+
39
+ An example description will appear in red text if the example failed, yellow text if the example is pending, or green text if the example passed.
40
+
41
+ The color of an example group description is determined by the result status of its examples or recursively by the examples of its subgroups. The description will appear in red text if at least one failed example is present in its tree (e.g. if it contains a subgroup that contains a failed example), yellow text if its tree contains no failed examples and at least one pending example, or green text if every example in its tree passed.
42
+
43
+ <br>
44
+
45
+ _key controls_
46
+
47
+ Key control | Description
48
+ ------------|--------------
49
+ | BACKSPACE | View the list that contains the parent of the current list or example result summary.|
50
+ | ENTER/RETURN | Select an example group or example from the result list.|
51
+ | ESCAPE | Return to the top-level result list. If already viewing the top-level list, the escape key has no effect.|
52
+ | SPACEBAR | View the top failed example result summary from the current result set. |
53
+ | UP/DOWN | Navigate up and down the result list, or, if viewing an example result summary, view the next or previous example result summary.|
54
+ | A | Clear the inclusion filter and rerun RSpec with all examples.|
55
+ | C | Clear the inclusion filter.|
56
+ | F | Rerun RSpec with only failed examples from the current result set. |
57
+ | I | View or exit instructions.|
58
+ | M | Include or remove an example or example group from the inclusion filter. |
59
+ | P | Hide or reveal passing examples in the current result set. |
60
+ | R | Rerun RSpec with only examples and example groups marked for inclusion. |
61
+ | T | Rerun RSpec with only the top failed example from the current result set. |
62
+ | V | View the inclusion filter as a list. |
63
+ | Q | Exit spec_selector. |
64
+
65
+ <br>
66
+
27
67
  **Installation**
28
68
 
29
69
  ````
@@ -41,6 +81,9 @@ Or, use the -f option on the command line
41
81
  ````
42
82
  rspec -f SpecSelector
43
83
  ````
84
+
85
+ <br>
86
+ <br>
44
87
 
45
88
 
46
89
 
@@ -99,7 +99,7 @@ module SpecSelectorUtil
99
99
  empty_line
100
100
  bold('Press F to rerun only failed examples')
101
101
  empty_line
102
- bold('Press SHIFT + T to rerun only the top failed example')
102
+ bold('Press T to rerun only the top failed example')
103
103
  empty_line
104
104
  bold('Press M to include or remove selected item from run filter')
105
105
  empty_line
@@ -118,7 +118,7 @@ module SpecSelectorUtil
118
118
  end
119
119
 
120
120
  def top_fail_text
121
- bold 'Press T to view top failed example'
121
+ bold 'Press [spacebar] to view top failed example'
122
122
  end
123
123
 
124
124
  def exit_instruction_page
@@ -127,6 +127,7 @@ module SpecSelectorUtil
127
127
  end
128
128
 
129
129
  def top_fail!
130
+ return if @failed.empty?
130
131
  @inclusion_filter = []
131
132
  filter_include(@failed.first)
132
133
  rerun
@@ -6,12 +6,12 @@ module SpecSelectorUtil
6
6
  DIRECTION_KEYS = ["\e[A", "\e[B"].freeze
7
7
  TREE_NAVIGATION_KEYS = ["\r", "\x7F", "\e"].freeze
8
8
  OPTION_KEYS = [
9
- /t/i, /f/i, /p/i, /q/i, /i/i, /r/i, /m/i, /c/i, /a/i, /v/i
9
+ /^t$/i, /^f$/i, /^p$/i, /^q$/i, /^i$/i, /^r$/i, /^m$/i, /^c$/i, /^a$/i, /^v$/i, /^ $/
10
10
  ].freeze
11
11
 
12
12
  def exit_only
13
13
  q_to_exit
14
- loop { quit if user_input.match?(/q/i) }
14
+ loop { quit if user_input.match?(/^q$/i) }
15
15
  end
16
16
 
17
17
  def selector
@@ -125,35 +125,35 @@ module SpecSelectorUtil
125
125
 
126
126
  def option_keys(input)
127
127
  case input
128
- when /T/
128
+ when /^t$/i
129
129
  top_fail!
130
- when /t/
130
+ when /^ $/
131
131
  top_fail
132
- when /p/i
132
+ when /^p$/i
133
133
  toggle_passing
134
- when /f/i
134
+ when /^f$/i
135
135
  run_only_fails
136
- when /q/i
136
+ when /^q$/i
137
137
  quit
138
- when /i/i
138
+ when /^i$/i
139
139
  unless @instructions
140
140
  view_instructions_page
141
141
  return
142
142
  end
143
143
 
144
144
  exit_instruction_page_only
145
- when /r/i
145
+ when /^r$/i
146
146
  rerun
147
147
  when /^a$/i
148
148
  rerun_all
149
- when /m/i
149
+ when /^m$/i
150
150
  return if @instructions
151
151
 
152
152
  @selected.metadata[:include] ? filter_remove : filter_include
153
153
  refresh_display
154
154
  when /^c$/i
155
155
  clear_filter
156
- when /v/i
156
+ when /^v$/i
157
157
  view_inclusion_filter
158
158
  end
159
159
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spec_selector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Almon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -34,28 +34,22 @@ cert_chain:
34
34
  2oaEU1xxH+4n3qzECM32PIry9QVrTud/3/ouDLy4LVVyutD5ZANsVQrr0y8vEA6+
35
35
  OXcnI0Yc8EI4dmIAwDI0ZfBo2OgFBxNJCeurVx36tUPsSWjJUd0BeA==
36
36
  -----END CERTIFICATE-----
37
- date: 2021-02-28 00:00:00.000000000 Z
37
+ date: 2021-12-29 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: rspec
41
41
  requirement: !ruby/object:Gem::Requirement
42
42
  requirements:
43
- - - ">="
43
+ - - "~>"
44
44
  - !ruby/object:Gem::Version
45
- version: 3.0.0
46
- - - "<"
47
- - !ruby/object:Gem::Version
48
- version: '4'
45
+ version: '3.0'
49
46
  type: :runtime
50
47
  prerelease: false
51
48
  version_requirements: !ruby/object:Gem::Requirement
52
49
  requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 3.0.0
56
- - - "<"
50
+ - - "~>"
57
51
  - !ruby/object:Gem::Version
58
- version: '4'
52
+ version: '3.0'
59
53
  description: " SpecSelector is an RSpec formatter that opens a utility \n menu in
60
54
  your terminal window when you run tests (rather \n than just printing static text).
61
55
  The utility allows you to \n select, view, filter, and rerun specific test results
@@ -78,23 +72,14 @@ files:
78
72
  - lib/spec_selector/terminal.rb
79
73
  - lib/spec_selector/ui.rb
80
74
  - license.md
81
- - spec/factories.rb
82
- - spec/shared.rb
83
- - spec/spec_helper.rb
84
- - spec/spec_selector_spec.rb
85
- - spec/spec_selector_util/data_map_spec.rb
86
- - spec/spec_selector_util/data_presentation_spec.rb
87
- - spec/spec_selector_util/format_spec.rb
88
- - spec/spec_selector_util/helpers_spec.rb
89
- - spec/spec_selector_util/initialize_spec.rb
90
- - spec/spec_selector_util/ui_spec.rb
91
75
  homepage: https://github.com/TrevorA-TrevorA/spec_selector
92
76
  licenses:
93
77
  - MIT
94
78
  metadata:
95
79
  source_code_uri: https://github.com/TrevorA-TrevorA/spec_selector
96
80
  homepage_uri: https://github.com/TrevorA-TrevorA/spec_selector
97
- post_install_message:
81
+ changelog_uri: https://github.com/TrevorA-TrevorA/spec_selector/blob/master/CHANGELOG.md
82
+ post_install_message:
98
83
  rdoc_options: []
99
84
  require_paths:
100
85
  - lib
@@ -109,8 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
94
  - !ruby/object:Gem::Version
110
95
  version: '0'
111
96
  requirements: []
112
- rubygems_version: 3.0.3
113
- signing_key:
97
+ rubygems_version: 3.2.21
98
+ signing_key:
114
99
  specification_version: 4
115
100
  summary: A results viewer and filter utility for RSpec
116
101
  test_files: []
metadata.gz.sig CHANGED
Binary file
data/spec/factories.rb DELETED
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TestObjects
4
- RSN = RSpec::Core::Notifications
5
-
6
- class Example < RSpec::Core::Example
7
- attr_accessor :metadata, :execution_result, :description, :example_group
8
-
9
- def initialize
10
- end
11
- end
12
-
13
- class ExecutionResult < RSpec::Core::Example::ExecutionResult
14
- attr_accessor :status
15
- end
16
-
17
- class ExampleGroup < RSpec::Core::ExampleGroup
18
- attr_accessor :examples, :metadata, :description
19
- end
20
-
21
- class SummaryNotification < RSN::SummaryNotification
22
- attr_accessor :example_count,
23
- :duration,
24
- :load_time,
25
- :errors_outside_of_example_count
26
-
27
- :examples
28
- end
29
-
30
- class SkippedExampleNotification < RSN::SkippedExampleNotification
31
- attr_accessor :example
32
-
33
- def fully_formatted(_)
34
- "\npending example"
35
- end
36
- end
37
-
38
- class FailedExampleNotification < RSN::FailedExampleNotification
39
- attr_accessor :example
40
-
41
- def initialize
42
- end
43
-
44
- def fully_formatted(_)
45
- "\nfailed example"
46
- end
47
- end
48
- end
49
-
50
- FactoryBot.define do
51
- factory :execution_result, class: 'TestObjects::ExecutionResult' do
52
- status { :passed }
53
- end
54
-
55
- factory :example, class: 'TestObjects::Example' do
56
- execution_result { build(:execution_result) }
57
- description { 'passed' }
58
- metadata { {} }
59
- end
60
-
61
- factory :example_group, class: 'TestObjects::ExampleGroup' do
62
- examples { [build(:example)] }
63
- metadata { { block: self } }
64
- description do
65
- if examples.all? { |ex| ex.execution_result.status == :passed }
66
- 'passing example group'
67
- else
68
- 'non-passing example group'
69
- end
70
- end
71
- end
72
-
73
- factory :summary_notification, class: 'TestObjects::SummaryNotification' do
74
- example_count { 25 }
75
- duration { 1.5 }
76
- load_time { 0.5 }
77
- errors_outside_of_examples_count { 0 }
78
- end
79
-
80
- factory :skipped_example_notification,
81
- class: 'TestObjects::SkippedExampleNotification' do
82
- example
83
- end
84
-
85
- factory :failed_example_notification,
86
- class: 'TestObjects::FailedExampleNotification' do
87
- example
88
- end
89
- end
data/spec/shared.rb DELETED
@@ -1,145 +0,0 @@
1
- RSpec.shared_context 'shared' do
2
- let(:spec_selector) { SpecSelector.new(StringIO.new) }
3
- let(:output) { spec_selector.ivar(:@output).string }
4
- let(:fail_result) { build(:execution_result, status: :failed) }
5
- let(:pending_result) { build(:execution_result, status: :pending) }
6
- let(:failed_example) { build(:example, execution_result: fail_result, metadata: { description: 'failed_example' }) }
7
- let(:pending_example) do
8
- build(:example, execution_result: pending_result, metadata: { description: 'pending_example' })
9
- end
10
- let(:passing_example) do
11
- build(:example, metadata: { description: 'passing_example' }, description: 'passing_example')
12
- end
13
- let(:pass_group) do
14
- build(:example_group, examples: [build(:example), build(:example)], metadata: { description: 'pass_group' })
15
- end
16
- let(:fail_group) { build(:example_group, examples: [failed_example, failed_example]) }
17
- let(:pending_group) do
18
- build(:example_group, examples: [pending_example, pending_example], metadata: { description: 'pending_group' })
19
- end
20
- let(:mixed_result_group) { build(:example_group, examples: [passing_example, failed_example, pending_example]) }
21
- let(:fail_subgroup) do
22
- build(
23
- :example_group,
24
- metadata: {
25
- parent_example_group: {}
26
- },
27
- examples: [failed_example, failed_example]
28
- )
29
- end
30
-
31
- let(:pending_subgroup) do
32
- build(
33
- :example_group,
34
- metadata: {
35
- parent_example_group: {}
36
- },
37
- examples: [pending_example, pending_example]
38
- )
39
- end
40
-
41
- let(:fail_parent_group) { build(:example_group, examples: [], metadata: { description: 'fail_parent_group' }) }
42
- let(:pending_parent_group) { build(:example_group, examples: [], metadata: { description: 'pending_parent_group' }) }
43
- let(:pass_subgroup) do
44
- build(
45
- :example_group,
46
- metadata: { parent_example_group: pass_parent_group.metadata, description: 'pass_subgroup' },
47
- examples: [passing_example, passing_example]
48
- )
49
- end
50
-
51
- let(:pass_parent_group) { build(:example_group, examples: [], metadata: { description: 'pass_parent_group' }) }
52
- let(:mixed_list) { [pass_group, fail_group] }
53
- let(:mixed_map) do
54
- {
55
- :top_level => [pass_group, fail_group],
56
- pass_group.metadata[:block] => pass_group.examples,
57
- fail_group.metadata[:block] => fail_group.examples
58
- }
59
- end
60
-
61
- let(:pending_map) do
62
- {
63
- :top_level => [pending_group],
64
- pending_group.metadata[:block] => pending_group.examples
65
- }
66
- end
67
-
68
- let(:deep_map) do
69
- {
70
- :top_level => [pending_parent_group, pass_parent_group, fail_parent_group],
71
- pending_parent_group.metadata[:block] => [pending_subgroup],
72
- pass_parent_group.metadata[:block] => [pass_subgroup],
73
- fail_parent_group.metadata[:block] => [fail_subgroup],
74
- pending_subgroup.metadata[:block] => pending_subgroup.examples,
75
- pass_subgroup.metadata[:block] => pass_subgroup.examples,
76
- fail_subgroup.metadata[:block] => fail_subgroup.examples
77
- }
78
- end
79
-
80
- let(:all_passing_map) do
81
- {
82
- top_level: [pass_group, pass_group],
83
- pass_group.metadata[:block] => pass_group.examples,
84
- pass_group.metadata[:block] => pass_group.examples
85
- }
86
- end
87
-
88
- def allow_methods(*methods)
89
- methods.each do |method|
90
- allow(spec_selector).to receive(method)
91
- end
92
- end
93
-
94
- def ivars_set(ivar_hash)
95
- ivar_hash.each do |ivar, value|
96
- spec_selector.ivar_set(ivar, value)
97
- end
98
- end
99
-
100
- def ivar_set(sym, value)
101
- spec_selector.ivar_set(sym, value)
102
- end
103
-
104
- def ivar(sym)
105
- spec_selector.ivar(sym)
106
- end
107
-
108
- def more_data?(readable)
109
- IO.select([readable], nil, nil, 0.000001)
110
- end
111
-
112
- def summary_settings(example)
113
- case example
114
- when failed_example
115
- notification_type = :failed_example_notification
116
- summary_list = :@failure_summaries
117
- ivar = :@failed
118
- when pending_example
119
- notification_type = :skipped_example_notification
120
- summary_list = :@pending_summaries
121
- ivar = :@pending
122
- end
123
-
124
- ivars_set(:@selected => example, ivar => [example])
125
- notification = build(notification_type, example: example)
126
- spec_selector.ivar(summary_list)[example] = notification
127
- end
128
-
129
- def expect_full_instructions_to_be_displayed
130
- expect(output).to include('Press I to hide instructions')
131
- expect(output).to include('Press F to exclude passing examples')
132
- expect(output).to include('Press ↑ or ↓ to navigate list')
133
- expect(output).to include('Press [enter] to select')
134
- expect(output).to include('Press Q to exit')
135
- end
136
-
137
- def expect_full_instructions_to_be_hidden
138
- expect(output).to include('Press I to view instructions')
139
- expect(output).not_to include('Press I to hide instructions')
140
- expect(output).not_to include('Press F to exclude passing examples')
141
- expect(output).not_to include('Press ↑ or ↓ to navigate list')
142
- expect(output).not_to include('Press [enter] to select')
143
- expect(output).not_to include('Press Q to exit')
144
- end
145
- end
data/spec/spec_helper.rb DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_selector'
4
- require 'stringio'
5
- require 'factory_bot'
6
- require 'timeout'
7
- require 'shared'
8
-
9
- RCN = RSpec::Core::Notifications
10
- EXAMPLE_STUBS = { description: 'description',
11
- execution_result: 'result',
12
- full_description: 'full_description' }.freeze
13
-
14
- alias ivar instance_variable_get
15
- alias ivar_set instance_variable_set
16
-
17
- RSpec.configure do |config|
18
- config.expect_with :rspec do |expectations|
19
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
20
- end
21
-
22
- config.filter_run_when_matching :focus
23
-
24
- config.mock_with :rspec do |mocks|
25
- mocks.verify_partial_doubles = true
26
- end
27
-
28
- config.shared_context_metadata_behavior = :apply_to_host_groups
29
-
30
- config.include_context 'shared', include_shared: true
31
-
32
- config.include FactoryBot::Syntax::Methods
33
-
34
- config.before(:suite) do
35
- FactoryBot.find_definitions
36
- end
37
-
38
- config.around(:example, break_loop: true) do |example|
39
- begin
40
- Timeout.timeout(0.001) do
41
- example.run
42
- end
43
- rescue Timeout::Error
44
- nil
45
- end
46
- end
47
- end