lib/soaspec/matchers.rb in soaspec-0.2.29 vs lib/soaspec/matchers.rb in soaspec-0.2.30

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require_relative 'core_ext/hash' require_relative 'errors' # Whether response has any element with the provided value RSpec::Matchers.define :contain_value do |expected| @@ -83,12 +85,12 @@ failure_list = [] failure_list << "#{exchange.status_code} not valid status code" unless exchange.successful_status_code? exchange.exchange_handler.expected_mandatory_elements.each do |mandatory_element_path| begin exchange[mandatory_element_path] - rescue NoElementAtPath => error - failure_list << error.message + rescue NoElementAtPath => e + failure_list << e.message end end exchange.exchange_handler.expected_mandatory_xpath_values.each do |path, value| failure_list << "Expected value at xpath '#{path}' to be '#{value}' but was '#{exchange[path]}'" unless exchange[path] == value end @@ -100,15 +102,17 @@ match do |actual| exchange = exchange_from actual failure_list = collect_errors exchange raise failure_list.to_s unless failure_list.empty? + true end match_when_negated do |actual| exchange = exchange_from actual failure_list = collect_errors exchange raise "Expected failure. Status code is #{exchange.status_code}" if failure_list.empty? + true end end