rbraspag 0.0.2

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.
@@ -0,0 +1,190 @@
1
+ #encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
+
4
+ describe Braspag::Crypto::JarWebservice do
5
+ let!(:crypto_key) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
6
+ let!(:uri) {"http://localhost:9292"}
7
+ let!(:crypt) {Braspag::Crypto::JarWebservice.new(crypto_key, uri)}
8
+ let!(:crypt_invalid) {Braspag::Crypto::JarWebservice.new("00000", uri)}
9
+ let! (:key) {"5u0ZN5qk8eQNuuGPHrcsk0rfi7YclF6s+ZXCE+G4uG4ztfRJrrOALlf81ra7k7p7"}
10
+
11
+ after (:each) do
12
+ FakeWeb.clean_registry
13
+ end
14
+
15
+ context "when encrypt data" do
16
+
17
+ it "should return a string" do
18
+ FakeWeb.register_uri(
19
+ :post,
20
+ "http://localhost:9292/v1/encrypt.json",
21
+ :body => <<-EOJSON
22
+ {"encrypt":"5u0ZN5qk8eQNuuGPHrcsk0rfi7YclF6s+ZXCE+G4uG4ztfRJrrOALlf81ra7k7p7"}
23
+ EOJSON
24
+ )
25
+
26
+ crypt.encrypt(:nome => "Chapulin", :sobrenome => "Colorado").should == key
27
+ end
28
+
29
+ it "should raise a error with invalid params" do
30
+ expect {
31
+ crypt.encrypt(9999)
32
+ }.to raise_error(Braspag::IncompleteParams)
33
+ end
34
+
35
+ it "should raise an error with invalid params after process" do
36
+ FakeWeb.register_uri(
37
+ :post,
38
+ "http://localhost:9292/v1/encrypt.json",
39
+ :body => <<-EOJSON
40
+ {
41
+ "msg" : "INVALID FORMAT"
42
+ }
43
+ EOJSON
44
+ )
45
+
46
+ expect {
47
+ crypt.encrypt(:venda => "value")
48
+ }.to raise_error(Braspag::IncompleteParams)
49
+ end
50
+
51
+ it "should raise an error with invalid params after process" do
52
+ FakeWeb.register_uri(
53
+ :post,
54
+ "http://localhost:9292/v1/encrypt.json",
55
+ :body => <<-EOJSON
56
+ INVALIDO
57
+ EOJSON
58
+ )
59
+
60
+ expect {
61
+ crypt.encrypt(:venda => "value")
62
+ }.to raise_error(Braspag::UnknownError)
63
+ end
64
+
65
+ it "should raise an error with invalid params after process" do
66
+ FakeWeb.register_uri(
67
+ :post,
68
+ "http://localhost:9292/v1/encrypt.json",
69
+ :body => <<-EOJSON
70
+ {
71
+ "msg" : "INVALID FIELDS"
72
+ }
73
+ EOJSON
74
+ )
75
+
76
+ expect {
77
+ crypt.encrypt(:venda => nil)
78
+ }.to raise_error(Braspag::IncompleteParams)
79
+ end
80
+
81
+ it "should raise an error with invalid crypt key" do
82
+ FakeWeb.register_uri(
83
+ :post,
84
+ "http://localhost:9292/v1/encrypt.json",
85
+ :body => <<-EOJSON
86
+ {
87
+ "msg" : "INVALID KEY"
88
+ }
89
+ EOJSON
90
+ )
91
+
92
+ expect {
93
+ crypt_invalid.encrypt(:venda => "value")
94
+ }.to raise_error(Braspag::InvalidCryptKey)
95
+ end
96
+
97
+ end
98
+
99
+ context "when decrypt data" do
100
+
101
+ it "should return a hash" do
102
+ FakeWeb.register_uri(
103
+ :post,
104
+ "http://localhost:9292/v1/decrypt.json",
105
+ :body => <<-EOJSON
106
+ {"fields":{"nome":"Chapulin","sobrenome":"Colorado"}}
107
+ EOJSON
108
+ )
109
+
110
+ crypt.decrypt(key, [:nome, :sobrenome])[:nome].should eql("Chapulin")
111
+ end
112
+
113
+ it "should raise a error with invalid encrypted key" do
114
+ FakeWeb.register_uri(
115
+ :post,
116
+ "http://localhost:9292/v1/decrypt.json",
117
+ :body => <<-EOJSON
118
+ {
119
+ "msg" : "INVALID ENCRYPTED STRING"
120
+ }
121
+ EOJSON
122
+ )
123
+
124
+ expect {
125
+ crypt.decrypt("1", [:nome, :sobrenome])
126
+ }.to raise_error(Braspag::InvalidEncryptedKey)
127
+ end
128
+
129
+ it "should raise a error with invalid encrypted key" do
130
+ expect {
131
+ crypt.decrypt(1, [:nome, :sobrenome])
132
+ }.to raise_error(Braspag::InvalidEncryptedKey)
133
+ end
134
+
135
+
136
+ it "should raise a error with invalid fields" do
137
+ expect {
138
+ crypt.decrypt(key, 9999)
139
+ }.to raise_error(Braspag::IncompleteParams)
140
+ end
141
+
142
+ it "should raise a error with invalid fields" do
143
+ FakeWeb.register_uri(
144
+ :post,
145
+ "http://localhost:9292/v1/decrypt.json",
146
+ :body => <<-EOJSON
147
+ {
148
+ "msg" : "INVALID FIELDS"
149
+ }
150
+ EOJSON
151
+ )
152
+
153
+ expect {
154
+ crypt.decrypt(key, [:nome, :sobrenome])
155
+ }.to raise_error(Braspag::IncompleteParams)
156
+ end
157
+
158
+ it "should raise an error with invalid params after process" do
159
+ FakeWeb.register_uri(
160
+ :post,
161
+ "http://localhost:9292/v1/decrypt.json",
162
+ :body => <<-EOJSON
163
+ INVALIDO
164
+ EOJSON
165
+ )
166
+
167
+
168
+ expect {
169
+ crypt.decrypt(key, [:nome, :sobrenome])
170
+ }.to raise_error(Braspag::UnknownError)
171
+ end
172
+
173
+ it "should raise an error with invalid crypt key" do
174
+ FakeWeb.register_uri(
175
+ :post,
176
+ "http://localhost:9292/v1/decrypt.json",
177
+ :body => <<-EOJSON
178
+ {
179
+ "msg" : "INVALID KEY"
180
+ }
181
+ EOJSON
182
+ )
183
+
184
+ expect {
185
+ crypt_invalid.decrypt(key, [:nome, :sobrenome])
186
+ }.to raise_error(Braspag::InvalidCryptKey)
187
+ end
188
+
189
+ end
190
+ end
@@ -0,0 +1,165 @@
1
+ #encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
+
4
+ describe Braspag::Crypto::Webservice do
5
+ let!(:merchant_id) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
6
+ let!(:connection) {Braspag::Connection.new(merchant_id, :test)}
7
+ let!(:connection_invalid) {Braspag::Connection.new("{83BE7E7F-698A-6C74-F820-AE359C2A07A1}", :test)}
8
+ let!(:crypt) {Braspag::Crypto::Webservice.new(connection)}
9
+ let!(:crypt_invalid) {Braspag::Crypto::Webservice.new(connection_invalid)}
10
+
11
+ context "encrypt" do
12
+ let!(:key) {"XXXXX"}
13
+
14
+ context "consistencies" do
15
+ it "should return error with invalid data" do
16
+ expect {
17
+ crypt.encrypt("INVALID DATA")
18
+ }.to raise_error(Braspag::IncompleteParams)
19
+ end
20
+
21
+ it "should return error with invalid data after process" do
22
+ body_invalid = <<-EOXML
23
+ SERVER was unable to process
24
+ EOXML
25
+ FakeWeb.register_uri(:post,
26
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
27
+ :body => body_invalid )
28
+ expect {
29
+ crypt.encrypt(:key => "INVALID DATA")
30
+ }.to raise_error(Braspag::UnknownError)
31
+ FakeWeb.clean_registry
32
+ end
33
+
34
+ it "should return error with invalid merchant_id" do
35
+ body_invalid = <<-EOXML
36
+ <?xml version="1.0" encoding="utf-8"?>
37
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
38
+ <soap:Body><EncryptRequestResponse xmlns="https://www.pagador.com.br/webservice/BraspagGeneralService">
39
+ <EncryptRequestResult>Erro BP 011</EncryptRequestResult></EncryptRequestResponse>
40
+ </soap:Body></soap:Envelope>
41
+ EOXML
42
+ FakeWeb.register_uri(:post,
43
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
44
+ :body => body_invalid )
45
+ expect {
46
+ crypt.encrypt(:key => "value")
47
+ }.to raise_error(Braspag::InvalidMerchantId)
48
+ FakeWeb.clean_registry
49
+ end
50
+
51
+ it "should return error with invalid ip" do
52
+ body_invalid = <<-EOXML
53
+ <?xml version="1.0" encoding="utf-8"?>
54
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
55
+ <soap:Body><EncryptRequestResponse xmlns="https://www.pagador.com.br/webservice/BraspagGeneralService">
56
+ <EncryptRequestResult>Erro BP 067</EncryptRequestResult></EncryptRequestResponse>
57
+ </soap:Body></soap:Envelope>
58
+ EOXML
59
+ FakeWeb.register_uri(:post,
60
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
61
+ :body => body_invalid )
62
+ expect {
63
+ crypt.encrypt(:key => "value")
64
+ }.to raise_error(Braspag::InvalidIP)
65
+ FakeWeb.clean_registry
66
+ end
67
+ end
68
+
69
+ it "should return a string" do
70
+ FakeWeb.register_uri(:post,
71
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
72
+ :body => <<-EOXML
73
+ <?xml version='1.0' encoding='utf-8'?>
74
+ <soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
75
+ <soap:Body>
76
+ <EncryptRequestResponse xmlns='https://www.pagador.com.br/webservice/BraspagGeneralService'>
77
+ <EncryptRequestResult>#{key}</EncryptRequestResult>
78
+ </EncryptRequestResponse>
79
+ </soap:Body></soap:Envelope>
80
+ EOXML
81
+ )
82
+ crypt.encrypt(:key => "value").should == key
83
+ FakeWeb.clean_registry
84
+ end
85
+ end
86
+
87
+ context "when decrypt data" do
88
+
89
+ context "consistencies" do
90
+ it "should return error with invalid data" do
91
+ expect {
92
+ crypt.decrypt(1213123)
93
+ }.to raise_error(Braspag::IncompleteParams)
94
+ end
95
+
96
+ it "should return error with invalid data" do
97
+ body_invalid = <<-EOXML
98
+ SERVER was unable to process
99
+ EOXML
100
+ FakeWeb.register_uri(:post,
101
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
102
+ :body => body_invalid )
103
+ expect {
104
+ crypt.decrypt("{sdfsdf34543534}")
105
+ }.to raise_error(Braspag::UnknownError)
106
+ FakeWeb.clean_registry
107
+ end
108
+
109
+ it "should return error with invalid merchant_id" do
110
+ body_invalid = <<-EOXML
111
+ <?xml version="1.0" encoding="utf-8"?>
112
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
113
+ <soap:Body><DecryptRequestResponse xmlns="https://www.pagador.com.br/webservice/BraspagGeneralService">
114
+ <DecryptRequestResult><string>Erro BP 011</string></DecryptRequestResult>
115
+ </DecryptRequestResponse></soap:Body></soap:Envelope>
116
+ EOXML
117
+ FakeWeb.register_uri(:post,
118
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
119
+ :body => body_invalid )
120
+ expect {
121
+ crypt_invalid.decrypt("{sdfsdf34543534}")
122
+ }.to raise_error(Braspag::InvalidMerchantId)
123
+ FakeWeb.clean_registry
124
+ end
125
+
126
+ it "should return error with invalid ip" do
127
+ body_invalid = <<-EOXML
128
+ <?xml version="1.0" encoding="utf-8"?>
129
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
130
+ <soap:Body><DecryptRequestResponse xmlns="https://www.pagador.com.br/webservice/BraspagGeneralService">
131
+ <DecryptRequestResult><string>Erro BP 068</string></DecryptRequestResult>
132
+ </DecryptRequestResponse></soap:Body></soap:Envelope>
133
+ EOXML
134
+ FakeWeb.register_uri(:post,
135
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
136
+ :body => body_invalid )
137
+ expect {
138
+ crypt.decrypt("{sdfsdf34543534}")
139
+ }.to raise_error(Braspag::InvalidIP)
140
+ FakeWeb.clean_registry
141
+ end
142
+ end
143
+
144
+ it "should return a string" do
145
+ FakeWeb.register_uri(:post,
146
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
147
+ :body => <<-EOXML
148
+ <?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
149
+ <soap:Body><DecryptRequestResponse xmlns='https://www.pagador.com.br/webservice/BraspagGeneralService'>
150
+ <DecryptRequestResult>
151
+ <string>CODPAGAMENTO=18</string>
152
+ <string>VENDAID=teste123</string>
153
+ <string>VALOR=100</string>
154
+ <string>PARCELAS=1</string>
155
+ <string>NOME=comprador</string>
156
+ </DecryptRequestResult></DecryptRequestResponse>
157
+ </soap:Body></soap:Envelope>
158
+ EOXML
159
+ )
160
+ crypt.decrypt("{sdfsdf34543534}")[:parcelas].should eql("1")
161
+ FakeWeb.clean_registry
162
+ end
163
+
164
+ end
165
+ end
data/spec/eft_spec.rb ADDED
@@ -0,0 +1,238 @@
1
+ #encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
+
4
+ describe Braspag::Eft do
5
+
6
+ let!(:merchant_id) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
7
+ let!(:connection) {Braspag::Connection.new(merchant_id, :test)}
8
+
9
+
10
+ describe ".new" do
11
+
12
+ it "should raise an error when no connection is given" do
13
+ expect {
14
+ Braspag::Eft.new("", {})
15
+ }.to raise_error(Braspag::InvalidConnection)
16
+ end
17
+
18
+ it "should raise an error when :order_id is not present" do
19
+ expect {
20
+ Braspag::Eft.new(connection, {
21
+ :amount => "10000",
22
+ :payment_method => "11"
23
+ })
24
+ }.to raise_error(Braspag::IncompleteParams)
25
+ end
26
+
27
+ it "should raise an error when :amount is not present" do
28
+ expect {
29
+ Braspag::Eft.new(connection, {
30
+ :order_id => "12",
31
+ :payment_method => "11"
32
+ })
33
+ }.to raise_error(Braspag::IncompleteParams)
34
+ end
35
+
36
+ it "should raise an error when :payment_method is not present" do
37
+ expect {
38
+ Braspag::Eft.new(connection, {
39
+ :order_id => "13",
40
+ :amount => "12000"
41
+ })
42
+ }.to raise_error(Braspag::IncompleteParams)
43
+ end
44
+
45
+ it "should raise an error when :order_id is less than 1 character" do
46
+ expect {
47
+ Braspag::Eft.new(connection, {
48
+ :order_id => "",
49
+ :amount => "12300",
50
+ :payment_method => "11"
51
+ })
52
+ }.to raise_error(Braspag::InvalidOrderId)
53
+ end
54
+
55
+ it "should raise an error when :order_id is more than 50 characters" do
56
+ expect {
57
+ Braspag::Eft.new(connection, {
58
+ :order_id => "1" * 51,
59
+ :amount => "1200",
60
+ :payment_method => "11"
61
+ })
62
+ }.to raise_error(Braspag::InvalidOrderId)
63
+ end
64
+
65
+ it "should raise an error when :customer_name is less than 1 character" do
66
+ expect {
67
+ Braspag::Eft.new(connection, {
68
+ :order_id => "102",
69
+ :amount => "4200",
70
+ :payment_method => "11",
71
+ :customer_name => ""
72
+ })
73
+ }.to raise_error(Braspag::InvalidCustomerName)
74
+ end
75
+
76
+ it "should raise an error when :customer_name is more than 255 characters" do
77
+ expect {
78
+ Braspag::Eft.new(connection, {
79
+ :order_id => "112",
80
+ :amount => "12100",
81
+ :payment_method => "11",
82
+ :customer_name => "A" * 256
83
+ })
84
+ }.to raise_error(Braspag::InvalidCustomerName)
85
+ end
86
+
87
+ it "should raise an error when :customer_id is less than 11 characters" do
88
+ expect {
89
+ Braspag::Eft.new(connection, {
90
+ :order_id => "23",
91
+ :amount => "25100",
92
+ :payment_method => "11",
93
+ :customer_id => "2" * 10
94
+ })
95
+ }.to raise_error(Braspag::InvalidCustomerId)
96
+ end
97
+
98
+ it "should raise an error when :customer_id is more than 18 characters" do
99
+ expect {
100
+ Braspag::Eft.new(connection, {
101
+ :order_id => "90",
102
+ :amount => "9000",
103
+ :payment_method => "11",
104
+ :customer_id => "3" * 19
105
+ })
106
+ }.to raise_error(Braspag::InvalidCustomerId)
107
+ end
108
+
109
+ it "should raise an error when :installments is less than 1 character" do
110
+ expect {
111
+ Braspag::Eft.new(connection, {
112
+ :order_id => "900",
113
+ :amount => "9200",
114
+ :payment_method => "11",
115
+ :installments => ""
116
+ })
117
+ }.to raise_error(Braspag::InvalidInstallments)
118
+ end
119
+
120
+ it "should raise an error when :installments is more than 2 characters" do
121
+ expect {
122
+ Braspag::Eft.new(connection, {
123
+ :order_id => "91",
124
+ :amount => "8000",
125
+ :payment_method => "11",
126
+ :installments => "5" * 3
127
+ })
128
+ }.to raise_error(Braspag::InvalidInstallments)
129
+ end
130
+
131
+ it "should raise an error when :installments is not a number" do
132
+ expect {
133
+ Braspag::Eft.new(connection, {
134
+ :order_id => "91",
135
+ :amount => "8000",
136
+ :payment_method => "11",
137
+ :installments => "A" * 2
138
+ })
139
+ }.to raise_error(Braspag::InvalidInstallments)
140
+ end
141
+
142
+ it "should raise an error when :has_interest is not boolean" do
143
+ expect {
144
+ Braspag::Eft.new(connection, {
145
+ :order_id => "76",
146
+ :amount => "5000",
147
+ :payment_method => "11",
148
+ :has_interest => []
149
+ })
150
+ }.to raise_error(Braspag::InvalidHasInterest)
151
+ end
152
+ end
153
+
154
+ describe ".generate" do
155
+ let!(:crypto_key) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
156
+ let!(:braspag_crypto_jar_webservice) {Braspag::Crypto::JarWebservice.new(crypto_key, "http://localhost:9292")}
157
+ let!(:braspag_crypto_webservice) {Braspag::Crypto::Webservice.new(connection)}
158
+
159
+
160
+ it "should return form fields in strategy without crypto" do
161
+ html = <<-EOHTML
162
+ <form id="form_tef_1234123125" name="form_tef_1234123125" action="https://homologacao.pagador.com.br/pagador/passthru.asp" method="post">
163
+ <input type="text" name="VendaId" value="1234123125" />
164
+ <input type="text" name="Valor" value="12300" />
165
+ <input type="text" name="codpagamento" value="11" />
166
+ <input type="text" name="Id_Loja" value="{84BE7E7F-698A-6C74-F820-AE359C2A07C2}" />
167
+ </form>
168
+ <script type="text/javascript" charset="utf-8">
169
+ document.forms["form_tef_1234123125"].submit();
170
+ </script>
171
+ EOHTML
172
+
173
+ Braspag::Eft.new(connection , {
174
+ :order_id => "1234123125",
175
+ :amount => "12300",
176
+ :payment_method => "11"
177
+ }).generate.should == html
178
+ end
179
+
180
+ it "should return form fields in strategy with braspag.jar crypto service" do
181
+ FakeWeb.register_uri(:post,
182
+ "http://localhost:9292/v1/encrypt.json",
183
+ :body => <<-EOJSON
184
+ {"encrypt":"5u0ZN5qk8eQNuuGPHrcsk0rfi7YclF6s+ZXCE+G4uG4ztfRJrrOALlf81ra7k7p7"}
185
+ EOJSON
186
+ )
187
+
188
+ html = <<-EOHTML
189
+ <form id="form_tef_1234123125" name="form_tef_1234123125" action="https://homologacao.pagador.com.br/pagador/passthru.asp" method="post">
190
+ <input type="text" name="crypt" value="5u0ZN5qk8eQNuuGPHrcsk0rfi7YclF6s+ZXCE+G4uG4ztfRJrrOALlf81ra7k7p7" />
191
+ <input type="text" name="Id_Loja" value="{84BE7E7F-698A-6C74-F820-AE359C2A07C2}" />
192
+ </form>
193
+ <script type="text/javascript" charset="utf-8">
194
+ document.forms["form_tef_1234123125"].submit();
195
+ </script>
196
+ EOHTML
197
+
198
+ Braspag::Eft.new(connection , {
199
+ :order_id => "1234123125",
200
+ :amount => "12300",
201
+ :payment_method => "11"
202
+ } , braspag_crypto_jar_webservice ).generate.should == html
203
+
204
+ FakeWeb.clean_registry
205
+
206
+ end
207
+
208
+ let!(:key) { "12312312312313123123" }
209
+ it "should return form fields in strategy with braspag crypto webservice" do
210
+
211
+ FakeWeb.register_uri(:post,
212
+ "https://homologacao.pagador.com.br/BraspagGeneralService/BraspagGeneralService.asmx",
213
+ :body => "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><soap:Body><EncryptRequestResponse xmlns='https://www.pagador.com.br/webservice/BraspagGeneralService'><EncryptRequestResult>#{key}</EncryptRequestResult></EncryptRequestResponse></soap:Body></soap:Envelope>" )
214
+
215
+ html = <<-EOHTML
216
+ <form id="form_tef_1234123125" name="form_tef_1234123125" action="https://homologacao.pagador.com.br/pagador/passthru.asp" method="post">
217
+ <input type="text" name="crypt" value="#{key}" />
218
+ <input type="text" name="Id_Loja" value="{84BE7E7F-698A-6C74-F820-AE359C2A07C2}" />
219
+ </form>
220
+ <script type="text/javascript" charset="utf-8">
221
+ document.forms["form_tef_1234123125"].submit();
222
+ </script>
223
+ EOHTML
224
+
225
+ Braspag::Eft.new(connection , {
226
+ :order_id => "1234123125",
227
+ :amount => "12300",
228
+ :payment_method => "11"
229
+ } , braspag_crypto_webservice ).generate.should == html
230
+
231
+ FakeWeb.clean_registry
232
+
233
+ end
234
+
235
+
236
+ end
237
+
238
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'rbraspag'
3
+ require 'fakeweb'
4
+
5
+ RSpec.configure do |config|
6
+ config.mock_with :rspec
7
+
8
+ HTTPI.log = false
9
+ end