wirecardmapper 0.8.0 → 0.9.0

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.
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,39 @@
1
- require 'rubygems'
2
-
3
1
  $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require "bundler/setup"
4
+
5
+ require 'mongo_mapper'
4
6
  require 'wirecardmapper'
7
+ require 'rspec'
8
+ require 'database_cleaner'
5
9
 
6
10
  FIXTURES_PATH = "#{File.dirname(__FILE__)}/fixtures"
7
11
 
8
12
  WirecardMapper::Config.server_uri = "http://localhost/issuer/client"
9
13
  WirecardMapper::Config.server_port = 8080
10
- WirecardMapper::Config.login = "000000315ED21E8A";
11
- WirecardMapper::Config.password = "FDJqLhoRX";
12
- WirecardMapper::Config.mode = "test"
14
+ WirecardMapper::Config.login = "000000315ED21E8A"
15
+ WirecardMapper::Config.password = "FDJqLhoRX"
16
+ WirecardMapper::Config.mode = "live"
13
17
  WirecardMapper::Config.entity_id = "000000315ED21F74"
14
18
  WirecardMapper::Config.product_id = 11
19
+ WirecardMapper::Config.currency = "EUR"
15
20
 
16
21
  RSpec.configure do |config|
22
+ config.mock_with :rspec
23
+
24
+ config.before(:suite) do
25
+ MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
26
+ MongoMapper.database = "wirecardmapper_test"
27
+
28
+ DatabaseCleaner[:mongo_mapper].strategy = :truncation
29
+ end
30
+
31
+ config.before(:each) do
32
+ DatabaseCleaner.start
33
+ end
34
+
35
+ config.after(:each) do
36
+ DatabaseCleaner.clean
37
+ end
38
+ end
17
39
 
18
- end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe "config" do
4
+ it 'should set by methods' do
5
+ WirecardMapper::Config.server_uri = "http://localhost/issuer/client"
6
+ WirecardMapper::Config.server_port = 8080
7
+ WirecardMapper::Config.login = "000000315ED21E8A"
8
+ WirecardMapper::Config.password = "FDJqLhoRX"
9
+ WirecardMapper::Config.mode = "live"
10
+ WirecardMapper::Config.entity_id = "000000315ED21F74"
11
+ WirecardMapper::Config.product_id = 11
12
+
13
+ WirecardMapper::Config.server_uri.should eql("http://localhost/issuer/client")
14
+ WirecardMapper::Config.server_port.should eql(8080)
15
+ WirecardMapper::Config.login.should eql("000000315ED21E8A")
16
+ WirecardMapper::Config.password.should eql("FDJqLhoRX")
17
+ WirecardMapper::Config.mode.should eql("live")
18
+ WirecardMapper::Config.entity_id.should eql("000000315ED21F74")
19
+ WirecardMapper::Config.product_id.should eql(11)
20
+ end
21
+
22
+ it 'should set by hash' do
23
+ WirecardMapper::Config.config = {
24
+ :server_uri => "http://localhost/issuer/client",
25
+ :server_port => 8080,
26
+ :login => "000000315ED21E8A",
27
+ :password => "FDJqLhoRX",
28
+ :mode => "live",
29
+ :entity_id => "000000315ED21F74",
30
+ :product_id => 11
31
+ }
32
+
33
+ WirecardMapper::Config.server_uri.should eql("http://localhost/issuer/client")
34
+ WirecardMapper::Config.server_port.should eql(8080)
35
+ WirecardMapper::Config.login.should eql("000000315ED21E8A")
36
+ WirecardMapper::Config.password.should eql("FDJqLhoRX")
37
+ WirecardMapper::Config.mode.should eql("live")
38
+ WirecardMapper::Config.entity_id.should eql("000000315ED21F74")
39
+ WirecardMapper::Config.product_id.should eql(11)
40
+ end
41
+
42
+ it 'should set by block' do
43
+ WirecardMapper::Config.config do |c|
44
+ c.server_uri = "http://localhost/issuer/client"
45
+ c.server_port = 8080
46
+ c.login = "000000315ED21E8A"
47
+ c.password = "FDJqLhoRX"
48
+ c.mode = "live"
49
+ c.entity_id = "000000315ED21F74"
50
+ c.product_id = 11
51
+ end
52
+
53
+ WirecardMapper::Config.server_uri.should eql("http://localhost/issuer/client")
54
+ WirecardMapper::Config.server_port.should eql(8080)
55
+ WirecardMapper::Config.login.should eql("000000315ED21E8A")
56
+ WirecardMapper::Config.password.should eql("FDJqLhoRX")
57
+ WirecardMapper::Config.mode.should eql("live")
58
+ WirecardMapper::Config.entity_id.should eql("000000315ED21F74")
59
+ WirecardMapper::Config.product_id.should eql(11)
60
+ end
61
+
62
+ it 'should set by yml' do
63
+ File.open("#{FIXTURES_PATH}/config/wirecardmapper.yml") do |config_file|
64
+ WirecardMapper::Config.config = YAML.load(config_file.read)['development']
65
+
66
+ WirecardMapper::Config.server_uri.should eql("http://localhost/issuer/client")
67
+ WirecardMapper::Config.server_port.should eql(8080)
68
+ WirecardMapper::Config.login.should eql("000000315ED21E8A")
69
+ WirecardMapper::Config.password.should eql("FDJqLhoRX")
70
+ WirecardMapper::Config.mode.should eql("live")
71
+ WirecardMapper::Config.entity_id.should eql("000000315ED21F74")
72
+ WirecardMapper::Config.product_id.should eql(11)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe WirecardMapper do
4
+
5
+ it "should build create_card request" do
6
+ request = WirecardMapper.create_card_request(:card_data => {:card_comment => 'Test'})
7
+
8
+ request.should_not be_blank
9
+ request.should include("<entity-id>000000315ED21F74</entity-id>")
10
+ request.should include("<product-id>11</product-id>")
11
+ request.should include("<card-comment>Test</card-comment>")
12
+ end
13
+
14
+ it "should build create_card request with entity-id id" do
15
+ request = WirecardMapper.create_card_request(:entity_id => 123, :card_data => {:card_comment => 'Test'})
16
+
17
+ request.should_not be_blank
18
+ request.should include("<entity-id>123</entity-id>")
19
+ end
20
+
21
+ it "should build update_card_info request" do
22
+ request = WirecardMapper.update_card_info_request(:card_data => {:card_id => 123})
23
+
24
+ request.should_not be_blank
25
+ request.should include("<card-id>123</card-id>")
26
+ end
27
+
28
+ it "should build card_info request" do
29
+ request = WirecardMapper.card_info_request(:card_data => {:card_id => 123})
30
+
31
+ request.should_not be_blank
32
+ request.should include("<card-id>123</card-id>")
33
+ end
34
+
35
+ it "should build submit_payment request" do
36
+ request = WirecardMapper.submit_payment_request(:card_data => {:card_id => 123}, :payment_data => {:amount => {:text => 1000, :attributes => {:currency => 'EUR'}}})
37
+
38
+ request.should_not be_blank
39
+ request.should include("<card-id>123</card-id>")
40
+ request.should include("<amount currency=\"EUR\">1000</amount>")
41
+ end
42
+
43
+ it "should build payment_info request" do
44
+ request = WirecardMapper.payment_info_request
45
+
46
+ request.should_not be_blank
47
+ end
48
+
49
+ it "should build change_card_status request" do
50
+ request = WirecardMapper.change_card_status_request(:card_data => {:card_id => 123}, :status_code => 'blocked')
51
+
52
+ request.should_not be_blank
53
+ request.should include("<card-id>123</card-id>")
54
+ request.should include("<status-code>blocked</status-code>")
55
+ end
56
+
57
+ end
@@ -1,28 +1,41 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Response" do
3
+ describe WirecardMapper::Response do
4
4
 
5
- it "should get card status" do
5
+ it "should get responses" do
6
6
  File.open("#{FIXTURES_PATH}/create_card.xml") do |file|
7
7
  response = WirecardMapper::Response.new(file)
8
8
  response.card_id.should eql('47ae07020a010018157db66065da6e5c')
9
- response.card_number.should eql(5274569796581777)
9
+ response.card_number.should eql("5274569796581777")
10
10
  response.status_code.should eql('activated')
11
11
  response.status_message.should eql('Active card')
12
12
  response.expiration_month.should eql('08')
13
13
  response.expiration_year.should eql(2011)
14
- response.card_security_code.should eql(618)
14
+ response.card_security_code.should eql("018")
15
15
  response.card_level.should eql('P')
16
16
  response.card_comment.should eql('This is a test card')
17
17
  response.issuing_date.should eql('2010-08-06')
18
- response.bank_code.should eql(51230800)
19
- response.account_number.should eql(2345)
18
+ response.bank_code.should eql("51230800")
19
+ response.account_number.should eql("2345")
20
20
  response.currency.should eql('EUR')
21
21
  response.first_name.should eql('WD SCP Test')
22
22
  response.last_name.should eql('WD SCP Test')
23
23
  response.issuer_consumer_id.should eql(2345)
24
24
  end
25
25
  end
26
-
26
+
27
+ it "should get exception message" do
28
+ File.open("#{FIXTURES_PATH}/wirecard_server_down.xml") do |file|
29
+ lambda { WirecardMapper::Response.new(file) }.should raise_exception(WirecardMapper::Exception, "No valid wirecard issuer-response")
30
+ end
31
+ end
32
+
33
+ it "should get NoMethodError if xml node not exists" do
34
+ File.open("#{FIXTURES_PATH}/create_card_without_card_id.xml") do |file|
35
+ response = WirecardMapper::Response.new(file)
36
+ lambda { response.card_id }.should raise_exception(NoMethodError)
37
+ end
38
+ end
39
+
27
40
  end
28
41
 
metadata CHANGED
@@ -1,118 +1,179 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: wirecardmapper
3
- version: !ruby/object:Gem::Version
4
- hash: 63
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 8
9
- - 0
10
- version: 0.8.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Alexander Klaiber
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-12-03 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: nokogiri
12
+ date: 2012-09-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 1
32
- - 4
33
- - 2
34
- version: 1.4.2
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: money
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
35
38
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
38
47
  name: uuid
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
39
55
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: nokogiri
64
+ requirement: !ruby/object:Gem::Requirement
41
65
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 1
46
- segments:
47
- - 2
48
- - 3
49
- - 1
50
- version: 2.3.1
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
51
70
  type: :runtime
52
- version_requirements: *id002
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: forgery
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
53
126
  description: A Ruby Object Mapper for Wirecard XML interface
54
127
  email: alex.klaiber@gmail.com
55
128
  executables: []
56
-
57
129
  extensions: []
58
-
59
- extra_rdoc_files:
130
+ extra_rdoc_files:
60
131
  - README.rdoc
61
- - LICENSE
62
- files:
63
- - LICENSE
132
+ files:
64
133
  - README.rdoc
65
134
  - Rakefile
66
- - lib/wirecardmapper.rb
67
- - lib/wirecardmapper/version.rb
68
- - lib/wirecardmapper/net_http_monkeypatch.rb
69
- - lib/wirecardmapper/xml.rb
70
- - lib/wirecardmapper/config.rb
135
+ - lib/wirecardmapper/exception.rb
71
136
  - lib/wirecardmapper/response.rb
72
- - spec/fixtures/create_card.xml
73
- - spec/unit/response_spec.rb
137
+ - lib/wirecardmapper/models/base.rb
138
+ - lib/wirecardmapper/models/mongo_mapper.rb
139
+ - lib/wirecardmapper/config.rb
140
+ - lib/wirecardmapper/railtie.rb
141
+ - lib/wirecardmapper/version.rb
142
+ - lib/wirecardmapper.rb
74
143
  - spec/spec_helper.rb
75
- - spec/functional/request_spec.rb
76
- - templates/get_card_info.xml
77
- - templates/create_card.xml
78
- - templates/update_card_info.xml
79
- - templates/submit_payment.xml
80
- - templates/main.xml
81
- - templates/change_card_status.xml
82
- - templates/get_payment_info.xml
83
- has_rdoc: true
144
+ - spec/functional/models/base_spec.rb
145
+ - spec/functional/models/mongo_mapper_spec.rb
146
+ - spec/functional/wirecardmapper_spec.rb
147
+ - spec/unit/request_spec.rb
148
+ - spec/unit/response_spec.rb
149
+ - spec/unit/config_spec.rb
150
+ - spec/fixtures/wirecard_server_down.xml
151
+ - spec/fixtures/config/wirecardmapper.yml
152
+ - spec/fixtures/create_card.xml
153
+ - spec/fixtures/create_card_without_card_id.xml
154
+ - spec/fixtures/get_card_info.xml
84
155
  homepage: http://github.com/aklaiber/wirecardmapper
85
156
  licenses: []
86
-
87
157
  post_install_message:
88
158
  rdoc_options: []
89
-
90
- require_paths:
159
+ require_paths:
91
160
  - lib
92
- required_ruby_version: !ruby/object:Gem::Requirement
161
+ required_ruby_version: !ruby/object:Gem::Requirement
93
162
  none: false
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
- version: "0"
101
- required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
168
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
110
173
  requirements: []
111
-
112
174
  rubyforge_project:
113
- rubygems_version: 1.3.7
175
+ rubygems_version: 1.8.23
114
176
  signing_key:
115
177
  specification_version: 3
116
178
  summary: A Ruby Object Mapper for Wirecard XML interface
117
179
  test_files: []
118
-