cuke_cataloger 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +104 -0
- data/LICENSE.txt +1 -1
- data/README.md +73 -13
- data/cuke_cataloger.gemspec +37 -16
- data/exe/cuke_cataloger +53 -0
- data/lib/cuke_cataloger/formatters/text_report_formatter.rb +38 -0
- data/lib/cuke_cataloger/rake_tasks.rb +51 -0
- data/lib/cuke_cataloger/unique_test_case_tagger.rb +180 -149
- data/lib/cuke_cataloger/version.rb +2 -1
- data/lib/cuke_cataloger.rb +6 -64
- data/testing/cucumber/features/cataloging_tasks.feature +48 -0
- data/testing/cucumber/features/formatting.feature +0 -3
- data/testing/cucumber/features/tag_indexing.feature +3 -3
- data/testing/cucumber/features/test_case_scanning_payload.feature +0 -2
- data/testing/cucumber/features/test_case_tagging.feature +2 -2
- data/testing/cucumber/features/test_case_validation.feature +3 -20
- metadata +125 -61
- data/.gitignore +0 -18
- data/.simplecov +0 -8
- data/.travis.yml +0 -35
- data/Gemfile +0 -22
- data/History.md +0 -39
- data/Rakefile +0 -35
- data/appveyor.yml +0 -69
- data/bin/cuke_cataloger +0 -68
- data/testing/cucumber/step_definitions/action_steps.rb +0 -42
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -69
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -207
- data/testing/cucumber/support/env.rb +0 -37
- data/testing/cucumber/support/transforms.rb +0 -3
- data/testing/fixtures/tests/foo.feature +0 -11
- data/testing/gemfiles/cuke_modeler0.gemfile +0 -21
- data/testing/gemfiles/cuke_modeler1.gemfile +0 -21
- data/testing/gemfiles/rake10.gemfile +0 -21
- data/testing/gemfiles/rake11.gemfile +0 -16
- data/testing/gemfiles/rake12.gemfile +0 -16
- data/testing/rspec/spec/cuke_cataloger_spec.rb +0 -22
- data/testing/rspec/spec/spec_helper.rb +0 -27
- data/testing/rspec/spec/unique_test_case_tagger_integration_spec.rb +0 -122
- data/testing/rspec/spec/unique_test_case_tagger_unit_spec.rb +0 -75
- data/todo.txt +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eb3fd5cae38ab765ef2915d216509608ce7bbf28767baf54b370bf19eff41c90
|
4
|
+
data.tar.gz: 040f1d882042efd4a4da63f8fbcbaa0d1b37ad3e3126b54a3beb809088dfa419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e57370bfb86b86f211c93641f0fba504279570612502d2dfce5d790c1c6061b93b2b4489bcacc4d206f51e9e748d0942633faba01a54cff1bf3ad785310cdd83
|
7
|
+
data.tar.gz: 3a48e9559901b71336a48adb65172de4d739975b3c883859ed5f184647ecc5bfb5ad2f703eb1b3f46697956e99224ecfd55b48efe9cef59783cce3392772c521
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
Nothing yet...
|
10
|
+
|
11
|
+
## [2.0.0] - 2022-02-05
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Added support for Ruby 3.x
|
16
|
+
|
17
|
+
### Removed
|
18
|
+
|
19
|
+
- Removed support for some older versions of the gem's dependencies:
|
20
|
+
- Ruby 1.x
|
21
|
+
- Rake 0.x
|
22
|
+
- CukeModeler 0.x
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- Test case IDs are no longer erroneously detected if a tag only partially matches the ID pattern. For example, the
|
27
|
+
gem would incorrectly identify `@test_case_123_plus_more` as an ID tag even though it was not one.
|
28
|
+
- Cataloging tests now correctly handles tests that are nested in rules. Previously, the presence of a `Rule`
|
29
|
+
keyword would cause new ID tags to be placed on the wrong lines in the cataloged file.
|
30
|
+
|
31
|
+
|
32
|
+
## [1.6.0] - 2020-06-21
|
33
|
+
|
34
|
+
### Added
|
35
|
+
- Support added for more versions of the `cuke_modeler` gem
|
36
|
+
- 3.x
|
37
|
+
- 2.x
|
38
|
+
|
39
|
+
- Support added for more versions of the `rake` gem
|
40
|
+
- 13.x
|
41
|
+
|
42
|
+
- Support added for more versions of the `thor` gem
|
43
|
+
- 1.x
|
44
|
+
|
45
|
+
## [1.5.0] - 2018-09-09
|
46
|
+
|
47
|
+
### Added
|
48
|
+
- The default cataloging prefix used by the Rake tasks is now also the default prefix used by the various object
|
49
|
+
based methods.
|
50
|
+
|
51
|
+
## [1.4.1] - 2017-07-09
|
52
|
+
|
53
|
+
### Changed
|
54
|
+
- Improved documentation
|
55
|
+
|
56
|
+
## [1.4.0] - 2017-04-18
|
57
|
+
|
58
|
+
### Added
|
59
|
+
- Both cataloging and validation can now be used without including outline rows, if desired.
|
60
|
+
- The column header used for outline row ids is now configurable.
|
61
|
+
|
62
|
+
## [1.3.1] - 2017-01-11
|
63
|
+
|
64
|
+
### Fixed
|
65
|
+
- Added missing shebang line to the gem's executable file.
|
66
|
+
|
67
|
+
## [1.3.0] - 2017-01-09
|
68
|
+
|
69
|
+
### Added
|
70
|
+
- Added an executable file for the gem so that it can be used without having to use Rake tasks.
|
71
|
+
- A basic cataloging location and prefix is used by default so that specifying these values will not be necessary in
|
72
|
+
many cases.
|
73
|
+
|
74
|
+
### Fixed
|
75
|
+
- Replaced non-Ruby 1.8.x compatible code so that the gem now correctly works with older versions of Ruby.
|
76
|
+
|
77
|
+
## [1.2.0] - 2016-10-02
|
78
|
+
|
79
|
+
### Added
|
80
|
+
- The gem now declares version limits on all of its dependencies.
|
81
|
+
- Added support for the 1.x series of the 'cuke_modeler' gem.
|
82
|
+
|
83
|
+
## [1.1.0] - 2016-02-21
|
84
|
+
|
85
|
+
### Added
|
86
|
+
- Upgraded to a more recent version of the 'cuke_modeler' gem and removed monkey patches that were
|
87
|
+
previously providing functionality that is now present in the newer version of 'cuke_modeler'
|
88
|
+
|
89
|
+
## [1.0.0] - 2015-10-05
|
90
|
+
|
91
|
+
- Initial release
|
92
|
+
|
93
|
+
|
94
|
+
[Unreleased]: https://github.com/enkessler/cuke_cataloger/compare/v2.0.0...HEAD
|
95
|
+
[2.0.0]: https://github.com/enkessler/cuke_cataloger/compare/v1.6.0...v2.0.0
|
96
|
+
[1.6.0]: https://github.com/enkessler/cuke_cataloger/compare/v1.5.0...v1.6.0
|
97
|
+
[1.5.0]: https://github.com/enkessler/cuke_cataloger/compare/v1.4.1...v1.5.0
|
98
|
+
[1.4.1]: https://github.com/enkessler/cuke_cataloger/compare/v1.4.0...v1.4.1
|
99
|
+
[1.4.0]: https://github.com/enkessler/cuke_cataloger/compare/v1.3.1...v1.4.0
|
100
|
+
[1.3.1]: https://github.com/enkessler/cuke_cataloger/compare/v1.3.0...v1.3.1
|
101
|
+
[1.3.0]: https://github.com/enkessler/cuke_cataloger/compare/v1.2.0...v1.3.0
|
102
|
+
[1.2.0]: https://github.com/enkessler/cuke_cataloger/compare/v1.1.0...v1.2.0
|
103
|
+
[1.1.0]: https://github.com/enkessler/cuke_cataloger/compare/v1.0.0...v1.1.0
|
104
|
+
[1.0.0]: https://github.com/enkessler/cuke_cataloger/compare/e2084caddc80886a3b6b8ff000f220e56ca92a05...v1.0.0
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,75 @@
|
|
1
|
-
|
1
|
+
Basic stuff:
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/cuke_cataloger.svg)](https://rubygems.org/gems/cuke_cataloger)
|
3
|
+
[![Project License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/mit-license.php)
|
4
|
+
[![Downloads](https://img.shields.io/gem/dt/cuke_cataloger.svg)](https://rubygems.org/gems/cuke_cataloger)
|
5
|
+
|
6
|
+
User stuff:
|
7
|
+
[![Cucumber Docs](http://img.shields.io/badge/Documentation-Features-green.svg)](https://github.com/enkessler/cuke_cataloger/tree/master/testing/cucumber/features)
|
8
|
+
[![Yard Docs](http://img.shields.io/badge/Documentation-API-blue.svg)](https://www.rubydoc.info/gems/cuke_cataloger)
|
9
|
+
|
10
|
+
Developer stuff:
|
11
|
+
[![Build Status](https://github.com/enkessler/cuke_cataloger/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/enkessler/cuke_cataloger/actions/workflows/ci.yml?query=branch%3Amaster)
|
12
|
+
[![Coverage Status](https://coveralls.io/repos/github/enkessler/cuke_cataloger/badge.svg?branch=master)](https://coveralls.io/github/enkessler/cuke_cataloger?branch=master)
|
13
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/662f0e7aa69bf9725515/maintainability)](https://codeclimate.com/github/enkessler/cuke_cataloger/maintainability)
|
14
|
+
[![Inline docs](http://inch-ci.org/github/enkessler/cuke_cataloger.svg?branch=master)](https://inch-ci.org/github/enkessler/cuke_cataloger)
|
15
|
+
|
16
|
+
|
17
|
+
---
|
2
18
|
|
3
19
|
|
4
|
-
|
5
|
-
[![Build Status](https://travis-ci.org/enkessler/cuke_cataloger.svg?branch=dev)](https://travis-ci.org/enkessler/cuke_cataloger)
|
6
|
-
[![Build status](https://ci.appveyor.com/api/projects/status/9a7gw3r5ddfugtf0/branch/dev?svg=true)](https://ci.appveyor.com/project/enkessler/cuke-cataloger/branch/dev)
|
7
|
-
[![Coverage Status](https://coveralls.io/repos/enkessler/cuke_cataloger/badge.svg?branch=dev&service=github)](https://coveralls.io/github/enkessler/cuke_cataloger?branch=dev)
|
8
|
-
[![Code Climate](https://codeclimate.com/github/enkessler/cuke_cataloger/badges/gpa.svg)](https://codeclimate.com/github/enkessler/cuke_cataloger)
|
9
|
-
[![Project License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/enkessler/cuke_cataloger/blob/master/LICENSE.txt)
|
20
|
+
# CukeCataloger
|
10
21
|
|
11
22
|
|
12
23
|
The cuke_cataloger gem is a convenient way to provide a unique id to every test case in your Cucumber test suite.
|
13
24
|
|
25
|
+
Turn your features from this
|
26
|
+
|
27
|
+
````
|
28
|
+
Feature:
|
29
|
+
|
30
|
+
Scenario:
|
31
|
+
* a step
|
32
|
+
|
33
|
+
Scenario Outline:
|
34
|
+
* a step
|
35
|
+
Examples:
|
36
|
+
| param 1 |
|
37
|
+
| value 1 |
|
38
|
+
Examples:
|
39
|
+
| param 1 |
|
40
|
+
| value 1 |
|
41
|
+
| value 2 |
|
42
|
+
|
43
|
+
Scenario:
|
44
|
+
* a step
|
45
|
+
````
|
46
|
+
|
47
|
+
into this!
|
48
|
+
|
49
|
+
````
|
50
|
+
Feature:
|
51
|
+
|
52
|
+
@test_case_1
|
53
|
+
Scenario:
|
54
|
+
* a step
|
55
|
+
|
56
|
+
@test_case_2
|
57
|
+
Scenario Outline:
|
58
|
+
* a step
|
59
|
+
Examples:
|
60
|
+
| param 1 | test_case_id |
|
61
|
+
| value 1 | 2-1 |
|
62
|
+
Examples:
|
63
|
+
| param 1 | test_case_id |
|
64
|
+
| value 1 | 2-2 |
|
65
|
+
| value 2 | 2-3 |
|
66
|
+
|
67
|
+
@test_case_3
|
68
|
+
Scenario:
|
69
|
+
* a step
|
70
|
+
````
|
71
|
+
|
72
|
+
|
14
73
|
## Installation
|
15
74
|
|
16
75
|
Add this line to your application's Gemfile:
|
@@ -104,11 +163,12 @@ By default, the cataloging and validation process uses `test_case_id` as the col
|
|
104
163
|
|
105
164
|
`Rake::Task['validate_tests'].invoke('./features','@test_case_',nil, true, 'my_special_column_id') # 5th argument is the id column name`
|
106
165
|
|
166
|
+
For more information and usage examples, see the documentation [here](https://github.com/enkessler/cuke_cataloger/tree/master/testing/cucumber/features).
|
167
|
+
|
168
|
+
## Development and Contributing
|
169
|
+
|
170
|
+
See [CONTRIBUTING.md](https://github.com/enkessler/cuke_cataloger/blob/master/CONTRIBUTING.md)
|
107
171
|
|
108
|
-
##
|
172
|
+
## License
|
109
173
|
|
110
|
-
|
111
|
-
2. Create your feature branch (off of the development branch) `git checkout -b my-new-feature`
|
112
|
-
3. Commit your changes `git commit -am 'Add some feature'`
|
113
|
-
4. Push to the branch `git push origin my-new-feature`
|
114
|
-
5. Create new Pull Request
|
174
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/cuke_cataloger.gemspec
CHANGED
@@ -1,32 +1,53 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'cuke_cataloger/version'
|
5
4
|
|
6
|
-
Gem::Specification.new do |spec|
|
5
|
+
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength - Gemspecs inherently have a lot of lines
|
7
6
|
spec.name = 'cuke_cataloger'
|
8
7
|
spec.version = CukeCataloger::VERSION
|
9
8
|
spec.authors = ['Eric Kessler']
|
10
9
|
spec.email = ['morrow748@gmail.com']
|
11
10
|
spec.summary = 'A tool to give every Cucumber test a unique id'
|
12
|
-
spec.description = 'Scans existing Cucumber tests and updates them to include an id tag that is unique for the
|
11
|
+
spec.description = ['Scans existing Cucumber tests and updates them to include an id tag that is unique for the ',
|
12
|
+
'test suite.'].join
|
13
13
|
spec.homepage = 'https://github.com/enkessler/cuke_cataloger'
|
14
14
|
spec.license = 'MIT'
|
15
|
+
spec.metadata = {
|
16
|
+
'bug_tracker_uri' => 'https://github.com/enkessler/cuke_cataloger/issues',
|
17
|
+
'changelog_uri' => 'https://github.com/enkessler/cuke_cataloger/blob/master/CHANGELOG.md',
|
18
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/cuke_cataloger',
|
19
|
+
'homepage_uri' => 'https://github.com/enkessler/cuke_cataloger',
|
20
|
+
'source_code_uri' => 'https://github.com/enkessler/cuke_cataloger'
|
21
|
+
}
|
15
22
|
|
16
|
-
|
17
|
-
|
18
|
-
spec.
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path('', __dir__)) do
|
26
|
+
source_controlled_files = `git ls-files -z`.split("\x0")
|
27
|
+
source_controlled_files.keep_if { |file| file =~ %r{^(lib|exe|testing/cucumber/features)} }
|
28
|
+
source_controlled_files + ['README.md', 'LICENSE.txt', 'CHANGELOG.md', 'cuke_cataloger.gemspec']
|
29
|
+
end
|
30
|
+
|
31
|
+
spec.bindir = 'exe'
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
33
|
spec.require_paths = ['lib']
|
20
34
|
|
21
|
-
spec.
|
22
|
-
|
23
|
-
spec.add_runtime_dependency '
|
24
|
-
spec.add_runtime_dependency '
|
35
|
+
spec.required_ruby_version = '>= 2.0', '< 4.0'
|
36
|
+
|
37
|
+
spec.add_runtime_dependency 'cuke_modeler', '>= 1.0', '< 4.0'
|
38
|
+
spec.add_runtime_dependency 'cql', '>= 1.0.1', '< 2.0'
|
39
|
+
spec.add_runtime_dependency 'rake', '>=10.0', '< 14.0'
|
40
|
+
spec.add_runtime_dependency 'thor', '< 2.0'
|
25
41
|
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.add_development_dependency '
|
42
|
+
spec.add_development_dependency 'childprocess', '< 5.0'
|
43
|
+
spec.add_development_dependency 'ffi', '< 2.0' # This is an invisible dependency for the `childprocess` gem on Windows
|
44
|
+
spec.add_development_dependency 'bundler', '< 3'
|
45
|
+
spec.add_development_dependency 'cucumber', '< 4.0'
|
28
46
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
-
spec.add_development_dependency '
|
30
|
-
spec.add_development_dependency 'simplecov', '< 1.0'
|
31
|
-
spec.add_development_dependency '
|
47
|
+
spec.add_development_dependency 'simplecov', '~> 0.18'
|
48
|
+
spec.add_development_dependency 'simplecov-lcov', '< 1.0'
|
49
|
+
spec.add_development_dependency 'rainbow', '< 4.0.0'
|
50
|
+
spec.add_development_dependency 'rubocop', '<= 0.50.0' # RuboCop can not lint against Ruby 2.0 after this version
|
51
|
+
spec.add_development_dependency 'yard', '< 1.0'
|
52
|
+
spec.add_development_dependency 'pry', '< 0.14'
|
32
53
|
end
|
data/exe/cuke_cataloger
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'cuke_cataloger'
|
5
|
+
|
6
|
+
# The Command Line Interface for the gem
|
7
|
+
class CLI < Thor
|
8
|
+
|
9
|
+
desc 'catalog_test_cases',
|
10
|
+
'Catalog the test cases in LOCATION with an id based on PREFIX'
|
11
|
+
option :location, default: '.'
|
12
|
+
option :prefix, default: '@test_case_'
|
13
|
+
option :row_id, type: :boolean, default: true
|
14
|
+
option :id_column_name, default: 'test_case_id'
|
15
|
+
|
16
|
+
def catalog_test_cases # rubocop:disable Metrics/AbcSize - Seems to be reporting high for some reason
|
17
|
+
puts "Tagging tests in '#{options[:location]}' with tag '#{options[:prefix]}'\n"
|
18
|
+
puts "Including outline rows\n" if options[:row_id]
|
19
|
+
|
20
|
+
tagger = CukeCataloger::UniqueTestCaseTagger.new
|
21
|
+
tagger.tag_tests(options[:location], options[:prefix], {}, options[:row_id], options[:id_column_name])
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'validate_test_cases',
|
25
|
+
'Validate the test cases in LOCATION with an id based on PREFIX. Will output the report to FILE, if provided.'
|
26
|
+
option :location, default: '.'
|
27
|
+
option :prefix, default: '@test_case_'
|
28
|
+
option :row_id, type: :boolean, default: true
|
29
|
+
option :id_column_name, default: 'test_case_id'
|
30
|
+
option :file
|
31
|
+
|
32
|
+
def validate_test_cases # rubocop:disable Metrics/AbcSize - Seems to be reporting high for some reason
|
33
|
+
puts "Validating tests in '#{options[:location]}' with tag '#{options[:prefix]}'\n"
|
34
|
+
puts "Including outline rows\n" if options[:row_id]
|
35
|
+
|
36
|
+
results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(options[:location],
|
37
|
+
options[:prefix],
|
38
|
+
options[:row_id],
|
39
|
+
options[:id_column_name])
|
40
|
+
report_text = CukeCataloger::TextReportFormatter.new.format_data(results)
|
41
|
+
|
42
|
+
if options[:file]
|
43
|
+
puts "Problems found: #{results.count}"
|
44
|
+
File.open(options[:file], 'w') { |file| file.write(report_text) }
|
45
|
+
else
|
46
|
+
puts report_text
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
CLI.start(ARGV)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# TODO: have better testing so that this can be safely refactored
|
2
|
+
# rubocop:disable Metrics/AbcSize - Not going to mess with this, given how little testing is present
|
3
|
+
|
4
|
+
module CukeCataloger
|
5
|
+
|
6
|
+
# Not a part of the public API. Subject to change at any time.
|
7
|
+
class TextReportFormatter
|
8
|
+
|
9
|
+
# Formats validation results into a readable text report
|
10
|
+
def format_data(data)
|
11
|
+
report_text = "Validation Results\nProblems found: #{data.count}\n\n"
|
12
|
+
|
13
|
+
|
14
|
+
results_by_category = Hash.new { |hash, key| hash[key] = [] }
|
15
|
+
|
16
|
+
data.each do |result|
|
17
|
+
results_by_category[result[:problem]] << result
|
18
|
+
end
|
19
|
+
|
20
|
+
results_by_category.each_key do |problem_category|
|
21
|
+
report_text << "#{problem_category} problems: #{results_by_category[problem_category].count}\n"
|
22
|
+
end
|
23
|
+
|
24
|
+
results_by_category.each_key do |problem_category|
|
25
|
+
report_text << "\n\n#{problem_category} problems (#{results_by_category[problem_category].count}):\n"
|
26
|
+
|
27
|
+
results_by_category[problem_category].each do |result|
|
28
|
+
report_text << "#{result[:test]}\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
report_text
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# rubocop:enable Metrics/AbcSize
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# TODO: have better testing so that this can be safely refactored
|
2
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/LineLength, Metrics/MethodLength, Metrics/PerceivedComplexity - Not going to mess with this, given how little testing is present
|
3
|
+
|
4
|
+
|
5
|
+
# The top level namespace used by this gem
|
6
|
+
module CukeCataloger
|
7
|
+
|
8
|
+
extend Rake::DSL
|
9
|
+
|
10
|
+
|
11
|
+
# Adds the gem's provided Rake tasks to the namespace from which the method is called
|
12
|
+
def self.create_tasks
|
13
|
+
desc 'Add unique id tags to tests in the given directory'
|
14
|
+
task 'tag_tests', [:directory, :prefix, :row_id, :id_column_name] do |_t, args|
|
15
|
+
location = args[:directory] || '.'
|
16
|
+
prefix = args[:prefix] || '@test_case_'
|
17
|
+
tag_rows = args[:row_id].nil? ? true : args[:row_id]
|
18
|
+
id_column_name = args[:id_column_name] || 'test_case_id'
|
19
|
+
|
20
|
+
puts "Tagging tests in '#{location}' with tag '#{prefix}'\n"
|
21
|
+
puts "Including outline rows\n" if tag_rows
|
22
|
+
|
23
|
+
tagger = CukeCataloger::UniqueTestCaseTagger.new
|
24
|
+
tagger.tag_tests(location, prefix, {}, tag_rows, id_column_name)
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Scan tests in the given directory for id problems'
|
28
|
+
task 'validate_tests', [:directory, :prefix, :out_file, :row_id, :id_column_name] do |_t, args|
|
29
|
+
location = args[:directory] || '.'
|
30
|
+
prefix = args[:prefix] || '@test_case_'
|
31
|
+
tag_rows = args[:row_id].nil? ? true : args[:row_id]
|
32
|
+
id_column_name = args[:id_column_name] || 'test_case_id'
|
33
|
+
|
34
|
+
puts "Validating tests in '#{location}' with tag '#{prefix}'\n"
|
35
|
+
puts "Including outline rows\n" if tag_rows
|
36
|
+
|
37
|
+
results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(location, prefix, tag_rows, id_column_name)
|
38
|
+
report_text = CukeCataloger::TextReportFormatter.new.format_data(results)
|
39
|
+
|
40
|
+
if args[:out_file]
|
41
|
+
puts "Problems found: #{results.count}"
|
42
|
+
File.open(args[:out_file], 'w') { |file| file.write(report_text) }
|
43
|
+
else
|
44
|
+
puts report_text
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/LineLength, Metrics/MethodLength, Metrics/PerceivedComplexity
|