lib/soaspec/matchers.rb in soaspec-0.0.47 vs lib/soaspec/matchers.rb in soaspec-0.0.48

- old
+ new

@@ -24,32 +24,23 @@ failure_message do |actual| "expected that #{actual.api_class.response_body(actual.response, format: :raw)} would contain value #{expected}" end end -# Whether expected element exists in body -RSpec::Matchers.define :contain_key do |path| - match do |actual| - expect(actual).to have_element_at_path path - end - - failure_message do |actual| - "expected that #{actual.api_class.response_body(actual.response, format: :hash)} would contain key #{path}" - end -end - # Whether an element exists at expected xpath RSpec::Matchers.define :have_element_at_path do |xpath| match do |exchange| expect { exchange[xpath] }.to_not raise_error # Error will be raised if Path returns no value end + # TODO: Would be better to print failure message failure_message do |actual| - "expected that #{actual.api_class.response_body(actual.response, format: :raw)} would have element at xpath '#{xpath}'" + "expected that #{actual.api_class.response_body(actual.response, format: :raw)} would have element at path '#{xpath}'" end end RSpec::Matchers.alias_matcher :have_element_at_xpath, :have_element_at_path +RSpec::Matchers.alias_matcher :contain_key, :have_element_at_path # Whether an element at xpath (defined by key) has value (defined by value). # @param [Hash] expected_hash Xpath => Value pair (e.g. '//xmlns:GetWeatherResult' => 'Data Not Found') RSpec::Matchers.define :have_xpath_value do |expected_hash| match do |exchange| \ No newline at end of file