lexis_nexis_api 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,143 @@
1
+ require 'rubygems'
2
+
3
+ ENV["RAILS_ENV"] = "test"
4
+ require File.expand_path(File.dirname(__FILE__) + "../../../../../config/environment")
5
+ require 'test_help'
6
+
7
+ require 'test/unit'
8
+ require 'active_support'
9
+ require 'active_support/test_case'
10
+ require File.dirname(__FILE__) + '/../lib/lexis_nexis_api'
11
+ require File.dirname(__FILE__) + '/../lib/lexis_nexis_api/xml_samples'
12
+ require 'rexml/document'
13
+
14
+ def address_hash(options={})
15
+ {
16
+ :type => 'current',
17
+ :valid_from => '2010-01-02',
18
+ :valid_to => '2020-12-31',
19
+ :municipality => 'Madison',
20
+ :region => 'WI',
21
+ :postal_code => '53711',
22
+ :country_code => 'US',
23
+ :address1 => '1234 Main St',
24
+ :address2 => '',
25
+ }.merge(options)
26
+ end
27
+
28
+
29
+ #
30
+ # xml: the XML string to search
31
+ #
32
+ # node_name: the name of the node to find in given XML
33
+ #
34
+ # options:
35
+ # :attributes => { :attr_name => :attr_value }
36
+ #
37
+ # :content => 'content of this node'
38
+ #
39
+ # :child => {
40
+ # :node_name => 'ChildNodeName',
41
+ # :attributes => { :attr_name => :attr_value },
42
+ # :content => 'Child content'
43
+ # }
44
+ #
45
+ def assert_node(xml, node_name, options={})
46
+ # we're using REXML here because it seems that neither Nokogiri nor Hpricot
47
+ # parse the multi-element XPath query properly, returning false positives.
48
+ # I did validate the query against an external XPath validator too.
49
+ doc = REXML::Document.new(xml)
50
+ q = xpath_query_for(node_name, options)
51
+ assert REXML::XPath.match(doc, q).size > 0, "Could not find < #{q} > in:\n#{xml}"
52
+ end
53
+
54
+ def assert_no_node(xml, node_name, options={})
55
+ doc = REXML::Document.new(xml)
56
+ q = xpath_query_for(node_name, options)
57
+ assert REXML::XPath.match(doc, q).empty?, "Expected not to find < #{q} > in:\n#{xml}"
58
+ end
59
+
60
+ def background_check_hash(options={})
61
+ {
62
+ :account => '123456',
63
+ :password => 'Secret',
64
+ :position_applied_for => 'Pastor',
65
+ :package_id => '2112',
66
+ :client_reference1 => '',
67
+ :client_reference2 => '',
68
+ :order_as_user_id => 'joeuser',
69
+ :order_as_account_suffix => 'TST',
70
+ :contact_email => 'me@example.com',
71
+ :licenses => [],
72
+ :person_names => [],
73
+ :postal_addresses => [],
74
+ }.merge(options)
75
+ end
76
+
77
+ def license_hash(options={})
78
+ {
79
+ :valid_from => '2001-02-03',
80
+ :valid_to => '2004-05-06',
81
+ :country_code => 'US',
82
+ :license_number => 'A1B2C3D4',
83
+ :license_region => 'CA',
84
+ }.merge(options)
85
+ end
86
+
87
+ def name_hash(options={})
88
+ {
89
+ :type => 'subject',
90
+ :first_name => 'Joe',
91
+ :middle_name => 'X',
92
+ :last_name => 'Tester',
93
+ }.merge(options)
94
+ end
95
+
96
+ def ssnv_hash(options={})
97
+ {
98
+ :ssn => '123456789',
99
+ :date_of_birth => '1950-01-02'
100
+ }.merge(options)
101
+ end
102
+
103
+ #
104
+ # constructs an XPath query like:
105
+ # //License[@validFrom="1999-01-01" and @validTo="2001-02-03"]
106
+ #
107
+ # or
108
+ #
109
+ # //LicenseNumber[.="1234ABC"]
110
+ #
111
+ # or
112
+ #
113
+ # //PersonName[@type="subject"]/GivenName[.="First1"]
114
+ #
115
+ def xpath_query_for(node_name, options={})
116
+ xpath_query = "#{options[:is_child] ? '/' : '//'}#{node_name}"
117
+ extras = []
118
+ extras += [%Q{.="#{options[:content]}"}] if options[:content]
119
+
120
+ extras += options[:attributes].map do |k,v|
121
+ %Q{@#{k}="#{v}"}
122
+ end if options[:attributes]
123
+
124
+ xpath_query << "[#{extras.join(' and ')}]" unless extras.empty?
125
+
126
+ if options[:child]
127
+ child = options.delete(:child)
128
+ child_options = {
129
+ :is_child => true,
130
+ :attributes => child[:attributes],
131
+ :content => child[:content],
132
+ :child => child[:child]
133
+ }
134
+ return xpath_query << "#{xpath_query_for(child[:node_name], child_options)}"
135
+ else
136
+ xpath_query
137
+ end
138
+ end
139
+
140
+ def xtest(*args)
141
+ file = File.basename(caller.first)
142
+ puts "Disabled test [#{file}]: #{args.first}"
143
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lexis_nexis_api
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 4
10
+ version: 1.0.4
11
+ platform: ruby
12
+ authors:
13
+ - Jeff Emminger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-07-30 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: nokogiri
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: net/http
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: net/https
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: ""
64
+ email:
65
+ - jeff@7compass.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - .gitignore
74
+ - Gemfile
75
+ - README.md
76
+ - Rakefile
77
+ - doc/AdminRequest.xsd
78
+ - doc/AdminResponse.xsd
79
+ - doc/CPBackgroundReports.xsd
80
+ - doc/CPScreenings.xsd
81
+ - doc/admin.wsdl
82
+ - lexis_nexis_api.gemspec
83
+ - lib/lexis_nexis_api.rb
84
+ - lib/lexis_nexis_api/background_check.rb
85
+ - lib/lexis_nexis_api/password_change.rb
86
+ - lib/lexis_nexis_api/remote_actions.rb
87
+ - lib/lexis_nexis_api/version.rb
88
+ - lib/lexis_nexis_api/xml_helper.rb
89
+ - lib/lexis_nexis_api/xml_samples.rb
90
+ - test/background_check_test.rb
91
+ - test/lexis_nexis_api_test.rb
92
+ - test/password_change_test.rb
93
+ - test/remote_actions_test.rb
94
+ - test/test_helper.rb
95
+ has_rdoc: true
96
+ homepage: http://github.com/7compass/lexis_nexis_api
97
+ licenses:
98
+ - MIT
99
+ post_install_message:
100
+ rdoc_options: []
101
+
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ requirements: []
123
+
124
+ rubyforge_project: lexis_nexis_api
125
+ rubygems_version: 1.3.7
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: Lexis Nexis Api gem
129
+ test_files:
130
+ - test/background_check_test.rb
131
+ - test/lexis_nexis_api_test.rb
132
+ - test/password_change_test.rb
133
+ - test/remote_actions_test.rb
134
+ - test/test_helper.rb