cuke_cataloger 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.simplecov +8 -0
- data/.travis.yml +9 -0
- data/Gemfile +17 -0
- data/History.md +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +67 -0
- data/Rakefile +26 -0
- data/cuke_cataloger.gemspec +32 -0
- data/features/formatting.feature +191 -0
- data/features/step_definitions/action_steps.rb +28 -0
- data/features/step_definitions/setup_steps.rb +56 -0
- data/features/step_definitions/verification_steps.rb +162 -0
- data/features/support/env.rb +22 -0
- data/features/support/transforms.rb +3 -0
- data/features/tag_indexing.feature +362 -0
- data/features/test_case_scanning.feature +59 -0
- data/features/test_case_scanning_payload.feature +32 -0
- data/features/test_case_tagging.feature +193 -0
- data/features/test_case_validation.feature +368 -0
- data/lib/cuke_cataloger/unique_test_case_tagger.rb +555 -0
- data/lib/cuke_cataloger/version.rb +3 -0
- data/lib/cuke_cataloger.rb +60 -0
- data/lib/extensions/cucumber_analytics_extensions.rb +44 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/unique_test_case_tagger_integration_spec.rb +85 -0
- data/spec/unique_test_case_tagger_unit_spec.rb +74 -0
- metadata +255 -0
data/.gitignore
ADDED
data/.simplecov
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in cuke_cataloger.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
|
7
|
+
if RUBY_VERSION =~ /^1\.8/
|
8
|
+
gem 'cucumber', '<1.3.0'
|
9
|
+
gem 'gherkin', '<2.12.0'
|
10
|
+
gem 'mime-types', '<2.0.0'
|
11
|
+
gem 'rest-client', '<1.7.0'
|
12
|
+
elsif RUBY_VERSION =~ /^1\./
|
13
|
+
gem 'cucumber', '<2.0.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
gem 'coveralls', :require => false, :group => :development
|
data/History.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Eric Kessler
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# CukeCataloger
|
2
|
+
|
3
|
+
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/cuke_cataloger.svg)](http://badge.fury.io/rb/cuke_cataloger)
|
5
|
+
[![Build Status](https://travis-ci.org/enkessler/cuke_cataloger.svg?branch=master)](https://travis-ci.org/enkessler/cuke_cataloger)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/enkessler/cuke_cataloger/badge.svg?branch=master&service=github)](https://coveralls.io/github/enkessler/cuke_cataloger?branch=master)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/enkessler/cuke_cataloger/badges/gpa.svg)](https://codeclimate.com/github/enkessler/cuke_cataloger)
|
8
|
+
[![Project License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/enkessler/cuke_cataloger/blob/master/LICENSE.txt)
|
9
|
+
|
10
|
+
|
11
|
+
The cuke_cataloger gem is a convenient way to provide a unique id to every test case in your Cucumber test suite.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'cuke_cataloger'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install cuke_cataloger
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
The simplest way to use this gem is to include the Rake tasks that it provides in your project. Just require the gem
|
30
|
+
|
31
|
+
require 'cuke_cataloger'
|
32
|
+
|
33
|
+
and then call its task creation method in your Rakefile (or wherever you like to keep your Rake tasks) in order to generate the tasks.
|
34
|
+
|
35
|
+
CukeCataloger.create_tasks
|
36
|
+
|
37
|
+
If you want the tasks to be created in a certain namespace, simply call the creation method from within that namespace.
|
38
|
+
|
39
|
+
namespace 'foo' do
|
40
|
+
CukeCataloger.create_tasks
|
41
|
+
end
|
42
|
+
|
43
|
+
The classes used to tag and validate tests could also be used directly in other scripts if you want to do something more complex than the functionality provided by the two predefined Rake tasks.
|
44
|
+
|
45
|
+
### Adding ids to tests
|
46
|
+
|
47
|
+
The tag_tests task will add an id tag to every scenario (and an id column to every outline) in a test suite. To do this, it needs to be provided a directory in which the tests are located and a prefix upon which to base the tagging scheme.
|
48
|
+
|
49
|
+
rake tag_tests['path/to/your/tests','@test_case_']
|
50
|
+
|
51
|
+
The above example would result in the tags @test_case_1, @test_case_2, @test_case_3, etc. being added to every test in the given directory.
|
52
|
+
|
53
|
+
### Validating test ids
|
54
|
+
|
55
|
+
The validate_tests task scans a given directory for any problems related to id tags and generates a report detailing its results. To do this, it needs to be provided a directory in which the tests are located and a prefix upon which to base the tagging scheme. It can optionally take a file location to which it should output its report instead of printing it to the console.
|
56
|
+
|
57
|
+
rake validate_tests['path/to/your/tests','@test_case_','validation_results.txt']
|
58
|
+
|
59
|
+
The above example would result in a report called 'validation_results.txt' being generated for any test had problems related to their id (e.g. did not have an id tag, had the same id tag as another test, etc.).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it ( http://github.com/<my-github-username>/cuke_cataloger/fork )
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'racatt'
|
2
|
+
require 'coveralls/rake/task'
|
3
|
+
|
4
|
+
|
5
|
+
namespace 'cuke_cataloger' do
|
6
|
+
|
7
|
+
task :clear_coverage do
|
8
|
+
# Remove previous coverage results so that they don't get merged into the new results
|
9
|
+
code_coverage_directory = File.join(File.dirname(__FILE__), 'coverage')
|
10
|
+
FileUtils.remove_dir(code_coverage_directory, true) if File.exists?(code_coverage_directory)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
Racatt.create_tasks
|
15
|
+
|
16
|
+
# Redefining the task from 'racatt' in order to clear the code coverage results
|
17
|
+
task :test_everything, [:command_options] => :clear_coverage
|
18
|
+
|
19
|
+
|
20
|
+
# The task that CI will use
|
21
|
+
Coveralls::RakeTask.new
|
22
|
+
task :ci_build => [:test_everything, 'coveralls:push']
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
task :default => 'cuke_cataloger:test_everything'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cuke_cataloger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cuke_cataloger'
|
8
|
+
spec.version = CukeCataloger::VERSION
|
9
|
+
spec.authors = ['Eric Kessler']
|
10
|
+
spec.email = ['morrow748@gmail.com']
|
11
|
+
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 test suite.'
|
13
|
+
spec.homepage = 'https://github.com/enkessler/cuke_cataloger'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'cuke_modeler'
|
22
|
+
spec.add_runtime_dependency 'cql', '~>1.0', '>= 1.0.1'
|
23
|
+
spec.add_runtime_dependency 'rake'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'cucumber'
|
28
|
+
spec.add_development_dependency 'rspec'
|
29
|
+
spec.add_development_dependency 'racatt'
|
30
|
+
spec.add_development_dependency 'simplecov'
|
31
|
+
spec.add_development_dependency 'coveralls'
|
32
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
Feature: Tagging formatting
|
2
|
+
|
3
|
+
In an effort to have the added tag scheme be as unobtrusive as possible, tagging needs to fit in with the existing
|
4
|
+
source code as well as possible.
|
5
|
+
|
6
|
+
|
7
|
+
Background:
|
8
|
+
And a tag prefix of "@test_case_"
|
9
|
+
|
10
|
+
Scenario: Test level tags have the same indentation as the test itself
|
11
|
+
Given the following feature file:
|
12
|
+
"""
|
13
|
+
Feature:
|
14
|
+
|
15
|
+
Scenario:
|
16
|
+
* a step
|
17
|
+
|
18
|
+
Scenario:
|
19
|
+
* a step
|
20
|
+
|
21
|
+
Scenario:
|
22
|
+
* a step
|
23
|
+
"""
|
24
|
+
When the files are processed
|
25
|
+
Then the resulting file is:
|
26
|
+
"""
|
27
|
+
Feature:
|
28
|
+
|
29
|
+
@test_case_1
|
30
|
+
Scenario:
|
31
|
+
* a step
|
32
|
+
|
33
|
+
@test_case_2
|
34
|
+
Scenario:
|
35
|
+
* a step
|
36
|
+
|
37
|
+
@test_case_3
|
38
|
+
Scenario:
|
39
|
+
* a step
|
40
|
+
"""
|
41
|
+
|
42
|
+
Scenario: The column for sub-ids is appropriately whitespace buffered
|
43
|
+
Given the following feature file:
|
44
|
+
"""
|
45
|
+
Feature:
|
46
|
+
|
47
|
+
@test_case_1
|
48
|
+
Scenario Outline:
|
49
|
+
* a step
|
50
|
+
Examples: column name is longer than sub-id
|
51
|
+
| param 1 |
|
52
|
+
| value 1 |
|
53
|
+
|
54
|
+
@test_case_123456789101112
|
55
|
+
Scenario Outline:
|
56
|
+
* a step
|
57
|
+
Examples: sub-id is longer than column name
|
58
|
+
| param 1 |
|
59
|
+
| value 1 |
|
60
|
+
"""
|
61
|
+
When the files are processed
|
62
|
+
Then the resulting file is:
|
63
|
+
"""
|
64
|
+
Feature:
|
65
|
+
|
66
|
+
@test_case_1
|
67
|
+
Scenario Outline:
|
68
|
+
* a step
|
69
|
+
Examples: column name is longer than sub-id
|
70
|
+
| param 1 | test_case_id |
|
71
|
+
| value 1 | 1-1 |
|
72
|
+
|
73
|
+
@test_case_123456789101112
|
74
|
+
Scenario Outline:
|
75
|
+
* a step
|
76
|
+
Examples: sub-id is longer than column name
|
77
|
+
| param 1 | test_case_id |
|
78
|
+
| value 1 | 123456789101112-1 |
|
79
|
+
"""
|
80
|
+
|
81
|
+
Scenario: The column for sub-ids is last
|
82
|
+
Given a feature file
|
83
|
+
When the file is processed
|
84
|
+
Then the column for sub-ids is placed after all other columns
|
85
|
+
|
86
|
+
Scenario: Test tags can be added above existing tags
|
87
|
+
Given the following feature file:
|
88
|
+
"""
|
89
|
+
Feature:
|
90
|
+
|
91
|
+
@tag_1
|
92
|
+
@tag_2 @tag_3
|
93
|
+
|
94
|
+
Scenario: Test with tags
|
95
|
+
|
96
|
+
Scenario: Test without tags
|
97
|
+
"""
|
98
|
+
And the tag should be at the "top"
|
99
|
+
When the files are processed
|
100
|
+
Then the resulting file is:
|
101
|
+
"""
|
102
|
+
Feature:
|
103
|
+
|
104
|
+
@test_case_1
|
105
|
+
@tag_1
|
106
|
+
@tag_2 @tag_3
|
107
|
+
|
108
|
+
Scenario: Test with tags
|
109
|
+
|
110
|
+
@test_case_2
|
111
|
+
Scenario: Test without tags
|
112
|
+
"""
|
113
|
+
|
114
|
+
Scenario: Test tags can be added below existing tags
|
115
|
+
Given the following feature file:
|
116
|
+
"""
|
117
|
+
Feature:
|
118
|
+
|
119
|
+
@tag_1
|
120
|
+
@tag_2 @tag_3
|
121
|
+
|
122
|
+
Scenario: Test with tags
|
123
|
+
|
124
|
+
Scenario: Test without tags
|
125
|
+
"""
|
126
|
+
And the tag should be at the "bottom"
|
127
|
+
When the files are processed
|
128
|
+
Then the resulting file is:
|
129
|
+
"""
|
130
|
+
Feature:
|
131
|
+
|
132
|
+
@tag_1
|
133
|
+
@tag_2 @tag_3
|
134
|
+
@test_case_1
|
135
|
+
|
136
|
+
Scenario: Test with tags
|
137
|
+
|
138
|
+
@test_case_2
|
139
|
+
Scenario: Test without tags
|
140
|
+
"""
|
141
|
+
|
142
|
+
Scenario: Test tags can be added adjacent to the test
|
143
|
+
Given the following feature file:
|
144
|
+
"""
|
145
|
+
Feature:
|
146
|
+
|
147
|
+
@tag_1
|
148
|
+
@tag_2 @tag_3
|
149
|
+
|
150
|
+
Scenario: Test with tags
|
151
|
+
|
152
|
+
Scenario: Test without tags
|
153
|
+
"""
|
154
|
+
And the tag should be at the "side"
|
155
|
+
When the files are processed
|
156
|
+
Then the resulting file is:
|
157
|
+
"""
|
158
|
+
Feature:
|
159
|
+
|
160
|
+
@tag_1
|
161
|
+
@tag_2 @tag_3
|
162
|
+
|
163
|
+
@test_case_1
|
164
|
+
Scenario: Test with tags
|
165
|
+
|
166
|
+
@test_case_2
|
167
|
+
Scenario: Test without tags
|
168
|
+
"""
|
169
|
+
|
170
|
+
Scenario: Test tagging location defaults to adjacent
|
171
|
+
Given the following feature file:
|
172
|
+
"""
|
173
|
+
Feature:
|
174
|
+
|
175
|
+
@tag_1
|
176
|
+
@tag_2 @tag_3
|
177
|
+
|
178
|
+
Scenario:
|
179
|
+
"""
|
180
|
+
And the tag location is unspecified
|
181
|
+
When the files are processed
|
182
|
+
Then the resulting file is:
|
183
|
+
"""
|
184
|
+
Feature:
|
185
|
+
|
186
|
+
@tag_1
|
187
|
+
@tag_2 @tag_3
|
188
|
+
|
189
|
+
@test_case_1
|
190
|
+
Scenario:
|
191
|
+
"""
|
@@ -0,0 +1,28 @@
|
|
1
|
+
When(/^the files? (?:is|are) processed$/) do
|
2
|
+
@start_index ||= {}
|
3
|
+
@directory = CukeModeler::Directory.new(@test_directory)
|
4
|
+
|
5
|
+
tagger = CukeCataloger::UniqueTestCaseTagger.new
|
6
|
+
tagger.tag_location = @above_or_below if @above_or_below
|
7
|
+
|
8
|
+
tagger.tag_tests(@directory.path, @tag_prefix, @start_index)
|
9
|
+
end
|
10
|
+
|
11
|
+
When(/^the ids in the test suite are validated$/) do
|
12
|
+
@directory = CukeModeler::Directory.new(@test_directory)
|
13
|
+
|
14
|
+
@test_results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(@directory.path, @tag_prefix)
|
15
|
+
end
|
16
|
+
|
17
|
+
When(/^the files are scanned$/) do
|
18
|
+
@directory = CukeModeler::Directory.new(@test_directory)
|
19
|
+
@exception_raised = false
|
20
|
+
|
21
|
+
@test_results = CukeCataloger::UniqueTestCaseTagger.new.scan_for_tagged_tests(@directory.path, @tag_prefix)
|
22
|
+
end
|
23
|
+
|
24
|
+
When(/^the existing ids are determined$/) do
|
25
|
+
@directory = CukeModeler::Directory.new(@test_directory)
|
26
|
+
|
27
|
+
@ids_found = CukeCataloger::UniqueTestCaseTagger.new.determine_known_ids(@directory.path, @tag_prefix)
|
28
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Given /^the following feature file(?: "([^"]*)")?:$/ do |file_name, file_text|
|
2
|
+
@test_directory = @default_file_directory
|
3
|
+
@files_created ||= 0
|
4
|
+
@feature_files ||= []
|
5
|
+
|
6
|
+
file_name ||= "#{@default_feature_file_name}_#{@files_created + 1}.feature"
|
7
|
+
file_path = "#{@test_directory}/#{file_name}"
|
8
|
+
@feature_files << file_path
|
9
|
+
|
10
|
+
File.open(file_path, 'w') { |file| file.write file_text }
|
11
|
+
|
12
|
+
@files_created += 1
|
13
|
+
end
|
14
|
+
|
15
|
+
When(/^a tag prefix of "([^"]*)"$/) do |prefix|
|
16
|
+
@tag_prefix = prefix
|
17
|
+
end
|
18
|
+
|
19
|
+
And(/^a start index of "([^"]*)"$/) do |index|
|
20
|
+
@start_index ||= {:sub => {}}
|
21
|
+
@start_index[:primary] = index
|
22
|
+
end
|
23
|
+
|
24
|
+
And(/^a start index of "([^"]*)" for testcase "([^"]*)"$/) do |sub_index, parent_index|
|
25
|
+
@start_index ||= {:sub => {}}
|
26
|
+
@start_index[:sub][parent_index.to_s] = sub_index
|
27
|
+
end
|
28
|
+
|
29
|
+
Given(/^a feature file$/) do
|
30
|
+
@test_directory = @default_file_directory
|
31
|
+
@files_created ||= 0
|
32
|
+
@feature_files ||= []
|
33
|
+
|
34
|
+
file_name ||= "#{@default_feature_file_name}_#{@files_created + 1}.feature"
|
35
|
+
file_path = "#{@test_directory}/#{file_name}"
|
36
|
+
@feature_files << file_path
|
37
|
+
|
38
|
+
File.open(file_path, 'w') { |file| file.write "Feature:\nScenario Outline:\n* a step\nExamples:\n| param 1 |\n| value 1 |" }
|
39
|
+
|
40
|
+
@files_created += 1
|
41
|
+
end
|
42
|
+
|
43
|
+
And(/^the tag should be at the "([^"]*)"$/) do |tag_location|
|
44
|
+
case tag_location
|
45
|
+
when 'top'
|
46
|
+
@above_or_below = :above
|
47
|
+
when 'bottom'
|
48
|
+
@above_or_below = :below
|
49
|
+
when 'side'
|
50
|
+
@above_or_below = :adjacent
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
And(/^the tag location is unspecified$/) do
|
55
|
+
@above_or_below = nil
|
56
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
Then(/^the resulting file(?: "([^"]*)")? is:$/) do |file_index, expected_text|
|
2
|
+
file_index ||= 1
|
3
|
+
file_name = @feature_files[file_index - 1]
|
4
|
+
|
5
|
+
actual_text = File.read(file_name)
|
6
|
+
|
7
|
+
expect(actual_text).to eq(expected_text)
|
8
|
+
end
|
9
|
+
|
10
|
+
Then(/^the following tests are found to be missing ids:$/) do |expected_tests|
|
11
|
+
verify_category_results(:missing_tag, expected_tests)
|
12
|
+
end
|
13
|
+
|
14
|
+
Then(/^no tests are found to be missing ids$/) do
|
15
|
+
verify_no_results
|
16
|
+
end
|
17
|
+
|
18
|
+
Then(/^the following tests rows are found to be missing sub ids:$/) do |expected_rows|
|
19
|
+
verify_category_results(:missing_row_id, expected_rows)
|
20
|
+
end
|
21
|
+
|
22
|
+
Then(/^no tests rows are found to be missing sub ids$/) do
|
23
|
+
verify_no_results
|
24
|
+
end
|
25
|
+
|
26
|
+
Then(/^the following tests examples are found to be missing a parameter for sub ids:$/) do |expected_examples|
|
27
|
+
verify_category_results(:missing_id_column, expected_examples)
|
28
|
+
end
|
29
|
+
|
30
|
+
Then(/^no test examples are found to be missing id parameters$/) do
|
31
|
+
verify_no_results
|
32
|
+
end
|
33
|
+
|
34
|
+
Then(/^the following tests example rows are found to have mismatched sub ids:$/) do |expected_rows|
|
35
|
+
verify_category_results(:mismatched_row_id, expected_rows)
|
36
|
+
end
|
37
|
+
|
38
|
+
Then(/^no test example rows are found to have mismatched ids$/) do
|
39
|
+
verify_no_results
|
40
|
+
end
|
41
|
+
|
42
|
+
Then(/^the following tests are found to have multiple test ids:$/) do |expected_tests|
|
43
|
+
verify_category_results(:multiple_tags, expected_tests)
|
44
|
+
end
|
45
|
+
|
46
|
+
Then(/^no tests are found to have multiple test ids$/) do
|
47
|
+
verify_no_results
|
48
|
+
end
|
49
|
+
|
50
|
+
Then(/^the following tests are found to have a duplicated id:$/) do |expected_tests|
|
51
|
+
verify_category_results(:duplicate_id_tag, expected_tests)
|
52
|
+
end
|
53
|
+
|
54
|
+
Then(/^no tests are found to have duplicated ids$/) do
|
55
|
+
verify_no_results
|
56
|
+
end
|
57
|
+
|
58
|
+
Then(/^the following tests example rows are found to have duplicated sub ids:$/) do |expected_rows|
|
59
|
+
verify_category_results(:duplicate_row_id, expected_rows)
|
60
|
+
end
|
61
|
+
|
62
|
+
Then(/^no test example rows are found to have duplicated sub ids$/) do
|
63
|
+
verify_no_results
|
64
|
+
end
|
65
|
+
|
66
|
+
Then(/^the following tests example rows are found to have malformed sub ids:$/) do |expected_rows|
|
67
|
+
verify_category_results(:malformed_sub_id, expected_rows)
|
68
|
+
end
|
69
|
+
|
70
|
+
Then(/^no test example rows are found to have malformed sub ids$/) do
|
71
|
+
verify_no_results
|
72
|
+
end
|
73
|
+
|
74
|
+
Then(/^the following tagged test objects are found:$/) do |expected_results|
|
75
|
+
verify_results(expected_results)
|
76
|
+
end
|
77
|
+
|
78
|
+
Then(/^the payload is a test object$/) do
|
79
|
+
expect(@test_results.first[:object]).to be_a_kind_of(CukeModeler::TestElement)
|
80
|
+
end
|
81
|
+
|
82
|
+
Then(/^the payload has a test and a test row$/) do
|
83
|
+
expect(@test_results[0][:object]).to be_a_kind_of(CukeModeler::Outline)
|
84
|
+
expect(@test_results[1][:object]).to be_a_kind_of(CukeModeler::Row)
|
85
|
+
end
|
86
|
+
|
87
|
+
Then(/^the following ids are found:$/) do |expected_ids|
|
88
|
+
expect(@ids_found).to match_array(expected_ids.raw.flatten)
|
89
|
+
end
|
90
|
+
|
91
|
+
Then(/^the following feature is found to have a test case tag:$/) do |expected_results|
|
92
|
+
verify_category_results(:feature_test_tag, expected_results)
|
93
|
+
end
|
94
|
+
|
95
|
+
Then(/^no feature is found to have a test case tag$/) do
|
96
|
+
verify_no_results
|
97
|
+
end
|
98
|
+
|
99
|
+
Then(/^the column for sub-ids is placed after all other columns$/) do
|
100
|
+
file_model = CukeModeler::FeatureFile.new(@feature_files.first)
|
101
|
+
outline_model = file_model.feature.outlines.first
|
102
|
+
|
103
|
+
expect(outline_model.examples.first.parameters.last).to eq('test_case_id')
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def verify_no_results
|
108
|
+
expect(@test_results).to be_empty
|
109
|
+
end
|
110
|
+
|
111
|
+
def verify_category_results(category, results)
|
112
|
+
@test_results = @test_results.select { |test_result| test_result[:problem] == category }
|
113
|
+
verify_results(results)
|
114
|
+
end
|
115
|
+
|
116
|
+
def verify_results(results)
|
117
|
+
expect(@test_results.collect { |test_result| test_result[:test] }).to match_array(process_results(results))
|
118
|
+
end
|
119
|
+
|
120
|
+
def process_results(results)
|
121
|
+
results = results.raw.flatten
|
122
|
+
results.collect { |test_path| test_path.sub('path/to', @default_file_directory) }
|
123
|
+
end
|
124
|
+
|
125
|
+
Then(/^the resulting first file is:$/) do |expected_text|
|
126
|
+
file_name = @feature_files[0]
|
127
|
+
|
128
|
+
actual_text = File.read(file_name)
|
129
|
+
|
130
|
+
# The order in which Ruby returns files various across version and operating system. This, in turn, will
|
131
|
+
# affect the order in which files are tagged. Either order is acceptable as long as the tagging is
|
132
|
+
# consistent for any given ordering.
|
133
|
+
begin
|
134
|
+
expect(actual_text).to eq(expected_text)
|
135
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
136
|
+
if RUBY_PLATFORM =~ /linux/
|
137
|
+
expected_text.sub!('test_case_1', 'test_case_2')
|
138
|
+
expect(actual_text).to eq(expected_text)
|
139
|
+
@switched = true
|
140
|
+
else
|
141
|
+
raise e
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
And(/^the resulting second file is:$/) do |expected_text|
|
148
|
+
file_name = @feature_files[1]
|
149
|
+
|
150
|
+
actual_text = File.read(file_name)
|
151
|
+
|
152
|
+
# The order in which Ruby returns files various across version and operating system. This, in turn, will
|
153
|
+
# affect the order in which files are tagged. Either order is acceptable as long as the tagging is
|
154
|
+
# consistent for any given ordering.
|
155
|
+
if @switched
|
156
|
+
expected_text.sub!('test_case_2', 'test_case_1')
|
157
|
+
expected_text.sub!('2-1', '1-1')
|
158
|
+
expected_text.sub!('2-2', '1-2')
|
159
|
+
end
|
160
|
+
|
161
|
+
expect(actual_text).to eq(expected_text)
|
162
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
unless RUBY_VERSION.to_s < '1.9.0'
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.command_name('cuke_cataloger-cucumber')
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'cuke_cataloger'
|
7
|
+
|
8
|
+
|
9
|
+
DEFAULT_FEATURE_FILE_NAME = 'test_feature'
|
10
|
+
DEFAULT_FILE_DIRECTORY = "#{File.dirname(__FILE__)}/../temp_files"
|
11
|
+
|
12
|
+
|
13
|
+
Before do
|
14
|
+
@default_feature_file_name = DEFAULT_FEATURE_FILE_NAME
|
15
|
+
@default_file_directory = DEFAULT_FILE_DIRECTORY
|
16
|
+
|
17
|
+
FileUtils.mkdir(@default_file_directory)
|
18
|
+
end
|
19
|
+
|
20
|
+
After do
|
21
|
+
FileUtils.remove_dir(@default_file_directory, true)
|
22
|
+
end
|