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.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +104 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +73 -13
  5. data/cuke_cataloger.gemspec +37 -16
  6. data/exe/cuke_cataloger +53 -0
  7. data/lib/cuke_cataloger/formatters/text_report_formatter.rb +38 -0
  8. data/lib/cuke_cataloger/rake_tasks.rb +51 -0
  9. data/lib/cuke_cataloger/unique_test_case_tagger.rb +180 -149
  10. data/lib/cuke_cataloger/version.rb +2 -1
  11. data/lib/cuke_cataloger.rb +6 -64
  12. data/testing/cucumber/features/cataloging_tasks.feature +48 -0
  13. data/testing/cucumber/features/formatting.feature +0 -3
  14. data/testing/cucumber/features/tag_indexing.feature +3 -3
  15. data/testing/cucumber/features/test_case_scanning_payload.feature +0 -2
  16. data/testing/cucumber/features/test_case_tagging.feature +2 -2
  17. data/testing/cucumber/features/test_case_validation.feature +3 -20
  18. metadata +125 -61
  19. data/.gitignore +0 -18
  20. data/.simplecov +0 -8
  21. data/.travis.yml +0 -35
  22. data/Gemfile +0 -22
  23. data/History.md +0 -39
  24. data/Rakefile +0 -35
  25. data/appveyor.yml +0 -69
  26. data/bin/cuke_cataloger +0 -68
  27. data/testing/cucumber/step_definitions/action_steps.rb +0 -42
  28. data/testing/cucumber/step_definitions/setup_steps.rb +0 -69
  29. data/testing/cucumber/step_definitions/verification_steps.rb +0 -207
  30. data/testing/cucumber/support/env.rb +0 -37
  31. data/testing/cucumber/support/transforms.rb +0 -3
  32. data/testing/fixtures/tests/foo.feature +0 -11
  33. data/testing/gemfiles/cuke_modeler0.gemfile +0 -21
  34. data/testing/gemfiles/cuke_modeler1.gemfile +0 -21
  35. data/testing/gemfiles/rake10.gemfile +0 -21
  36. data/testing/gemfiles/rake11.gemfile +0 -16
  37. data/testing/gemfiles/rake12.gemfile +0 -16
  38. data/testing/rspec/spec/cuke_cataloger_spec.rb +0 -22
  39. data/testing/rspec/spec/spec_helper.rb +0 -27
  40. data/testing/rspec/spec/unique_test_case_tagger_integration_spec.rb +0 -122
  41. data/testing/rspec/spec/unique_test_case_tagger_unit_spec.rb +0 -75
  42. data/todo.txt +0 -4
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- /.idea/
data/.simplecov DELETED
@@ -1,8 +0,0 @@
1
- SimpleCov.start do
2
- root File.dirname(__FILE__)
3
-
4
- add_filter '/features/'
5
- add_filter '/spec/'
6
-
7
- merge_timeout 300
8
- end
data/.travis.yml DELETED
@@ -1,35 +0,0 @@
1
- os:
2
- - linux
3
- - osx
4
-
5
- language: ruby
6
- rvm:
7
- - 1.8.7
8
- - 1.9.3
9
- - 2.2.2
10
- - 2.4.0
11
-
12
- matrix:
13
- exclude:
14
- # Travis does not provide 1.8.7 on OSX
15
- - rvm: 1.8.7
16
- os: osx
17
- # Rake 11.x does not support Ruby 1.8.7
18
- - rvm: 1.8.7
19
- gemfile: testing/gemfiles/rake11.gemfile
20
- # Rake 12.x does not support Ruby 1.8.7
21
- - rvm: 1.8.7
22
- gemfile: testing/gemfiles/rake12.gemfile
23
-
24
- gemfile:
25
- - testing/gemfiles/cuke_modeler0.gemfile
26
- - testing/gemfiles/cuke_modeler1.gemfile
27
- - testing/gemfiles/rake10.gemfile
28
- - testing/gemfiles/rake11.gemfile
29
- - testing/gemfiles/rake12.gemfile
30
-
31
- # todo - Remove this once TravisCI fixes their bundler issue (https://github.com/alphagov/govuk_template/pull/186)
32
- before_install:
33
- - gem install bundler -v 1.9.10
34
-
35
- script: bundle exec rake cuke_cataloger:ci_build
data/Gemfile DELETED
@@ -1,22 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cuke_cataloger.gemspec
4
- gemspec
5
-
6
-
7
- # cuke_cataloger can play with pretty much any version of these but they all play differently with Ruby
8
- if RUBY_VERSION =~ /^1\.8/
9
- gem 'cucumber', '< 1.3.0'
10
- gem 'gherkin', '< 2.12.0'
11
- gem 'rake', '< 11.0' # Rake dropped 1.8.x support after this version
12
- elsif RUBY_VERSION =~ /^1\./
13
- gem 'cucumber', '< 2.0.0'
14
- end
15
-
16
- if RUBY_VERSION =~ /^1\./
17
- gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
18
- gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
19
- gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
20
- end
21
-
22
- gem 'cuke_modeler', '< 2.0'
data/History.md DELETED
@@ -1,39 +0,0 @@
1
- # Release history
2
-
3
- ### Version 1.4.0 / 2017-04-18
4
-
5
- - Both cataloging and validation can now be used without including outline rows, if desired.
6
-
7
- - The column header used for outline row ids is now configurable.
8
-
9
-
10
- ### Version 1.3.1 / 2017-01-11
11
-
12
- - Bug fix: Added missing shebang line to the gem's executable file.
13
-
14
-
15
- ### Version 1.3.0 / 2017-01-09
16
-
17
- - Bug fix: Replaced non-Ruby 1.8.x compatible code so that the gem now correctly works with older versions of Ruby.
18
-
19
- - Added an executable file for the gem so that it can be used without having to use Rake tasks.
20
-
21
- - A basic cataloging location and prefix is used by default so that specifying these values will not be necessary in many cases.
22
-
23
-
24
- ### Version 1.2.0 / 2016-10-02
25
-
26
- - The gem now declares version limits on all of its dependencies.
27
-
28
- - Added support for the 1.x series of the 'cuke_modeler' gem.
29
-
30
-
31
- ### Version 1.1.0 / 2016-02-21
32
-
33
- - Upgraded to a more recent version of the 'cuke_modeler' gem and removed monkey patches that were
34
- previously providing functionality that is now present in the newer version of 'cuke_modeler'
35
-
36
-
37
- ### Version 1.0.0 / 2015-10-05
38
-
39
- - Initial release
data/Rakefile DELETED
@@ -1,35 +0,0 @@
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 => :clear_coverage
18
-
19
-
20
- desc 'Test the project'
21
- task :smart_test do |t, args|
22
- rspec_args = '--tag ~@wip --pattern testing/rspec/spec/**/*_spec.rb'
23
- cucumber_args = 'testing/cucumber/features -r testing/cucumber/support -r testing/cucumber/step_definitions -f progress -t ~@wip'
24
-
25
- Rake::Task['cuke_cataloger:test_everything'].invoke(rspec_args, cucumber_args)
26
- end
27
-
28
-
29
- # The task that CI will use
30
- Coveralls::RakeTask.new
31
- task :ci_build => [:smart_test, 'coveralls:push']
32
- end
33
-
34
-
35
- task :default => 'cuke_cataloger:smart_test'
data/appveyor.yml DELETED
@@ -1,69 +0,0 @@
1
- version: '1.0.{build}'
2
-
3
- environment:
4
- matrix:
5
- - RUBY_VERSION: 187-x64
6
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler0.gemfile
7
- - RUBY_VERSION: 193-x64
8
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler0.gemfile
9
- - RUBY_VERSION: 200-x64
10
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler0.gemfile
11
- - RUBY_VERSION: 21-x64
12
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler0.gemfile
13
- - RUBY_VERSION: 22-x64
14
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler0.gemfile
15
-
16
- - RUBY_VERSION: 187-x64
17
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
18
- - RUBY_VERSION: 193-x64
19
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
20
- - RUBY_VERSION: 200-x64
21
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
22
- - RUBY_VERSION: 21-x64
23
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
24
- - RUBY_VERSION: 22-x64
25
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
26
-
27
- - RUBY_VERSION: 187-x64
28
- BUNDLE_GEMFILE: testing/gemfiles/rake10.gemfile
29
- - RUBY_VERSION: 193-x64
30
- BUNDLE_GEMFILE: testing/gemfiles/rake10.gemfile
31
- - RUBY_VERSION: 200-x64
32
- BUNDLE_GEMFILE: testing/gemfiles/rake10.gemfile
33
- - RUBY_VERSION: 21-x64
34
- BUNDLE_GEMFILE: testing/gemfiles/rake10.gemfile
35
- - RUBY_VERSION: 22-x64
36
- BUNDLE_GEMFILE: testing/gemfiles/rake10.gemfile
37
-
38
- - RUBY_VERSION: 193-x64
39
- BUNDLE_GEMFILE: testing/gemfiles/rake11.gemfile
40
- - RUBY_VERSION: 200-x64
41
- BUNDLE_GEMFILE: testing/gemfiles/rake11.gemfile
42
- - RUBY_VERSION: 21-x64
43
- BUNDLE_GEMFILE: testing/gemfiles/rake11.gemfile
44
- - RUBY_VERSION: 22-x64
45
- BUNDLE_GEMFILE: testing/gemfiles/rake11.gemfile
46
-
47
- - RUBY_VERSION: 193-x64
48
- BUNDLE_GEMFILE: testing/gemfiles/rake12.gemfile
49
- - RUBY_VERSION: 200-x64
50
- BUNDLE_GEMFILE: testing/gemfiles/rake12.gemfile
51
- - RUBY_VERSION: 21-x64
52
- BUNDLE_GEMFILE: testing/gemfiles/rake12.gemfile
53
- - RUBY_VERSION: 22-x64
54
- BUNDLE_GEMFILE: testing/gemfiles/rake12.gemfile
55
-
56
-
57
- install:
58
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
59
- - bundle install
60
-
61
- build: off
62
-
63
- before_test:
64
- - ruby -v
65
- - gem -v
66
- - bundle -v
67
-
68
- test_script:
69
- - bundle exec rake
data/bin/cuke_cataloger DELETED
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
-
4
- require 'thor'
5
- require 'cuke_cataloger'
6
-
7
-
8
- class CLI < Thor
9
-
10
- desc 'catalog_test_cases', '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
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', 'Validate the test cases in LOCATION with an id based on PREFIX. Will output the report to FILE, if provided.'
25
- option :location, :default => '.'
26
- option :prefix, :default => '@test_case_'
27
- option :row_id, :type => :boolean, :default => true
28
- option :id_column_name, :default => 'test_case_id'
29
- option :file
30
-
31
- def validate_test_cases
32
- puts "Validating tests in '#{options[:location]}' with tag '#{options[:prefix]}'\n"
33
- puts "Including outline rows\n" if options[:row_id]
34
-
35
- results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(options[:location], options[:prefix], options[:row_id], options[:id_column_name])
36
- report_text = "Validation Results\nProblems found: #{results.count}\n\n"
37
-
38
-
39
- results_by_category = Hash.new { |hash, key| hash[key] = [] }
40
-
41
- results.each do |result|
42
- results_by_category[result[:problem]] << result
43
- end
44
-
45
- results_by_category.keys.each do |problem_category|
46
- report_text << "#{problem_category} problems: #{results_by_category[problem_category].count}\n"
47
- end
48
-
49
- results_by_category.keys.each do |problem_category|
50
- report_text << "\n\n#{problem_category} problems (#{results_by_category[problem_category].count}):\n"
51
-
52
- results_by_category[problem_category].each do |result|
53
- report_text << "#{result[:test]}\n"
54
- end
55
- end
56
-
57
- if options[:file]
58
- puts "Problems found: #{results.count}"
59
- File.open(options[:file], 'w') { |file| file.write(report_text) }
60
- else
61
- puts report_text
62
- end
63
- end
64
-
65
- end
66
-
67
-
68
- CLI.start(ARGV)
@@ -1,42 +0,0 @@
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
29
-
30
- When(/^the following command is executed:$/) do |command|
31
- if command =~ /--file /
32
- output_file_name = command.match(/--file <path_to>\/(.*)\.txt/)[1]
33
- command.sub!(/--file <path_to>\/(.*)\.txt/, "--file #{DEFAULT_FILE_DIRECTORY}/#{output_file_name}.txt")
34
- end
35
-
36
- command.sub!('<path_to>', FIXTURE_DIRECTORY)
37
- command = "bundle exec ruby #{@executable_directory}/#{command}"
38
-
39
- Dir.chdir(FIXTURE_DIRECTORY) do
40
- @output = `#{command}`
41
- end
42
- end
@@ -1,69 +0,0 @@
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
57
-
58
- Given(/^the cuke_cataloger executable is available$/) do
59
- @executable_directory = "#{PROJECT_ROOT}/bin"
60
- end
61
-
62
- And(/^there are test cases in the "([^"]*)" directory that have not been cataloged with "([^"]*)"$/) do |target_directory, prefix|
63
- target_directory = "#{FIXTURE_DIRECTORY}/#{target_directory}"
64
-
65
- @test_results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(target_directory, prefix)
66
-
67
- # Making sure that there is work to be done, thus avoiding false positives
68
- expect(@test_results.select { |test_result| test_result[:problem] == :missing_tag }).to_not be_empty
69
- end
@@ -1,207 +0,0 @@
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 model object$/) do
79
- class_name = @test_results.first[:object].class.name.split('::').last
80
-
81
- expect(CukeModeler.const_defined?(class_name)).to be true
82
- end
83
-
84
- Then(/^the payload has a test and a test row$/) do
85
- expect(@test_results[0][:object]).to be_a_kind_of(CukeModeler::Outline)
86
- expect(@test_results[1][:object]).to be_a_kind_of(CukeModeler::Row)
87
- end
88
-
89
- Then(/^the following ids are found:$/) do |expected_ids|
90
- expect(@ids_found).to match_array(expected_ids.raw.flatten)
91
- end
92
-
93
- Then(/^the following feature is found to have a test case tag:$/) do |expected_results|
94
- verify_category_results(:feature_test_tag, expected_results)
95
- end
96
-
97
- Then(/^no feature is found to have a test case tag$/) do
98
- verify_no_results
99
- end
100
-
101
- Then(/^the column for sub-ids is placed after all other columns$/) do
102
- file_model = CukeModeler::FeatureFile.new(@feature_files.first)
103
- outline_model = file_model.feature.outlines.first
104
-
105
- expect(outline_model.examples.first.parameters.last).to eq('test_case_id')
106
- end
107
-
108
-
109
- def verify_no_results
110
- expect(@test_results).to be_empty
111
- end
112
-
113
- def verify_category_results(category, results)
114
- @test_results = @test_results.select { |test_result| test_result[:problem] == category }
115
- verify_results(results)
116
- end
117
-
118
- def verify_results(results)
119
- expect(@test_results.collect { |test_result| test_result[:test] }).to match_array(process_results(results))
120
- end
121
-
122
- def process_results(results)
123
- results = results.raw.flatten
124
- results.collect { |test_path| test_path.sub('path/to', @default_file_directory) }
125
- end
126
-
127
- Then(/^the resulting first file is:$/) do |expected_text|
128
- file_name = @feature_files[0]
129
-
130
- actual_text = File.read(file_name)
131
-
132
- # The order in which Ruby returns files various across version and operating system. This, in turn, will
133
- # affect the order in which files are tagged. Either order is acceptable as long as the tagging is
134
- # consistent for any given ordering.
135
- begin
136
- expect(actual_text).to eq(expected_text)
137
- rescue RSpec::Expectations::ExpectationNotMetError => e
138
- if RUBY_PLATFORM =~ /linux/
139
- expected_text.sub!('test_case_1', 'test_case_2')
140
- expect(actual_text).to eq(expected_text)
141
- @switched = true
142
- else
143
- raise e
144
- end
145
- end
146
-
147
- end
148
-
149
- And(/^the resulting second file is:$/) do |expected_text|
150
- file_name = @feature_files[1]
151
-
152
- actual_text = File.read(file_name)
153
-
154
- # The order in which Ruby returns files various across version and operating system. This, in turn, will
155
- # affect the order in which files are tagged. Either order is acceptable as long as the tagging is
156
- # consistent for any given ordering.
157
- if @switched
158
- expected_text.sub!('test_case_2', 'test_case_1')
159
- expected_text.sub!('2-1', '1-1')
160
- expected_text.sub!('2-2', '1-2')
161
- end
162
-
163
- expect(actual_text).to eq(expected_text)
164
- end
165
-
166
- Then(/^all of the test cases in the "([^"]*)" directory will be cataloged with "([^"]*)"$/) do |target_directory, prefix|
167
- target_directory = "#{FIXTURE_DIRECTORY}/#{target_directory}"
168
-
169
- @test_results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(target_directory, prefix)
170
-
171
- verify_no_results
172
- end
173
-
174
- Then(/^all of the scenarios and outlines in the "([^"]*)" directory will be cataloged with "([^"]*)"$/) do |target_directory, prefix|
175
- target_directory = "#{FIXTURE_DIRECTORY}/#{target_directory}"
176
- @expected_prefix = prefix
177
- tag_rows = false
178
-
179
- @test_results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(target_directory, @expected_prefix, tag_rows)
180
-
181
- verify_no_results
182
- end
183
-
184
- But(/^outline rows in the "([^"]*)" directory are not cataloged$/) do |target_directory|
185
- target_directory = "#{FIXTURE_DIRECTORY}/#{target_directory}"
186
- tag_rows = true
187
-
188
- @test_results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(target_directory, @expected_prefix, tag_rows)
189
-
190
- expect(@test_results.collect { |result| result[:problem] }).to include(:missing_id_column)
191
- end
192
-
193
- Then(/^a validation report for the "([^"]*)" directory with prefix "([^"]*)" is output to the console$/) do |target_directory, prefix|
194
- expect(@output).to include("Validating tests in '#{target_directory}' with tag '#{prefix}'")
195
- expect(@output).to include("Validation Results")
196
- end
197
-
198
- Then(/^a validation report for the "([^"]*)" directory with prefix "([^"]*)" is output to "([^"]*)"$/) do |target_directory, prefix, filename|
199
- target_directory = "#{FIXTURE_DIRECTORY}/#{target_directory}"
200
- filename = "#{DEFAULT_FILE_DIRECTORY}/#{filename}"
201
-
202
- expect(@output).to include("Validating tests in '#{target_directory}' with tag '#{prefix}'")
203
- expect(@output).to include("Problems found:")
204
-
205
- expect(File.exists?(filename)).to be true
206
- expect(File.read(filename)).to include('Validation Results')
207
- end
@@ -1,37 +0,0 @@
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
- here = File.dirname(__FILE__)
9
-
10
- DEFAULT_FEATURE_FILE_NAME = 'test_feature'
11
- DEFAULT_FILE_DIRECTORY = "#{here}/../temp_files"
12
- PROJECT_ROOT = "#{here}/../../.."
13
- FIXTURE_DIRECTORY = "#{here}/../../fixtures"
14
-
15
- Before do
16
- begin
17
- @default_feature_file_name = DEFAULT_FEATURE_FILE_NAME
18
- @default_file_directory = DEFAULT_FILE_DIRECTORY
19
-
20
- FileUtils.mkdir(@default_file_directory)
21
- rescue => e
22
- puts "Error caught in before hook!"
23
- puts "Type: #{e.class}"
24
- puts "Message: #{e.message}"
25
- end
26
- end
27
-
28
- After do
29
- begin
30
- `git checkout HEAD -- #{FIXTURE_DIRECTORY}`
31
- FileUtils.remove_dir(@default_file_directory, true)
32
- rescue => e
33
- puts "Error caught in before hook!"
34
- puts "Type: #{e.class}"
35
- puts "Message: #{e.message}"
36
- end
37
- end
@@ -1,3 +0,0 @@
1
- Transform /^(-?\d+)$/ do |number|
2
- number.to_i
3
- end
@@ -1,11 +0,0 @@
1
- Feature: Foo
2
-
3
- Scenario: Test 1
4
- * a step
5
-
6
- Scenario Outline: Test 2
7
- * a step
8
- Examples:
9
- | param | value |
10
- | a | b |
11
- | c | d |