khipu-rails 0.0.1 → 1.3.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.
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe KhipuRails::ButtonHelper do
5
- before :all do
6
- @view = ActionView::Base.new
7
- end
8
-
9
- it "generates a form with the action provided by khipu" do
10
- button = Nokogiri::HTML.parse(@view.khipu_button "minimal", 2000)
11
- form = button.css('form')
12
- form.attribute('action').value.should == 'https://khipu.com/payment/api/createPaymentPage'
13
- end
14
-
15
- it "generates a form with the method post" do
16
- button = Nokogiri::HTML.parse(@view.khipu_button "minimal", 2000)
17
- form = button.css('form')
18
- form.attribute('method').value.should == 'post'
19
- end
20
-
21
- context "given a form with minimal data was correctly generated, it" do
22
- before :all do
23
- @receiver_id = KhipuRails::Config.user_id
24
- @secret = KhipuRails::Config.api_key
25
- @button = Nokogiri::HTML.parse(@view.khipu_button "minimal", 2000)
26
- end
27
-
28
- it "has an input called reciever_id" do
29
- input = @button.css('form input[name=receiver_id]')
30
- input.attribute('value').value.to_i.should == @receiver_id
31
- end
32
-
33
- it "has an input called subject" do
34
- input = @button.css('form input[name=subject]')
35
- input.attribute('value').value.should == 'minimal'
36
- end
37
-
38
- it "has an input called body" do
39
- input = @button.css('form input[name=body]')
40
- input.attribute('value').value.should == ''
41
- end
42
-
43
- it "has an input called amount" do
44
- input = @button.css('form input[name=amount]')
45
- input.attribute('value').value.should == '2000'
46
- end
47
-
48
- it "has an input called return_url" do
49
- input = @button.css('form input[name=return_url]')
50
- input.attribute('value').value.should == ''
51
- end
52
-
53
- it "has an input called cancel_url" do
54
- input = @button.css('form input[name=cancel_url]')
55
- input.attribute('value').value.should == ''
56
- end
57
-
58
- it "has an input called transaction_id" do
59
- input = @button.css('form input[name=transaction_id]')
60
- input.attribute('value').value.should == ''
61
- end
62
-
63
- it "has an input called custom" do
64
- input = @button.css('form input[name=custom]')
65
- input.attribute('value').value.should == ''
66
- end
67
-
68
- it "has an input called payer_email" do
69
- input = @button.css('form input[name=payer_email]')
70
- input.attribute('value').value.should == ''
71
- end
72
-
73
- it "has an input called picture_url" do
74
- input = @button.css('form input[name=picture_url]')
75
- input.attribute('value').value.should == ''
76
- end
77
-
78
- it "has an input called hash" do
79
- input = @button.css('form input[name=hash]')
80
- input.attribute('type').value.should == 'hidden'
81
- def get_value attribute
82
- @button.css("form input[name=#{attribute}]").attribute('value').value
83
- end
84
- raw = "receiver_id=#{get_value :receiver_id}&"
85
- raw += "subject=#{get_value :subject}&"
86
- raw += "body=#{get_value :body}&"
87
- raw += "amount=#{get_value :amount}&"
88
- raw += "return_url=#{get_value :return_url}&"
89
- raw += "cancel_url=#{get_value :cancel_url}&"
90
- raw += "custom=#{get_value :custom}&"
91
- raw += "transaction_id=#{get_value :transaction_id}&"
92
- raw += "picture_url=#{get_value :picture_url}&"
93
- raw += "payer_email=#{get_value :payer_email}&"
94
- raw += "secret=#{@secret}"
95
- input.attribute('value').value.should == Digest::SHA1.hexdigest(raw)
96
- end
97
-
98
- it "has an image submit" do
99
- input = @button.css('form input[name=submit]')
100
- input.attribute('type').value.should == 'image'
101
- input.attribute('src').value.should == 'https://s3.amazonaws.com/static.khipu.com/buttons/50x25.png'
102
- end
103
- end
104
- end