rbraspag 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/spec/eft_spec.rb CHANGED
@@ -2,161 +2,153 @@
2
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
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)
5
+ let!(:key) { "1234561246" }
6
+ describe ".payment_method_from_id" do
7
+ it 'Eft' do
8
+ Braspag::Eft.payment_method_from_id(31).should == :unibanco
9
+ Braspag::Eft.payment_method_from_id(31).should be_kind_of Symbol
16
10
  end
11
+ end
17
12
 
18
- it "should raise an error when :order_id is not present" do
19
- expect {
20
- Braspag::Eft.new(connection, {
21
- :amount => "100.00",
22
- :payment_method => :bradesco
23
- })
24
- }.to raise_error(Braspag::IncompleteParams)
25
- end
13
+ describe ".generate" do
14
+ context "consistencies" do
15
+
16
+ it "should raise an error when :order_id is not present" do
17
+ expect {
18
+ Braspag::Eft.generate({
19
+ :amount => "100.00",
20
+ :payment_method => :bradesco
21
+ })
22
+ }.to raise_error(Braspag::IncompleteParams)
23
+ end
26
24
 
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 => :bradesco
32
- })
33
- }.to raise_error(Braspag::IncompleteParams)
34
- end
25
+ it "should raise an error when :amount is not present" do
26
+ expect {
27
+ Braspag::Eft.generate({
28
+ :order_id => "12",
29
+ :payment_method => :bradesco
30
+ })
31
+ }.to raise_error(Braspag::IncompleteParams)
32
+ end
35
33
 
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 => "120.00"
41
- })
42
- }.to raise_error(Braspag::IncompleteParams)
43
- end
34
+ it "should raise an error when :payment_method is not present" do
35
+ expect {
36
+ Braspag::Eft.generate({
37
+ :order_id => "13",
38
+ :amount => "120.00"
39
+ })
40
+ }.to raise_error(Braspag::IncompleteParams)
41
+ end
44
42
 
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 => "123.00",
50
- :payment_method => :bradesco
51
- })
52
- }.to raise_error(Braspag::InvalidOrderId)
53
- end
43
+ it "should raise an error when :order_id is less than 1 character" do
44
+ expect {
45
+ Braspag::Eft.generate({
46
+ :order_id => "",
47
+ :amount => "123.00",
48
+ :payment_method => :bradesco
49
+ })
50
+ }.to raise_error(Braspag::InvalidOrderId)
51
+ end
54
52
 
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 => "12.00",
60
- :payment_method => :bradesco
61
- })
62
- }.to raise_error(Braspag::InvalidOrderId)
63
- end
53
+ it "should raise an error when :order_id is more than 50 characters" do
54
+ expect {
55
+ Braspag::Eft.generate({
56
+ :order_id => "1" * 51,
57
+ :amount => "12.00",
58
+ :payment_method => :bradesco
59
+ })
60
+ }.to raise_error(Braspag::InvalidOrderId)
61
+ end
64
62
 
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 => "42.00",
70
- :payment_method => :bradesco,
71
- :customer_name => ""
72
- })
73
- }.to raise_error(Braspag::InvalidCustomerName)
74
- end
63
+ it "should raise an error when :customer_name is less than 1 character" do
64
+ expect {
65
+ Braspag::Eft.generate({
66
+ :order_id => "102",
67
+ :amount => "42.00",
68
+ :payment_method => :bradesco,
69
+ :customer_name => ""
70
+ })
71
+ }.to raise_error(Braspag::InvalidCustomerName)
72
+ end
75
73
 
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 => "121.00",
81
- :payment_method => :bradesco,
82
- :customer_name => "A" * 256
83
- })
84
- }.to raise_error(Braspag::InvalidCustomerName)
85
- end
74
+ it "should raise an error when :customer_name is more than 255 characters" do
75
+ expect {
76
+ Braspag::Eft.generate({
77
+ :order_id => "112",
78
+ :amount => "121.00",
79
+ :payment_method => :bradesco,
80
+ :customer_name => "A" * 256
81
+ })
82
+ }.to raise_error(Braspag::InvalidCustomerName)
83
+ end
86
84
 
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 => "251.00",
92
- :payment_method => :bradesco,
93
- :customer_id => "2" * 10
94
- })
95
- }.to raise_error(Braspag::InvalidCustomerId)
96
- end
85
+ it "should raise an error when :customer_id is less than 11 characters" do
86
+ expect {
87
+ Braspag::Eft.generate({
88
+ :order_id => "23",
89
+ :amount => "251.00",
90
+ :payment_method => :bradesco,
91
+ :customer_id => "2" * 10
92
+ })
93
+ }.to raise_error(Braspag::InvalidCustomerId)
94
+ end
97
95
 
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 => "90.00",
103
- :payment_method => :bradesco,
104
- :customer_id => "3" * 19
105
- })
106
- }.to raise_error(Braspag::InvalidCustomerId)
107
- end
96
+ it "should raise an error when :customer_id is more than 18 characters" do
97
+ expect {
98
+ Braspag::Eft.generate({
99
+ :order_id => "90",
100
+ :amount => "90.00",
101
+ :payment_method => :bradesco,
102
+ :customer_id => "3" * 19
103
+ })
104
+ }.to raise_error(Braspag::InvalidCustomerId)
105
+ end
108
106
 
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 => "92.00",
114
- :payment_method => :bradesco,
115
- :installments => ""
116
- })
117
- }.to raise_error(Braspag::InvalidInstallments)
118
- end
107
+ it "should raise an error when :installments is less than 1 character" do
108
+ expect {
109
+ Braspag::Eft.generate({
110
+ :order_id => "900",
111
+ :amount => "92.00",
112
+ :payment_method => :bradesco,
113
+ :installments => ""
114
+ })
115
+ }.to raise_error(Braspag::InvalidInstallments)
116
+ end
119
117
 
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 => "80.00",
125
- :payment_method => :bradesco,
126
- :installments => "5" * 3
127
- })
128
- }.to raise_error(Braspag::InvalidInstallments)
129
- end
118
+ it "should raise an error when :installments is more than 2 characters" do
119
+ expect {
120
+ Braspag::Eft.generate({
121
+ :order_id => "91",
122
+ :amount => "80.00",
123
+ :payment_method => :bradesco,
124
+ :installments => "5" * 3
125
+ })
126
+ }.to raise_error(Braspag::InvalidInstallments)
127
+ end
130
128
 
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 => "80.00",
136
- :payment_method => :bradesco,
137
- :installments => "A" * 2
138
- })
139
- }.to raise_error(Braspag::InvalidInstallments)
140
- end
129
+ it "should raise an error when :installments is not a number" do
130
+ expect {
131
+ Braspag::Eft.generate({
132
+ :order_id => "91",
133
+ :amount => "80.00",
134
+ :payment_method => :bradesco,
135
+ :installments => "A" * 2
136
+ })
137
+ }.to raise_error(Braspag::InvalidInstallments)
138
+ end
141
139
 
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 => "50.00",
147
- :payment_method => :bradesco,
148
- :has_interest => []
149
- })
150
- }.to raise_error(Braspag::InvalidHasInterest)
140
+ it "should raise an error when :has_interest is not boolean" do
141
+ expect {
142
+ Braspag::Eft.generate({
143
+ :order_id => "76",
144
+ :amount => "50.00",
145
+ :payment_method => :bradesco,
146
+ :has_interest => []
147
+ })
148
+ }.to raise_error(Braspag::InvalidHasInterest)
149
+ end
151
150
  end
152
- end
153
151
 
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
152
  it "should return form fields in strategy without crypto" do
161
153
  html = <<-EOHTML
162
154
  <form id="form_tef_1234123125" name="form_tef_1234123125" action="https://homologacao.pagador.com.br/pagador/passthru.asp" method="post">
@@ -174,11 +166,11 @@ describe Braspag::Eft do
174
166
  </script>
175
167
  EOHTML
176
168
 
177
- Braspag::Eft.new(connection , {
169
+ Braspag::Eft.generate({
178
170
  :order_id => "1234123125",
179
171
  :amount => "123.00",
180
172
  :payment_method => :bradesco
181
- }).generate.should == html
173
+ }).should == html
182
174
  end
183
175
 
184
176
  it "should return form fields in strategy with braspag.jar crypto service" do
@@ -199,17 +191,16 @@ describe Braspag::Eft do
199
191
  </script>
200
192
  EOHTML
201
193
 
202
- Braspag::Eft.new(connection , {
194
+ Braspag::Eft.generate({
203
195
  :order_id => "1234123125",
204
196
  :amount => "123.00",
205
197
  :payment_method => :bradesco
206
- } , braspag_crypto_jar_webservice ).generate.should == html
198
+ } , Braspag::Crypto::JarWebservice ).should == html
207
199
 
208
200
  FakeWeb.clean_registry
209
201
 
210
202
  end
211
203
 
212
- let!(:key) { "12312312312313123123" }
213
204
  it "should return form fields in strategy with braspag crypto webservice" do
214
205
 
215
206
  FakeWeb.register_uri(:post,
@@ -226,23 +217,13 @@ describe Braspag::Eft do
226
217
  </script>
227
218
  EOHTML
228
219
 
229
- Braspag::Eft.new(connection , {
220
+ Braspag::Eft.generate({
230
221
  :order_id => "1234123125",
231
222
  :amount => "123.00",
232
223
  :payment_method => :bradesco
233
- } , braspag_crypto_webservice ).generate.should == html
224
+ } , Braspag::Crypto::Webservice ).should == html
234
225
 
235
226
  FakeWeb.clean_registry
236
-
237
227
  end
238
-
239
- context ".payment_method_from_id" do
240
- it 'Eft' do
241
- Braspag::Eft.payment_method_from_id(31).should == :unibanco
242
- Braspag::Eft.payment_method_from_id(31).should be_kind_of Symbol
243
- end
244
- end
245
-
246
228
  end
247
-
248
229
  end
data/spec/order_spec.rb CHANGED
@@ -2,33 +2,24 @@
2
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe Braspag::Order do
5
-
6
- let!(:merchant_id) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
7
- let!(:connection) {Braspag::Connection.new(merchant_id, :test)}
5
+ let!(:braspag_url) { "https://homologacao.pagador.com.br" }
8
6
 
9
7
  describe "#status" do
10
-
11
- it "should raise an error when no connection is given" do
12
- expect {
13
- Braspag::Order.status("", nil)
14
- }.to raise_error(Braspag::InvalidConnection)
15
- end
16
-
17
8
  it "should raise an error when no order_id is given" do
18
9
  expect {
19
- Braspag::Order.status(connection, nil)
10
+ Braspag::Order.status(nil)
20
11
  }.to raise_error(Braspag::InvalidOrderId)
21
12
  end
22
13
 
23
14
  it "should raise an error when order_id is empty" do
24
15
  expect {
25
- Braspag::Order.status(connection, "")
16
+ Braspag::Order.status("")
26
17
  }.to raise_error(Braspag::InvalidOrderId)
27
18
  end
28
19
 
29
20
  it "should raise an error when order_id is more than 50 characters" do
30
21
  expect {
31
- Braspag::Order.status(connection, "1" * 51)
22
+ Braspag::Order.status("1" * 51)
32
23
  }.to raise_error(Braspag::InvalidOrderId)
33
24
  end
34
25
 
@@ -41,17 +32,16 @@ describe Braspag::Order do
41
32
  xmlns="http://www.pagador.com.br/" />
42
33
  EOXML
43
34
 
44
- FakeWeb.register_uri(:post, "#{Braspag::Test::BASE_URL}/pagador/webservice/pedido.asmx/GetDadosPedido",
35
+ FakeWeb.register_uri(:post, "#{braspag_url}/pagador/webservice/pedido.asmx/GetDadosPedido",
45
36
  :body => xml)
46
37
 
47
38
  expect {
48
- Braspag::Order.status(connection, "sadpoakjspodqdouq09wduwq")
39
+ Braspag::Order.status("sadpoakjspodqdouq09wduwq")
49
40
  }.to raise_error(Braspag::Order::InvalidData)
50
41
 
51
- new_connection = Braspag::Connection.new("{12345678-1234-1234-1234-123456789012}", :test)
52
42
 
53
43
  expect {
54
- Braspag::Order.status(new_connection, "asdnasdniousa")
44
+ Braspag::Order.status("asdnasdniousa")
55
45
  }.to raise_error(Braspag::Order::InvalidData)
56
46
 
57
47
  FakeWeb.clean_registry
@@ -78,9 +68,9 @@ describe Braspag::Order do
78
68
  </DadosPedido>
79
69
  EOXML
80
70
 
81
- FakeWeb.register_uri(:post, "#{Braspag::Test::BASE_URL}/pagador/webservice/pedido.asmx/GetDadosPedido",
82
- :body => xml)
83
- order_info = Braspag::Order.status(connection, "12345")
71
+ FakeWeb.register_uri(:post, "#{braspag_url}/pagador/webservice/pedido.asmx/GetDadosPedido",
72
+ :body => xml)
73
+ order_info = Braspag::Order.status("12345")
84
74
  FakeWeb.clean_registry
85
75
  order_info
86
76
  }
@@ -108,11 +98,7 @@ describe Braspag::Order do
108
98
  it "should return a Hash with :#{key.to_s} key" do
109
99
  order_info[key].should == value
110
100
  end
111
-
112
101
  end
113
102
  end
114
-
115
103
  end
116
-
117
104
  end
118
-
data/spec/utils_spec.rb CHANGED
@@ -5,4 +5,6 @@ describe Braspag::Utils do
5
5
  it '.convert_decimal_to_string' do
6
6
  Braspag::Utils.convert_decimal_to_string(10.80).should == "10,80"
7
7
  end
8
+
9
+ pending "convert_to_map"
8
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbraspag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,12 +14,12 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2011-07-29 00:00:00.000000000 -03:00
17
+ date: 2011-08-04 00:00:00.000000000 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: cs-httpi
22
- requirement: &76986620 !ruby/object:Gem::Requirement
22
+ requirement: &85379830 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ! '>='
@@ -27,10 +27,10 @@ dependencies:
27
27
  version: 0.9.5.2
28
28
  type: :runtime
29
29
  prerelease: false
30
- version_requirements: *76986620
30
+ version_requirements: *85379830
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: json
33
- requirement: &76986410 !ruby/object:Gem::Requirement
33
+ requirement: &85379620 !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements:
36
36
  - - ! '>='
@@ -38,10 +38,10 @@ dependencies:
38
38
  version: '0'
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *76986410
41
+ version_requirements: *85379620
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: nokogiri
44
- requirement: &77028800 !ruby/object:Gem::Requirement
44
+ requirement: &85379390 !ruby/object:Gem::Requirement
45
45
  none: false
46
46
  requirements:
47
47
  - - ! '>='
@@ -49,10 +49,10 @@ dependencies:
49
49
  version: '0'
50
50
  type: :runtime
51
51
  prerelease: false
52
- version_requirements: *77028800
52
+ version_requirements: *85379390
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rspec
55
- requirement: &77028590 !ruby/object:Gem::Requirement
55
+ requirement: &85379180 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ! '>='
@@ -60,10 +60,10 @@ dependencies:
60
60
  version: '0'
61
61
  type: :development
62
62
  prerelease: false
63
- version_requirements: *77028590
63
+ version_requirements: *85379180
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: fakeweb
66
- requirement: &77028380 !ruby/object:Gem::Requirement
66
+ requirement: &85378970 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
69
  - - ! '>='
@@ -71,10 +71,10 @@ dependencies:
71
71
  version: '0'
72
72
  type: :development
73
73
  prerelease: false
74
- version_requirements: *77028380
74
+ version_requirements: *85378970
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: shoulda-matchers
77
- requirement: &77028170 !ruby/object:Gem::Requirement
77
+ requirement: &85378760 !ruby/object:Gem::Requirement
78
78
  none: false
79
79
  requirements:
80
80
  - - ! '>='
@@ -82,10 +82,10 @@ dependencies:
82
82
  version: '0'
83
83
  type: :development
84
84
  prerelease: false
85
- version_requirements: *77028170
85
+ version_requirements: *85378760
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: guard-rspec
88
- requirement: &77027960 !ruby/object:Gem::Requirement
88
+ requirement: &85378550 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ! '>='
@@ -93,10 +93,10 @@ dependencies:
93
93
  version: '0'
94
94
  type: :development
95
95
  prerelease: false
96
- version_requirements: *77027960
96
+ version_requirements: *85378550
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: guard-bundler
99
- requirement: &77027750 !ruby/object:Gem::Requirement
99
+ requirement: &85378340 !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements:
102
102
  - - ! '>='
@@ -104,10 +104,10 @@ dependencies:
104
104
  version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
- version_requirements: *77027750
107
+ version_requirements: *85378340
108
108
  - !ruby/object:Gem::Dependency
109
109
  name: ruby-debug19
110
- requirement: &77027540 !ruby/object:Gem::Requirement
110
+ requirement: &85378130 !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements:
113
113
  - - ! '>='
@@ -115,7 +115,7 @@ dependencies:
115
115
  version: '0'
116
116
  type: :development
117
117
  prerelease: false
118
- version_requirements: *77027540
118
+ version_requirements: *85378130
119
119
  description: rbraspag gem to use Braspag gateway
120
120
  email:
121
121
  - tinorj@gmail.com
@@ -135,6 +135,7 @@ files:
135
135
  - Guardfile
136
136
  - README.md
137
137
  - Rakefile
138
+ - config/braspag.yml
138
139
  - lib/rbraspag.rb
139
140
  - lib/rbraspag/bill.rb
140
141
  - lib/rbraspag/connection.rb
@@ -147,6 +148,7 @@ files:
147
148
  - lib/rbraspag/payment_method.rb
148
149
  - lib/rbraspag/utils.rb
149
150
  - lib/rbraspag/version.rb
151
+ - rbraspag-0.0.11.gem
150
152
  - rbraspag.gemspec
151
153
  - spec/bill_spec.rb
152
154
  - spec/connection_spec.rb