lib/shared_examples.rb in cucumber-compatibility-kit-12.0.0 vs lib/shared_examples.rb in cucumber-compatibility-kit-13.0.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'json' require 'rspec' require 'cucumber/messages' require 'messages_comparator' @@ -8,12 +10,12 @@ RSpec.shared_examples 'cucumber compatibility kit' do # Note: to use those examples, you need to define: # let(:example) { } # the name of the example to test # let(:messages) { } # the messages to validate - let(:example) { raise "`example` missing: add `let(:example) { example_name }` to your spec" } - let(:messages) { raise "`messages` missing: add `let(:messages) { ndjson }` to your spec" } + let(:example) { raise '`example` missing: add `let(:example) { example_name }` to your spec' } + let(:messages) { raise '`messages` missing: add `let(:messages) { ndjson }` to your spec' } let(:example_path) { Cucumber::CompatibilityKit.example_path(example) } let(:parsed_original) { parse_ndjson_file("#{example_path}/#{example}.feature.ndjson") } let(:parsed_generated) { parse_ndjson(messages) } @@ -43,10 +45,13 @@ def parse_ndjson(ndjson) Cucumber::Messages::NdjsonToMessageEnumerator.new(ndjson) end def message_type(message) - message.to_h.keys.first + # TODO: This is duplicate code - from messages_comparator:45 - It should live in a common helper methods module + message.to_h.each do |key, value| + return key unless value.nil? + end end def debug_lists(expected, obtained) return unless ENV['VERBOSE'] return if expected.sort == obtained.sort