match_point 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module MatchPoint
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
@@ -3,9 +3,10 @@ module MatchPoint
3
3
 
4
4
  SPEC_NODE="MatchPointSpec"
5
5
 
6
- def self.from_xml template, xml
6
+ def self.from_xml template, xml, error_node
7
7
  instance = self.new template
8
8
  instance.xml= xml
9
+ instance.error_node = error_node
9
10
  instance
10
11
  end
11
12
 
@@ -15,12 +16,8 @@ module MatchPoint
15
16
  instance
16
17
  end
17
18
 
18
- def initialize template
19
- @template= Nokogiri::XML(template)
20
- @xml = Nokogiri::XML(template)
21
- @nodes_paths = {}
22
-
23
- synchronize_object_to_xml
19
+ def error_node= error_node
20
+ @error_node = error_node
24
21
  end
25
22
 
26
23
  def xml= an_xml
@@ -57,8 +54,20 @@ module MatchPoint
57
54
  end
58
55
  end
59
56
 
57
+ def success?
58
+ !@xml.at_xpath(@error_node[:path]).has_attribute?(@error_node[:attribute])
59
+ end
60
+
60
61
  protected
61
62
 
63
+ def initialize template
64
+ @template= Nokogiri::XML(template)
65
+ @xml = Nokogiri::XML(template)
66
+ @nodes_paths = {}
67
+
68
+ synchronize_object_to_xml
69
+ end
70
+
62
71
  def node_path node_name
63
72
  @nodes_paths[node_name]
64
73
  end
@@ -26,8 +26,27 @@ describe MatchPoint do
26
26
  </TIX>"
27
27
  end
28
28
 
29
- let(:response) { MatchPoint::XmlInstance.from_xml(template, response_xml) }
30
- let(:request) { MatchPoint::XmlInstance.from_hash(template, {:auth_id=>"NeWVaLue"})}
29
+ let(:failed_response_xml) do
30
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
31
+ <TIX errCd=\"123\" version=\"TIX 4.11.0\">
32
+ <AccessControl method=\"AccessControlAuthenticate\">
33
+ <AuthRequest>
34
+ <AuthID>1ua5J1gJz3TryPEMQZkeWFarOagSJvYY</AuthID>
35
+ </AuthRequest>
36
+ </AccessControl>
37
+ </TIX>"
38
+ end
39
+
40
+ let(:error_node) {
41
+ {
42
+ :path => "//TIX",
43
+ :attribute => "errCd"
44
+ }
45
+ }
46
+
47
+ let(:response) { MatchPoint::XmlInstance.from_xml(template, response_xml, error_node) }
48
+ let(:failed_response) { MatchPoint::XmlInstance.from_xml(template, failed_response_xml, error_node) }
49
+ let(:request) { MatchPoint::XmlInstance.from_hash(template, {:auth_id => "NeWVaLue"}) }
31
50
 
32
51
  it "should get the auth_id from the xml if the template for that field is defined" do
33
52
  response.auth_id.should == "1ua5J1gJz3TryPEMQZkeWFarOagSJvYY"
@@ -67,6 +86,13 @@ describe MatchPoint do
67
86
  response.at_xpath("/TIX/AccessControl/AuthRequest/AuthID").text.should == "1ua5J1gJz3TryPEMQZkeWFarOagSJvYY"
68
87
  end
69
88
 
89
+ it "should success" do
90
+ response.success?.should be_true
91
+ end
92
+
93
+ it "should not success" do
94
+ failed_response.success?.should be_false
95
+ end
70
96
 
71
97
  end
72
98
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: match_point
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: