Class: CukeCataloger::UniqueTestCaseTagger
- Inherits:
-
Object
- Object
- CukeCataloger::UniqueTestCaseTagger
- Defined in:
- lib/cuke_cataloger/unique_test_case_tagger.rb
Constant Summary collapse
- SUB_ID_PATTERN =
/^\d+\-\d+$/- SUB_ID_MATCH_PATTERN =
/^\d+\-(\d+)$/
Instance Attribute Summary collapse
-
#tag_location ⇒ Object
Returns the value of attribute tag_location.
Instance Method Summary collapse
- #determine_known_ids(feature_directory, tag_prefix) ⇒ Object
-
#initialize ⇒ UniqueTestCaseTagger
constructor
A new instance of UniqueTestCaseTagger.
- #scan_for_tagged_tests(feature_directory, tag_prefix) ⇒ Object
- #tag_tests(feature_directory, tag_prefix, explicit_indexes = {}) ⇒ Object
- #validate_test_ids(feature_directory, tag_prefix) ⇒ Object
Constructor Details
#initialize ⇒ UniqueTestCaseTagger
Returns a new instance of UniqueTestCaseTagger.
11 12 13 14 |
# File 'lib/cuke_cataloger/unique_test_case_tagger.rb', line 11 def initialize @file_line_increases = Hash.new(0) @tag_location = :adjacent end |
Instance Attribute Details
#tag_location ⇒ Object
Returns the value of attribute tag_location.
8 9 10 |
# File 'lib/cuke_cataloger/unique_test_case_tagger.rb', line 8 def tag_location @tag_location end |
Instance Method Details
#determine_known_ids(feature_directory, tag_prefix) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cuke_cataloger/unique_test_case_tagger.rb', line 77 def determine_known_ids(feature_directory, tag_prefix) known_ids = [] found_tagged_objects = scan_for_tagged_tests(feature_directory, tag_prefix).collect { |result| result[:object] } found_tagged_objects.each do |element| if element.is_a?(CukeModeler::Row) row_id = row_id_for(element) known_ids << row_id if well_formed_sub_id?(row_id) else known_ids << test_id_for(element) end end known_ids end |
#scan_for_tagged_tests(feature_directory, tag_prefix) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cuke_cataloger/unique_test_case_tagger.rb', line 40 def scan_for_tagged_tests(feature_directory, tag_prefix) @results = [] @known_id_tags = {} set_id_tag(tag_prefix) set_test_suite_model(feature_directory) @tests.each do |test| add_to_results(test) if has_id_tag?(test) if test.is_a?(CukeModeler::Outline) test.examples.each do |example| if has_id_parameter?(example) example_rows_for(example).each do |row| add_to_results(row) if has_row_id?(row) end end end end end @results end |
#tag_tests(feature_directory, tag_prefix, explicit_indexes = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cuke_cataloger/unique_test_case_tagger.rb', line 16 def tag_tests(feature_directory, tag_prefix, explicit_indexes = {}) warn("This script will potentially rewrite all of your feature files. Please be patient and remember to tip your source control system.") @known_id_tags = {} set_id_tag(tag_prefix) set_test_suite_model(feature_directory) @start_indexes = merge_indexes(default_start_indexes(determine_known_ids(feature_directory, tag_prefix)), explicit_indexes) @next_index = @start_indexes[:primary] # Analysis and output @tests.each do |test| case when test.is_a?(CukeModeler::Scenario) process_scenario(test) when test.is_a?(CukeModeler::Outline) process_outline(test) else raise("Unknown test type: #{test.class.to_s}") end end end |
#validate_test_ids(feature_directory, tag_prefix) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cuke_cataloger/unique_test_case_tagger.rb', line 64 def validate_test_ids(feature_directory, tag_prefix) @results = [] @known_id_tags = {} set_id_tag(tag_prefix) set_test_suite_model(feature_directory) @features.each { |feature| validate_feature(feature) } @tests.each { |test| validate_test(test) } @results end |