rbraspag 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ doc
4
4
  tags
5
5
  *.swp
6
6
  .bundle
7
+ .rvmrc
8
+
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbraspag (0.0.1)
5
- cs-httpi (= 0.9.5.2)
4
+ rbraspag (0.0.2)
5
+ cs-httpi (>= 0.9.5.2)
6
6
  json
7
7
  nokogiri
8
8
 
@@ -17,6 +17,9 @@ GEM
17
17
  fakeweb (1.3.0)
18
18
  guard (0.4.2)
19
19
  thor (~> 0.14.6)
20
+ guard-bundler (0.1.3)
21
+ bundler (>= 1.0.0)
22
+ guard (>= 0.2.2)
20
23
  guard-rspec (0.4.0)
21
24
  guard (>= 0.4.0)
22
25
  json (1.5.3)
@@ -50,6 +53,7 @@ PLATFORMS
50
53
 
51
54
  DEPENDENCIES
52
55
  fakeweb
56
+ guard-bundler
53
57
  guard-rspec
54
58
  rbraspag!
55
59
  rspec
data/Guardfile CHANGED
@@ -4,6 +4,7 @@ end
4
4
 
5
5
  guard 'rspec', :version => 2, :bundler => false do
6
6
  watch(%r{^spec/(.*)_spec\.rb$})
7
- watch(%r{^lib/(.*)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch(%r{^lib/rbraspag.rb$}) { "spec" }
8
+ watch(%r{^lib/rbraspag/(.*)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
9
  watch('spec/spec_helper.rb') { "spec" }
9
10
  end
data/lib/rbraspag/bill.rb CHANGED
@@ -1,5 +1,17 @@
1
+ require "bigdecimal"
2
+
1
3
  module Braspag
2
4
  class Bill
5
+ PAYMENT_METHOD = {
6
+ :bradesco => "06",
7
+ :cef => "07",
8
+ :hsbc => "08",
9
+ :bb => "09",
10
+ :real => "10",
11
+ :citibank => "13",
12
+ :itau => "14",
13
+ :unibanco => "26"
14
+ }
3
15
 
4
16
  MAPPING = {
5
17
  :merchant_id => "merchantId",
@@ -10,7 +22,8 @@ module Braspag
10
22
  :payment_method => "paymentMethod",
11
23
  :number => "boletoNumber",
12
24
  :instructions => "instructions",
13
- :expiration_date => "expirationDate"
25
+ :expiration_date => "expirationDate",
26
+ :emails => "emails"
14
27
  }
15
28
 
16
29
  def initialize(connection, params)
@@ -24,9 +37,17 @@ module Braspag
24
37
  @params[:expiration_date] = @params[:expiration_date].strftime("%d/%m/%y")
25
38
  end
26
39
 
40
+ if @params[:amount] && !@params[:amount].is_a?(BigDecimal)
41
+ @params[:amount] = BigDecimal.new(@params[:amount].to_s)
42
+ end
43
+
27
44
  ok?
28
45
  end
29
46
 
47
+ def [](key)
48
+ @params[key]
49
+ end
50
+
30
51
  def ok?
31
52
  raise IncompleteParams if @params[:order_id].nil? || @params[:amount].nil? || @params[:payment_method].nil?
32
53
 
@@ -50,21 +71,29 @@ module Braspag
50
71
  end
51
72
 
52
73
  unless @params[:expiration_date].nil?
53
- raise InvalidExpirationDate unless @params[:expiration_date].to_s.size == 8
74
+ date_regexp = /(0[1-9]|1[0-9]|2[0-9]|3[01])\/(0[1-9]|1[012])\/\d\d/
75
+ raise InvalidExpirationDate unless @params[:expiration_date].to_s =~ date_regexp
76
+ end
77
+
78
+ unless @params[:payment_method].is_a?(Symbol) && PAYMENT_METHOD[@params[:payment_method]]
79
+ raise InvalidPaymentMethod
54
80
  end
55
-
81
+
56
82
  true
57
83
  end
58
84
 
59
85
  def generate
60
- data = {}
61
- @params.each {|name, value|
62
- if MAPPING[name].nil?
63
- data[name] = value
86
+ data = MAPPING.inject({}) do |memo, k|
87
+ if k[0] == :payment_method
88
+ memo[k[1]] = PAYMENT_METHOD[@params[:payment_method]]
89
+ elsif k[0] == :amount
90
+ memo[k[1]] = convert_decimal_to_string(@params[:amount])
64
91
  else
65
- data[MAPPING[name]] = value
92
+ memo[k[1]] = @params[k[0]] || "";
66
93
  end
67
- }
94
+
95
+ memo
96
+ end
68
97
 
69
98
  request = ::HTTPI::Request.new uri
70
99
  request.body = data
@@ -78,10 +107,17 @@ module Braspag
78
107
  raise InvalidStringFormat if response[:message] == "Input string was not in a correct format."
79
108
  raise UnknownError if response[:status].nil?
80
109
 
110
+ response[:amount] = BigDecimal.new(response[:amount])
111
+
81
112
  response
82
113
  end
83
114
 
84
115
  protected
116
+ def convert_decimal_to_string(value)
117
+ cents = "0#{((value - value.to_i) * 100).to_i}".slice(-2,2)
118
+ integer = (value - (value - value.to_i)).to_i
119
+ "#{integer},#{cents}"
120
+ end
85
121
 
86
122
  def uri
87
123
  "#{@connection.base_url}/webservices/pagador/Boleto.asmx/CreateBoleto"
@@ -91,8 +127,8 @@ module Braspag
91
127
  document = Nokogiri::XML(document)
92
128
 
93
129
  map = {
94
- :url => nil,\
95
- :amount => nil,
130
+ :url => nil,
131
+ :amount => nil,
96
132
  :number => "boletoNumber",
97
133
  :expiration_date => Proc.new {
98
134
  begin
@@ -107,7 +143,6 @@ module Braspag
107
143
  }
108
144
 
109
145
  map.each do |keyForMap , keyValue|
110
-
111
146
  if keyValue.is_a?(String) || keyValue.nil?
112
147
  keyValue = keyForMap if keyValue.nil?
113
148
 
@@ -126,8 +161,5 @@ module Braspag
126
161
 
127
162
  map
128
163
  end
129
-
130
164
  end
131
-
132
165
  end
133
-
@@ -1,3 +1,3 @@
1
1
  module Braspag
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/rbraspag.gemspec CHANGED
@@ -26,5 +26,6 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency "fakeweb"
27
27
  s.add_development_dependency "shoulda-matchers"
28
28
  s.add_development_dependency "guard-rspec"
29
+ s.add_development_dependency "guard-bundler"
29
30
  s.add_development_dependency "ruby-debug19"
30
31
  end
data/spec/bill_spec.rb CHANGED
@@ -3,8 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe Braspag::Bill do
5
5
 
6
- #TODO Transformar numeros magicos em symbols, por exemplo metodo de pagamento pode ser :real ao inves de 10
7
-
8
6
  let!(:merchant_id) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
9
7
  let!(:connection) {Braspag::Connection.new(merchant_id, :test)}
10
8
 
@@ -19,204 +17,299 @@ describe Braspag::Bill do
19
17
  it "should raise an error when :order_id is not present" do
20
18
  expect {
21
19
  Braspag::Bill.new(connection, {
22
- :amount => "10000",
23
- :payment_method => "06"
24
- })
20
+ :amount => "10000",
21
+ :payment_method => :bradesco
22
+ })
25
23
  }.to raise_error(Braspag::IncompleteParams)
26
24
  end
27
25
 
28
26
  it "should raise an error when :amount is not present" do
29
- expect {
30
- Braspag::Bill.new(connection, {
31
- :order_id => "12",
32
- :payment_method => "06"
33
- })
34
- }.to raise_error(Braspag::IncompleteParams)
27
+ expect {
28
+ Braspag::Bill.new(connection, {
29
+ :order_id => "12",
30
+ :payment_method => :bradesco
31
+ })
32
+ }.to raise_error(Braspag::IncompleteParams)
35
33
  end
36
34
 
37
35
  it "should raise an error when :payment_method is not present" do
38
36
  expect {
39
37
  Braspag::Bill.new(connection, {
40
- :order_id => "13",
41
- :amount => "12000"
42
- })
38
+ :order_id => "13",
39
+ :amount => "120.00"
40
+ })
43
41
  }.to raise_error(Braspag::IncompleteParams)
44
42
  end
45
43
 
44
+ it "should raise an error when invalid string :payment_method" do
45
+ expect {
46
+ Braspag::Bill.new(connection, {
47
+ :order_id => "13",
48
+ :amount => "120.00",
49
+ :payment_method => "10"
50
+ })
51
+ }.to raise_error(Braspag::InvalidPaymentMethod)
52
+ end
53
+
54
+ it "should raise an error when invalid symbol :payment_method" do
55
+ expect {
56
+ Braspag::Bill.new(connection, {
57
+ :order_id => "13",
58
+ :amount => "120.00",
59
+ :payment_method => :invalid
60
+ })
61
+ }.to raise_error(Braspag::InvalidPaymentMethod)
62
+ end
63
+
46
64
  it "should raise an error when :order_id is less than 1 character" do
47
65
  expect {
48
66
  Braspag::Bill.new(connection, {
49
- :order_id => "",
50
- :amount => "12300",
51
- :payment_method => "06"
52
- })
67
+ :order_id => "",
68
+ :amount => "123.00",
69
+ :payment_method => :bradesco
70
+ })
53
71
  }.to raise_error(Braspag::InvalidOrderId)
54
72
  end
55
73
 
56
74
  it "should raise an error when :order_id is more than 50 characters" do
57
75
  expect {
58
76
  Braspag::Bill.new(connection, {
59
- :order_id => "1" * 51,
60
- :amount => "1200",
61
- :payment_method => "06"
62
- })
77
+ :order_id => "1" * 51,
78
+ :amount => "12.00",
79
+ :payment_method => :bradesco
80
+ })
63
81
  }.to raise_error(Braspag::InvalidOrderId)
64
82
  end
65
83
 
66
84
  it "should raise an error when :customer_name is less than 1 character" do
67
85
  expect {
68
86
  Braspag::Bill.new(connection, {
69
- :order_id => "102",
70
- :amount => "4200",
71
- :payment_method => "06",
72
- :customer_name => ""
73
- })
87
+ :order_id => "102",
88
+ :amount => "42.00",
89
+ :payment_method => :bradesco,
90
+ :customer_name => ""
91
+ })
74
92
  }.to raise_error(Braspag::InvalidCustomerName)
75
93
  end
76
94
 
77
95
  it "should raise an error when :customer_name is more than 255 characters" do
78
96
  expect {
79
97
  Braspag::Bill.new(connection, {
80
- :order_id => "112",
81
- :amount => "12100",
82
- :payment_method => "06",
83
- :customer_name => "A" * 256
84
- })
98
+ :order_id => "112",
99
+ :amount => "121.00",
100
+ :payment_method => :bradesco,
101
+ :customer_name => "A" * 256
102
+ })
85
103
  }.to raise_error(Braspag::InvalidCustomerName)
86
104
  end
87
105
 
88
106
  it "should raise an error when :customer_id is less than 11 characters" do
89
107
  expect {
90
108
  Braspag::Bill.new(connection, {
91
- :order_id => "23",
92
- :amount => "25100",
93
- :payment_method => "06",
94
- :customer_id => "2" * 10
95
- })
109
+ :order_id => "23",
110
+ :amount => "251.00",
111
+ :payment_method => :bradesco,
112
+ :customer_id => "2" * 10
113
+ })
96
114
  }.to raise_error(Braspag::InvalidCustomerId)
97
115
  end
98
116
 
99
117
  it "should raise an error when :customer_id is more than 18 characters" do
100
118
  expect {
101
119
  Braspag::Bill.new(connection, {
102
- :order_id => "90",
103
- :amount => "9000",
104
- :payment_method => "06",
105
- :customer_id => "3" * 19
106
- })
120
+ :order_id => "90",
121
+ :amount => "90.00",
122
+ :payment_method => :bradesco,
123
+ :customer_id => "3" * 19
124
+ })
107
125
  }.to raise_error(Braspag::InvalidCustomerId)
108
126
  end
109
127
 
110
128
  it "should raise an error when :number is less than 1 character" do
111
129
  expect {
112
130
  Braspag::Bill.new(connection, {
113
- :order_id => "900",
114
- :amount => "9200",
115
- :payment_method => "06",
116
- :number => ""
117
- })
131
+ :order_id => "900",
132
+ :amount => "92.00",
133
+ :payment_method => :bradesco,
134
+ :number => ""
135
+ })
118
136
  }.to raise_error(Braspag::InvalidNumber)
119
137
  end
120
138
 
121
139
  it "should raise an error when :number is more than 255 characters" do
122
140
  expect {
123
141
  Braspag::Bill.new(connection, {
124
- :order_id => "91",
125
- :amount => "8000",
126
- :payment_method => "06",
127
- :number => "5" * 256
128
- })
142
+ :order_id => "91",
143
+ :amount => "80.00",
144
+ :payment_method => :bradesco,
145
+ :number => "5" * 256
146
+ })
129
147
  }.to raise_error(Braspag::InvalidNumber)
130
148
  end
131
149
 
132
150
  it "should raise an error when :instructions is less than 1 character" do
133
151
  expect {
134
152
  Braspag::Bill.new(connection, {
135
- :order_id => "76",
136
- :amount => "5000",
137
- :payment_method => "06",
138
- :instructions => ""
139
- })
153
+ :order_id => "76",
154
+ :amount => "50.00",
155
+ :payment_method => :bradesco,
156
+ :instructions => ""
157
+ })
140
158
  }.to raise_error(Braspag::InvalidInstructions)
141
159
  end
142
160
 
143
161
  it "should raise an error when :instructions is more than 512 characters" do
144
162
  expect {
145
163
  Braspag::Bill.new(connection, {
146
- :order_id => "65",
147
- :amount => "21000",
148
- :payment_method => "06",
149
- :instructions => "O" * 513
150
- })
164
+ :order_id => "65",
165
+ :amount => "210.00",
166
+ :payment_method => :bradesco,
167
+ :instructions => "O" * 513
168
+ })
151
169
  }.to raise_error(Braspag::InvalidInstructions)
152
170
  end
153
171
 
154
172
  it "should raise an error when :expiration_date is more or less than 8 characters" do
155
173
  expect {
156
174
  Braspag::Bill.new(connection, {
157
- :order_id => "34",
158
- :amount => "24500",
159
- :payment_method => "06",
160
- :expiration_date => "1" * 7
161
- })
175
+ :order_id => "34",
176
+ :amount => "245.00",
177
+ :payment_method => :bradesco,
178
+ :expiration_date => "1" * 7
179
+ })
162
180
  }.to raise_error(Braspag::InvalidExpirationDate)
163
181
 
164
182
  expect {
165
183
  Braspag::Bill.new(connection, {
166
- :order_id => "67",
167
- :amount => "32100",
168
- :payment_method => "06",
169
- :expiration_date => "2" * 9
170
- })
184
+ :order_id => "67",
185
+ :amount => "321.00",
186
+ :payment_method => :bradesco,
187
+ :expiration_date => "2" * 9
188
+ })
171
189
  }.to raise_error(Braspag::InvalidExpirationDate)
172
190
  end
173
191
 
192
+ it "should accept :payment_method as Symbol Object and convert to relative String value" do
193
+ (bill = Braspag::Bill.new(connection, {
194
+ :order_id => "67",
195
+ :amount => "321.00",
196
+ :payment_method => :itau,
197
+ :expiration_date => Date.today + 2
198
+ })
199
+ ).should be_ok
200
+
201
+ bill[:payment_method].should == :itau
202
+ end
203
+
174
204
  it "should accept :expiration_date with Date Object" do
175
- Braspag::Bill.new(connection, {
205
+ Braspag::Bill.new(connection, {
176
206
  :order_id => "67",
177
- :amount => "32100",
178
- :payment_method => "06",
207
+ :amount => "321.00",
208
+ :payment_method => :bradesco,
179
209
  :expiration_date => Date.today + 2
180
210
  }).should be_ok
181
211
  end
182
212
 
183
- end
213
+ it "should accept :expiration_date with valid string date" do
214
+ Braspag::Bill.new(connection, {
215
+ :order_id => "67",
216
+ :amount => "321.00",
217
+ :payment_method => :bradesco,
218
+ :expiration_date => (Date.today + 2).strftime("%d/%m/%y")
219
+ }).should be_ok
220
+ end
184
221
 
185
- describe ".generate" do
222
+ it "should accept string as :amount" do
223
+ (bill = Braspag::Bill.new(connection, {
224
+ :order_id => "67",
225
+ :amount => "54321.45",
226
+ :payment_method => :bradesco,
227
+ :expiration_date => (Date.today + 2).strftime("%d/%m/%y")
228
+ })
229
+ ).should be_ok
186
230
 
187
- context "with correct data" do
231
+ bill[:amount].should == BigDecimal.new("54321.45")
232
+ end
188
233
 
189
- before do
190
- xml = <<-EOXML
191
- <?xml version="1.0" encoding="utf-8"?>
192
- <PagadorBoletoReturn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
193
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
194
- xmlns="https://www.pagador.com.br/webservice/pagador">
195
- <amount>3</amount>
196
- <boletoNumber>70031</boletoNumber>
197
- <expirationDate>2011-06-27T00:00:00-03:00</expirationDate>
198
- <url>https://homologacao.pagador.com.br/pagador/reenvia.asp?Id_Transacao=34ae7d96-aa65-425a-b893-55791cb6a4df</url>
199
- <returnCode>0</returnCode>)
200
- <status>0</status>
201
- </PagadorBoletoReturn>
202
- EOXML
234
+ it "should accept integer as :amount" do
235
+ (bill = Braspag::Bill.new(connection, {
236
+ :order_id => "67",
237
+ :amount => 123,
238
+ :payment_method => :bradesco,
239
+ :expiration_date => (Date.today + 2).strftime("%d/%m/%y")
240
+ })
241
+ ).should be_ok
203
242
 
204
- FakeWeb.register_uri(:post, "#{Braspag::Test::BASE_URL}/webservices/pagador/Boleto.asmx/CreateBoleto", :body => xml)
243
+ bill[:amount].should == BigDecimal.new("123.00")
244
+ end
245
+
246
+ it "should accept BigDecimal as :amount" do
247
+ (bill = Braspag::Bill.new(connection, {
248
+ :order_id => "67",
249
+ :amount => BigDecimal.new("123.45"),
250
+ :payment_method => :bradesco,
251
+ :expiration_date => (Date.today + 2).strftime("%d/%m/%y")
252
+ })
253
+ ).should be_ok
205
254
 
206
- @bill = Braspag::Bill.new(connection , {
207
- :order_id => 1,
255
+ bill[:amount].should == BigDecimal.new("123.45")
256
+ end
257
+
258
+ it "should accept integer as :amount" do
259
+ (bill = Braspag::Bill.new(connection, {
260
+ :order_id => "67",
261
+ :amount => 12345,
262
+ :payment_method => :bradesco,
263
+ :expiration_date => (Date.today + 2).strftime("%d/%m/%y")
264
+ })
265
+ ).should be_ok
266
+
267
+ bill[:amount].should == BigDecimal.new("12345.00")
268
+ end
269
+
270
+ end
271
+
272
+ describe ".generate" do
273
+ context "with all data" do
274
+ before do
275
+ @tomorrow = (Time.now + 3600 * 24 * 2)
276
+
277
+ data = {
278
+ :order_id => Time.now.to_i.to_s,
208
279
  :amount => 3,
209
- :payment_method => 10
210
- })
280
+ :payment_method => :real,
281
+ :number => "123123",
282
+ :expiration_date => @tomorrow.strftime("%d/%m/%y")
283
+ }
284
+
285
+ @bill = Braspag::Bill.new(connection, data)
211
286
  @response = @bill.generate
212
287
  end
213
288
 
214
- after do
215
- FakeWeb.clean_registry
289
+ it "should return the bill number" do
290
+ @response[:number].should == "123123"
291
+ end
292
+
293
+ it "should return the expiration date" do
294
+ @response[:expiration_date].should be_kind_of Date
295
+ @response[:expiration_date].strftime("%d/%m/%Y").should == @tomorrow.strftime("%d/%m/%Y")
296
+ end
297
+ end
298
+
299
+ context "with minimum correct data" do
300
+ before(:all) do
301
+ data = {
302
+ :order_id => Time.now.to_i.to_s,
303
+ :amount => 1234.56,
304
+ :payment_method => :real
305
+ }
306
+ @bill = Braspag::Bill.new(connection, data)
307
+ @response = @bill.generate
216
308
  end
217
309
 
218
310
  it "should return a public url" do
219
- @response[:url].should == "https://homologacao.pagador.com.br/pagador/reenvia.asp?Id_Transacao=34ae7d96-aa65-425a-b893-55791cb6a4df"
311
+ regexp = %r"https://homologacao\.pagador\.com\.br/pagador/reenvia\.asp\?Id_Transacao=[a-z0-9]{8}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{12}"
312
+ @response[:url].should match(regexp)
220
313
  end
221
314
 
222
315
  it "should return 0 (waiting payment) as the status" do
@@ -228,22 +321,22 @@ describe Braspag::Bill do
228
321
  end
229
322
 
230
323
  it "should return 3 as the amount" do
231
- @response[:amount].should == "3"
324
+ @response[:amount].should == BigDecimal.new("1234.56")
232
325
  end
233
326
 
234
327
  it "should return the bill number" do
235
- @response[:number].should == "70031"
328
+ @response[:number].should_not be_empty
236
329
  end
237
330
 
238
331
  it "should return the expiration date" do
332
+ ten_days_after_today = (Time.now + 3600 * 24 * 10)
333
+
239
334
  @response[:expiration_date].should be_kind_of Date
240
- @response[:expiration_date].to_s.should == "2011-06-27"
335
+ @response[:expiration_date].strftime("%d/%m/%Y").should == ten_days_after_today.strftime("%d/%m/%Y")
241
336
  end
242
-
243
337
  end
244
338
 
245
339
  context "with incorrect data" do
246
-
247
340
  it "should raise an error for invalid :merchantId" do
248
341
  xml = <<-EOXML
249
342
  <?xml version="1.0" encoding="utf-8"?>
@@ -264,10 +357,10 @@ describe Braspag::Bill do
264
357
 
265
358
  expect {
266
359
  bill = Braspag::Bill.new(connection, {
267
- :order_id => 1,
268
- :amount => 3,
269
- :payment_method => 10
270
- })
360
+ :order_id => 1,
361
+ :amount => 3,
362
+ :payment_method => :hsbc
363
+ })
271
364
  bill.generate
272
365
  }.to raise_error(Braspag::InvalidMerchantId)
273
366
 
@@ -292,11 +385,11 @@ describe Braspag::Bill do
292
385
 
293
386
  expect {
294
387
  bill = Braspag::Bill.new(connection, {
295
- :number => "A" * 50,
296
- :order_id => "x",
297
- :amount => 3,
298
- :payment_method => 10
299
- })
388
+ :number => "A" * 50,
389
+ :order_id => "x",
390
+ :amount => 3,
391
+ :payment_method => :hsbc
392
+ })
300
393
  bill.generate
301
394
  }.to raise_error(Braspag::InvalidStringFormat)
302
395
 
@@ -321,10 +414,10 @@ describe Braspag::Bill do
321
414
 
322
415
  expect {
323
416
  bill = Braspag::Bill.new(connection, {
324
- :order_id => 1,
325
- :amount => "0000",
326
- :payment_method => 10
327
- })
417
+ :order_id => 1,
418
+ :amount => "0000",
419
+ :payment_method => :hsbc
420
+ })
328
421
  bill.generate
329
422
  }.to raise_error(Braspag::InvalidPaymentMethod)
330
423
 
@@ -349,10 +442,10 @@ describe Braspag::Bill do
349
442
 
350
443
  expect {
351
444
  bill = Braspag::Bill.new(connection, {
352
- :order_id => 1,
353
- :amount => -33,
354
- :payment_method => 10
355
- })
445
+ :order_id => 1,
446
+ :amount => -33,
447
+ :payment_method => :hsbc
448
+ })
356
449
  bill.generate
357
450
  }.to raise_error(Braspag::InvalidAmount)
358
451
 
@@ -377,18 +470,15 @@ describe Braspag::Bill do
377
470
 
378
471
  expect {
379
472
  bill = Braspag::Bill.new(connection, {
380
- :order_id => 1,
381
- :amount => 3,
382
- :payment_method => "10"
383
- })
473
+ :order_id => 1,
474
+ :amount => 3,
475
+ :payment_method => :real
476
+ })
384
477
  bill.generate
385
478
  }.to raise_error(Braspag::UnknownError)
386
479
 
387
480
  FakeWeb.clean_registry
388
481
  end
389
-
390
482
  end
391
-
392
483
  end
393
-
394
484
  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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,11 +13,11 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2011-07-01 00:00:00.000000000Z
16
+ date: 2011-07-06 00:00:00.000000000Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: cs-httpi
20
- requirement: &21839140 !ruby/object:Gem::Requirement
20
+ requirement: &18748720 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ! '>='
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: 0.9.5.2
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *21839140
28
+ version_requirements: *18748720
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: json
31
- requirement: &21838720 !ruby/object:Gem::Requirement
31
+ requirement: &18748300 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ! '>='
@@ -36,10 +36,10 @@ dependencies:
36
36
  version: '0'
37
37
  type: :runtime
38
38
  prerelease: false
39
- version_requirements: *21838720
39
+ version_requirements: *18748300
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: nokogiri
42
- requirement: &21838260 !ruby/object:Gem::Requirement
42
+ requirement: &18747840 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
45
  - - ! '>='
@@ -47,10 +47,10 @@ dependencies:
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
- version_requirements: *21838260
50
+ version_requirements: *18747840
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rspec
53
- requirement: &21837840 !ruby/object:Gem::Requirement
53
+ requirement: &18747420 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
56
  - - ! '>='
@@ -58,10 +58,10 @@ dependencies:
58
58
  version: '0'
59
59
  type: :development
60
60
  prerelease: false
61
- version_requirements: *21837840
61
+ version_requirements: *18747420
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: fakeweb
64
- requirement: &21837420 !ruby/object:Gem::Requirement
64
+ requirement: &18747000 !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ! '>='
@@ -69,10 +69,10 @@ dependencies:
69
69
  version: '0'
70
70
  type: :development
71
71
  prerelease: false
72
- version_requirements: *21837420
72
+ version_requirements: *18747000
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: shoulda-matchers
75
- requirement: &21837000 !ruby/object:Gem::Requirement
75
+ requirement: &18746580 !ruby/object:Gem::Requirement
76
76
  none: false
77
77
  requirements:
78
78
  - - ! '>='
@@ -80,10 +80,10 @@ dependencies:
80
80
  version: '0'
81
81
  type: :development
82
82
  prerelease: false
83
- version_requirements: *21837000
83
+ version_requirements: *18746580
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: guard-rspec
86
- requirement: &21836580 !ruby/object:Gem::Requirement
86
+ requirement: &18773640 !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements:
89
89
  - - ! '>='
@@ -91,10 +91,21 @@ dependencies:
91
91
  version: '0'
92
92
  type: :development
93
93
  prerelease: false
94
- version_requirements: *21836580
94
+ version_requirements: *18773640
95
+ - !ruby/object:Gem::Dependency
96
+ name: guard-bundler
97
+ requirement: &18773220 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: *18773220
95
106
  - !ruby/object:Gem::Dependency
96
107
  name: ruby-debug19
97
- requirement: &21836160 !ruby/object:Gem::Requirement
108
+ requirement: &18772800 !ruby/object:Gem::Requirement
98
109
  none: false
99
110
  requirements:
100
111
  - - ! '>='
@@ -102,7 +113,7 @@ dependencies:
102
113
  version: '0'
103
114
  type: :development
104
115
  prerelease: false
105
- version_requirements: *21836160
116
+ version_requirements: *18772800
106
117
  description: rbraspag gem to use Braspag gateway
107
118
  email:
108
119
  - tinorj@gmail.com