Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions lib/cucumber/formatter/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def initialize(config)

# 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 = {}

Expand Down Expand Up @@ -115,25 +114,23 @@ def on_step_definition_registered(event)
end

def on_test_case_created(event)
@pickle_id_by_test_case_id[event.test_case.id] = event.pickle.id
end

def on_test_case_ready(event)
message = Cucumber::Messages::Envelope.new(
test_case: Cucumber::Messages::TestCase.new(
id: event.test_case.id,
pickle_id: fake_query_pickle_id(event.test_case),
pickle_id: event.pickle.id,
test_steps: event.test_case.test_steps.map { |step| test_step_to_message(step) },
test_run_started_id: @test_run_started_id
)
)

# TODO: This may be a redundant update. But for now we're leaving this in whilst we're in the transitory phase
@repository.update(message)

output_envelope(message)
end

def on_test_case_ready(_event)
# We now publish all the relevant information and data in the `on_test_case_created` handler
:no_op
end

def on_test_case_started(event)
# For any new test_case_started events, we must ALWAYS generate a new id for a new run
@current_test_case_started_id = @config.id_generator.new_id
Expand Down Expand Up @@ -410,12 +407,6 @@ def fake_query_hook_id(test_step)

raise TestStepUnknownError, "No hook found for #{test_step.id} }. Known: #{@hook_id_by_test_step_id.keys}"
end

def fake_query_pickle_id(test_case)
return @pickle_id_by_test_case_id[test_case.id] if @pickle_id_by_test_case_id.key?(test_case.id)

raise TestCaseUnknownError, "No pickle found for #{test_case.id} }. Known: #{@pickle_id_by_test_case_id.keys}"
end
end
end
end