From 8c25fcdc8a7b745ec0bb735a5242154443bc7287 Mon Sep 17 00:00:00 2001 From: Austin Swaney Date: Wed, 13 Apr 2016 15:06:27 -0500 Subject: [PATCH] Added step to check for a tag in multiple messages. --- .ruby-version | 1 + lib/agent_fix/cucumber.rb | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..3361fb0 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +jruby-1.7.24 diff --git a/lib/agent_fix/cucumber.rb b/lib/agent_fix/cucumber.rb index 35a6cff..1319132 100644 --- a/lib/agent_fix/cucumber.rb +++ b/lib/agent_fix/cucumber.rb @@ -143,3 +143,26 @@ def anticipate_fix expect(found).to be(true), "Message not included in FIX messages\n #{error_accum}" end + +Then(/^the (?:fix|FIX) messages should include a message with(?: the tag)? "(.*)"$/) do |path| + expect(@message_scope).not_to be_nil, "No message scope defined" + + found = false + error_accum = "" + index = 1 + @message_scope.each do |m| + @message = m + begin + steps %Q{ +When I inspect the #{index}th FIX message +And the FIX message should have "#{path}" + } + found = true + rescue Exception => e + error_accum << "\n#{m.to_s.gsub!(/\001/, '|')}\n #{e}" + end + index += 1 + end + + expect(found).to be(true), "Tag not included in FIX messages\n #{error_accum}" +end