lib/soaspec/matchers.rb in soaspec-0.0.5 vs lib/soaspec/matchers.rb in soaspec-0.0.6
- old
+ new
@@ -1,17 +1,24 @@
-RSpec::Matchers.define :contain do |expected|
- match do |actual|
- expect(actual.xml_response).to include expected
- end
-end
-
-RSpec::Matchers.define :have_element_at_xpath do |expected|
- match do |soap_class|
- expect(soap_class.xml_doc.at_xpath(expected, Soaspec::Environment.api_handler.namespaces).content).not_to be_empty
- end
-end
-
-RSpec::Matchers.define :have_xpath_value do |expected_hash|
- match do |soap_class|
- expect(soap_class.xml_doc.at_xpath(expected_hash.keys.first, Soaspec::Environment.api_handler.namespaces).content).to eq expected_hash.values.first
- end
+
+require_relative 'hash_methods'
+
+RSpec::Matchers.define :contain_value do |expected|
+ match do |actual|
+ expect(actual.response.body.include_value?(expected)).to be true
+ end
+
+ failure_message do |actual|
+ "expected that #{actual.response.body} would contain value #{expected}"
+ end
+end
+
+RSpec::Matchers.define :have_element_at_xpath do |expected|
+ match do |exchange|
+ expect(exchange.xml_doc.at_xpath(expected, Soaspec::Environment.api_handler.namespaces).content).not_to be_empty
+ end
+end
+
+RSpec::Matchers.define :have_xpath_value do |expected_hash|
+ match do |exchange|
+ expect(exchange.xml_doc.at_xpath(expected_hash.keys.first, Soaspec::Environment.api_handler.namespaces).content).to eq expected_hash.values.first
+ end
end
\ No newline at end of file