lib/soaspec/matchers.rb in soaspec-0.0.45 vs lib/soaspec/matchers.rb in soaspec-0.0.46

- old
+ new

@@ -25,31 +25,31 @@ "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 |expected| +RSpec::Matchers.define :contain_key do |path| match do |actual| - expect(actual.api_class.include_key?(actual.response, expected)).to be true + 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 #{expected}" + "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_xpath do |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 XPath returns no value + expect { exchange[xpath] }.to_not raise_error # Error will be raised if Path returns no value end failure_message do |actual| "expected that #{actual.api_class.response_body(actual.response, format: :raw)} would have element at xpath '#{xpath}'" end end -RSpec::Matchers.alias_matcher :have_element_at_path, :have_element_at_xpath +RSpec::Matchers.alias_matcher :have_element_at_xpath, :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