Class: Cucumber::Formatter::MessageBuilder
- Inherits:
-
Object
- Object
- Cucumber::Formatter::MessageBuilder
- Includes:
- Console, Io, MessageHandlers, Messages::Helpers::TimeConversion
- Defined in:
- lib/cucumber/formatter/message_builder.rb
Direct Known Subclasses
Constant Summary
Constants included from ANSIColor
Constants included from Term::ANSIColor
Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP
Instance Method Summary collapse
-
#initialize(config) ⇒ MessageBuilder
constructor
A new instance of MessageBuilder.
- #on_attach_called(event) ⇒ Object
- #on_envelope(event) ⇒ Object
Methods included from Console
#collect_snippet_data, #collect_undefined_parameter_type_names, #do_print_passing_wip, #do_print_profile_information, #do_print_snippets, #do_print_undefined_parameter_type_snippet, #exception_message_string, #format_step, #format_string, #indent, #linebreaks, #print_element_messages, #print_elements, #print_exception, #print_passing_wip, #print_profile_information, #print_snippets, #print_statistics
Methods included from ANSIColor
apply_custom_colors, #cukes, #green_cukes, #red_cukes, #yellow_cukes
Methods included from Term::ANSIColor
#attributes, included, #uncolored
Methods included from Duration
Methods included from MessageHandlers
#store_current_test_run_hook_started_id
Methods included from Io
ensure_dir, ensure_file, ensure_io, included, io?, url?
Constructor Details
#initialize(config) ⇒ MessageBuilder
Returns a new instance of MessageBuilder.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cucumber/formatter/message_builder.rb', line 19 def initialize(config) @config = config @ast_lookup = AstLookup.new(config) @repository = Cucumber::Repository.new @test_run_started_id = config.test_run_started_id # Fake Query objects @test_case_by_step_id = {} @pickle_id_by_test_case_id = {} @pickle_id_step_by_test_step_id = {} @hook_id_by_test_step_id = {} @step_definition_ids_by_test_step_id = {} @step_match_arguments_by_test_step_id = {} # Ensure all handlers for events occur after all ivars are instantiated config.on_event :gherkin_source_parsed, &method(:on_gherkin_source_parsed) config.on_event :hook_test_step_created, &method(:on_hook_test_step_created) config.on_event :step_activated, &method(:on_step_activated) config.on_event :test_case_created, &method(:on_test_case_created) config.on_event :test_case_ready, &method(:on_test_case_ready) config.on_event :test_case_started, &method(:on_test_case_started) config.on_event :test_case_finished, &method(:on_test_case_finished) config.on_event :test_run_started, &method(:on_test_run_started) config.on_event :test_run_finished, &method(:on_test_run_finished) config.on_event :test_step_created, &method(:on_test_step_created) config.on_event :test_step_started, &method(:on_test_step_started) config.on_event :test_step_finished, &method(:on_test_step_finished) config.on_event :attach_called, &method(:on_attach_called) config.on_event :envelope, &method(:on_envelope) end |
Instance Method Details
#on_attach_called(event) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cucumber/formatter/message_builder.rb', line 62 def on_attach_called(event) = if @current_test_run_hook_started_id.nil? { test_step_id: @current_test_step_id, test_case_started_id: @current_test_case_started_id, media_type: event.media_type, file_name: event.filename, timestamp: (Time.now) } else { test_run_hook_started_id: @current_test_run_hook_started_id, media_type: event.media_type, file_name: event.filename, timestamp: (Time.now) } end streamed_file = event.src.encoding == Encoding::BINARY if streamed_file [:content_encoding] = Cucumber::Messages::AttachmentContentEncoding::BASE64 [:body] = Base64.strict_encode64(event.src) else [:content_encoding] = Cucumber::Messages::AttachmentContentEncoding::IDENTITY [:body] = event.src.is_a?(Hash) ? event.src.to_json : event.src end = Cucumber::Messages::Envelope.new(attachment: Cucumber::Messages::Attachment.new(**)) @config.event_bus.envelope() end |
#on_envelope(event) ⇒ Object
58 59 60 |
# File 'lib/cucumber/formatter/message_builder.rb', line 58 def on_envelope(event) store_current_test_run_hook_started_id(event) end |