Class: QAT::Formatter::Scenario::Name
- Inherits:
-
Object
- Object
- QAT::Formatter::Scenario::Name
- Includes:
- Cucumber::Formatter::Io, Helper
- Defined in:
- lib/qat/formatter/scenario/name.rb
Overview
Instance Method Summary collapse
-
#initialize(config) ⇒ Name
constructor
A new instance of Name.
- #on_test_case_started(event) ⇒ Object
- #on_test_run_finished(_event) ⇒ Object
- #scenario_name ⇒ Object
Methods included from Helper
#assign_print_feature, #on_test_case_finished, #on_test_step_finished, #on_test_step_started, #print_assign_step, #print_scenario_results, #print_scenario_start
Methods included from UtilityFuction
#background, #calculate_row_number, #create_feature_hash, #features?, #get_example_values, #get_lines_from_scenario
Methods included from Builder
#add_values_to_examples, #build, #create_id_from_scenario_source, #feature, #get_scenario_tags, #scenario
Constructor Details
#initialize(config) ⇒ Name
Returns a new instance of Name.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/qat/formatter/scenario/name.rb', line 12 def initialize(config) @config = config @io = ensure_io(config.out_stream, config.error_stream) # @to_file = (@io != $stdout) @to_file = @io @scenarios = {} @repeated = {} @ast_lookup = ::Cucumber::Formatter::AstLookup.new(config) @feature_hashes = [] config.on_event :test_case_started, &method(:on_test_case_started) config.on_event :test_run_finished, &method(:on_test_run_finished) end |
Instance Method Details
#on_test_case_started(event) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/qat/formatter/scenario/name.rb', line 26 def on_test_case_started event @examples_values = [] build(event.test_case, @ast_lookup) @current_feature = @feature_hash scenario_name end |
#on_test_run_finished(_event) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/qat/formatter/scenario/name.rb', line 49 def on_test_run_finished(_event) if @to_file content = { scenarios: @scenarios, repeated: @repeated } @io.write (JSON.pretty_generate(content)) @io.flush end end |
#scenario_name ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/qat/formatter/scenario/name.rb', line 33 def scenario_name if @to_file if @scenarios.values.include?(@scenario[:name]) file_colon_line = "#{@current_feature[:uri]}:#{@scenario[:line]}" unless @scenarios.keys.include?(file_colon_line) @repeated[@scenario[:name]] ||= [] @repeated[@scenario[:name]] << "#{@current_feature[:uri]}:#{@scenario[:line]}" end end file_colon_line = "#{@current_feature[:uri]}:#{@scenario[:line]}" @scenarios[file_colon_line] = @scenario[:name] else Kernel.puts "#{@scenario[:name]}: #{file_colon_line}" end end |