sage_pay 0.2.13 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rbenv-version +1 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -7
- data/README.md +27 -8
- data/Rakefile +5 -114
- data/config/locales/en.yml +8 -0
- data/lib/sage_pay.rb +10 -6
- data/lib/sage_pay/locale_initializer.rb +3 -0
- data/lib/sage_pay/server/address.rb +11 -15
- data/lib/sage_pay/server/authorise.rb +2 -2
- data/lib/sage_pay/server/command.rb +7 -4
- data/lib/sage_pay/server/notification.rb +1 -1
- data/lib/sage_pay/server/notification_response.rb +1 -1
- data/lib/sage_pay/server/refund.rb +2 -3
- data/lib/sage_pay/server/registration.rb +2 -2
- data/lib/sage_pay/server/related_transaction.rb +1 -1
- data/lib/sage_pay/server/release.rb +2 -3
- data/lib/sage_pay/server/repeat.rb +2 -2
- data/lib/sage_pay/server/response.rb +2 -1
- data/lib/sage_pay/uri_fixups.rb +6 -40
- data/lib/sage_pay/validators.rb +36 -0
- data/lib/sage_pay/version.rb +3 -0
- data/sage_pay.gemspec +16 -30
- data/spec/integration/sage_pay/server_spec.rb +9 -9
- data/spec/sage_pay/server/address_spec.rb +5 -5
- data/spec/sage_pay/server/notification_response_spec.rb +2 -2
- data/spec/sage_pay/server/registration_spec.rb +13 -13
- data/spec/sage_pay/server_spec.rb +4 -4
- data/spec/sage_pay_spec.rb +2 -2
- data/spec/spec_helper.rb +8 -2
- data/spec/support/integration.rb +6 -6
- data/spec/support/validation_matchers.rb +13 -13
- metadata +115 -93
- data/Gemfile.lock +0 -39
- data/lib/validatable-ext.rb +0 -28
- data/lib/validations/validates_inclusion_of.rb +0 -22
data/spec/support/integration.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
else
|
4
|
-
STDERR.puts "Running integration tests. Set SKIP_INTEGRATION=true to skip them."
|
1
|
+
def run_integration_specs?
|
2
|
+
ENV["VENDOR_NAME"].present?
|
5
3
|
end
|
6
4
|
|
7
|
-
|
8
|
-
ENV["
|
5
|
+
if run_integration_specs?
|
6
|
+
STDERR.puts "Running integration tests with vendor name #{ENV["VENDOR_NAME"]}."
|
7
|
+
else
|
8
|
+
STDERR.puts "Skipping integration tests, re-run with VENDOR_NAME set to a simulator account to enable them."
|
9
9
|
end
|
@@ -2,56 +2,56 @@ module ValidationMatchers
|
|
2
2
|
def validates_the_presence_of(model_name, attribute, message = "can't be empty")
|
3
3
|
model = model_factory(model_name, attribute => "")
|
4
4
|
model.should_not be_valid
|
5
|
-
model.errors
|
5
|
+
model.errors[attribute].should include(message)
|
6
6
|
end
|
7
7
|
|
8
8
|
def does_not_require_the_presence_of(model_name, attribute)
|
9
9
|
model = model_factory(model_name, attribute => "")
|
10
10
|
model.should be_valid
|
11
|
-
model.errors
|
11
|
+
model.errors[attribute].should be_empty
|
12
12
|
end
|
13
13
|
|
14
14
|
def validates_the_length_of(model_name, attribute, limits, message = "is invalid")
|
15
15
|
if limits[:min]
|
16
16
|
model = model_factory(model_name, attribute => 'a' * (limits[:min] - 1))
|
17
17
|
model.should_not be_valid
|
18
|
-
model.errors
|
18
|
+
model.errors[attribute].should include(message)
|
19
19
|
|
20
20
|
model = model_factory(model_name, attribute => 'a' * limits[:min])
|
21
21
|
model.should be_valid
|
22
|
-
model.errors
|
22
|
+
model.errors[attribute].should be_empty
|
23
23
|
|
24
24
|
model = model_factory(model_name, attribute => 'a' * (limits[:min] + 1))
|
25
25
|
model.should be_valid
|
26
|
-
model.errors
|
26
|
+
model.errors[attribute].should be_empty
|
27
27
|
end
|
28
28
|
|
29
29
|
if limits[:max]
|
30
30
|
model = model_factory(model_name, attribute => 'a' * (limits[:max] - 1))
|
31
31
|
model.should be_valid
|
32
|
-
model.errors
|
32
|
+
model.errors[attribute].should be_empty
|
33
33
|
|
34
34
|
model = model_factory(model_name, attribute => 'a' * limits[:max])
|
35
35
|
model.should be_valid
|
36
|
-
model.errors
|
36
|
+
model.errors[attribute].should be_empty
|
37
37
|
|
38
38
|
model = model_factory(model_name, attribute => 'a' * (limits[:max] + 1))
|
39
39
|
model.should_not be_valid
|
40
|
-
model.errors
|
40
|
+
model.errors[attribute].should include(message)
|
41
41
|
end
|
42
42
|
|
43
43
|
if limits[:exactly]
|
44
44
|
model = model_factory(model_name, attribute => 'a' * (limits[:exactly] - 1))
|
45
45
|
model.should_not be_valid
|
46
|
-
model.errors
|
46
|
+
model.errors[attribute].should include(message)
|
47
47
|
|
48
48
|
model = model_factory(model_name, attribute => 'a' * limits[:exactly])
|
49
49
|
model.should be_valid
|
50
|
-
model.errors
|
50
|
+
model.errors[attribute].should be_empty
|
51
51
|
|
52
52
|
model = model_factory(model_name, attribute => 'a' * (limits[:exactly] + 1))
|
53
53
|
model.should_not be_valid
|
54
|
-
model.errors
|
54
|
+
model.errors[attribute].should include(message)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -59,13 +59,13 @@ module ValidationMatchers
|
|
59
59
|
(examples[:invalid] || []).each do |invalid|
|
60
60
|
model = model_factory(model_name, attribute => invalid)
|
61
61
|
model.should_not be_valid
|
62
|
-
model.errors
|
62
|
+
model.errors[attribute].should include(message)
|
63
63
|
end
|
64
64
|
|
65
65
|
(examples[:valid] || []).each do |valid|
|
66
66
|
model = model_factory(model_name, attribute => valid)
|
67
67
|
model.should be_valid
|
68
|
-
model.errors
|
68
|
+
model.errors[attribute].should be_empty
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
metadata
CHANGED
@@ -1,106 +1,136 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sage_pay
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 13
|
10
|
-
version: 0.2.13
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Graeme Mathieson
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: activesupport
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
- 8
|
34
|
-
version: 2.3.8
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.3
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: validatable
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
25
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activemodel
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.1.0
|
51
38
|
type: :runtime
|
52
|
-
|
53
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.1.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
54
47
|
name: uuid
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.3.0
|
54
|
+
type: :runtime
|
55
55
|
prerelease: false
|
56
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 3
|
62
|
-
segments:
|
63
|
-
- 2
|
64
|
-
- 3
|
65
|
-
- 0
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
66
61
|
version: 2.3.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: i18n
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.6.0
|
67
70
|
type: :runtime
|
68
|
-
|
69
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.6.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
70
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
|
71
87
|
prerelease: false
|
72
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
89
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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'
|
81
102
|
type: :development
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
+
description: ! 'This is a Ruby library for integrating with SagePay. SagePay is a
|
111
|
+
payment
|
112
|
+
|
85
113
|
gateway for accepting credit card payments through your web app.
|
86
114
|
|
115
|
+
'
|
87
116
|
email: mathie@woss.name
|
88
117
|
executables: []
|
89
|
-
|
90
118
|
extensions: []
|
91
|
-
|
92
|
-
extra_rdoc_files:
|
119
|
+
extra_rdoc_files:
|
93
120
|
- README.md
|
94
121
|
- LICENSE
|
95
|
-
files:
|
122
|
+
files:
|
123
|
+
- .rbenv-version
|
124
|
+
- .rspec
|
96
125
|
- CHANGELOG.md
|
97
126
|
- Gemfile
|
98
|
-
- Gemfile.lock
|
99
127
|
- LICENSE
|
100
128
|
- README.md
|
101
129
|
- Rakefile
|
102
130
|
- TODO
|
131
|
+
- config/locales/en.yml
|
103
132
|
- lib/sage_pay.rb
|
133
|
+
- lib/sage_pay/locale_initializer.rb
|
104
134
|
- lib/sage_pay/server.rb
|
105
135
|
- lib/sage_pay/server/abort.rb
|
106
136
|
- lib/sage_pay/server/address.rb
|
@@ -121,8 +151,8 @@ files:
|
|
121
151
|
- lib/sage_pay/server/signature_verification_details.rb
|
122
152
|
- lib/sage_pay/server/transaction_code.rb
|
123
153
|
- lib/sage_pay/uri_fixups.rb
|
124
|
-
- lib/
|
125
|
-
- lib/
|
154
|
+
- lib/sage_pay/validators.rb
|
155
|
+
- lib/sage_pay/version.rb
|
126
156
|
- sage_pay.gemspec
|
127
157
|
- spec/integration/sage_pay/server_spec.rb
|
128
158
|
- spec/sage_pay/server/address_spec.rb
|
@@ -138,41 +168,32 @@ files:
|
|
138
168
|
- spec/support/factories.rb
|
139
169
|
- spec/support/integration.rb
|
140
170
|
- spec/support/validation_matchers.rb
|
141
|
-
has_rdoc: true
|
142
171
|
homepage: http://github.com/mathie/sage_pay
|
143
172
|
licenses: []
|
144
|
-
|
145
173
|
post_install_message:
|
146
|
-
rdoc_options:
|
174
|
+
rdoc_options:
|
147
175
|
- --charset=UTF-8
|
148
|
-
require_paths:
|
176
|
+
require_paths:
|
149
177
|
- lib
|
150
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
179
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
|
156
|
-
|
157
|
-
- 0
|
158
|
-
version: "0"
|
159
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ! '>='
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: 1.9.2
|
184
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
185
|
none: false
|
161
|
-
requirements:
|
162
|
-
- -
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
|
165
|
-
segments:
|
166
|
-
- 0
|
167
|
-
version: "0"
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
168
190
|
requirements: []
|
169
|
-
|
170
191
|
rubyforge_project: sage_pay
|
171
|
-
rubygems_version: 1.
|
192
|
+
rubygems_version: 1.8.23
|
172
193
|
signing_key:
|
173
194
|
specification_version: 2
|
174
195
|
summary: Ruby implementation of the SagePay payment gateway protocol.
|
175
|
-
test_files:
|
196
|
+
test_files:
|
176
197
|
- spec/integration/sage_pay/server_spec.rb
|
177
198
|
- spec/sage_pay/server/address_spec.rb
|
178
199
|
- spec/sage_pay/server/notification_response_spec.rb
|
@@ -183,3 +204,4 @@ test_files:
|
|
183
204
|
- spec/sage_pay/server/transaction_code_spec.rb
|
184
205
|
- spec/sage_pay/server_spec.rb
|
185
206
|
- spec/sage_pay_spec.rb
|
207
|
+
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
---
|
2
|
-
dependencies:
|
3
|
-
rake:
|
4
|
-
group:
|
5
|
-
- :development
|
6
|
-
version: ">= 0"
|
7
|
-
uuid:
|
8
|
-
group:
|
9
|
-
- :default
|
10
|
-
version: ">= 2.3.1"
|
11
|
-
rspec:
|
12
|
-
group:
|
13
|
-
- :development
|
14
|
-
version: ">= 0"
|
15
|
-
activesupport:
|
16
|
-
group:
|
17
|
-
- :default
|
18
|
-
version: ">= 2.3.8"
|
19
|
-
validatable:
|
20
|
-
group:
|
21
|
-
- :default
|
22
|
-
version: ">= 1.6.7"
|
23
|
-
specs:
|
24
|
-
- rake:
|
25
|
-
version: 0.8.7
|
26
|
-
- activesupport:
|
27
|
-
version: 2.3.8
|
28
|
-
- macaddr:
|
29
|
-
version: 1.0.0
|
30
|
-
- rspec:
|
31
|
-
version: 1.3.0
|
32
|
-
- uuid:
|
33
|
-
version: 2.3.1
|
34
|
-
- validatable:
|
35
|
-
version: 1.6.7
|
36
|
-
hash: 64c077bdede3436c2ce404a8f1824f50cf7a1f7c
|
37
|
-
sources:
|
38
|
-
- Rubygems:
|
39
|
-
uri: http://gemcutter.org
|
data/lib/validatable-ext.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'validatable'
|
2
|
-
require 'validations/validates_inclusion_of'
|
3
|
-
|
4
|
-
module Validatable
|
5
|
-
module Macros
|
6
|
-
# call-seq: validates_inclusion_of(*args)
|
7
|
-
#
|
8
|
-
# Encapsulates the pattern of wanting to validate that an attribute is is in a list. Example:
|
9
|
-
#
|
10
|
-
# class Person
|
11
|
-
# include Validatable
|
12
|
-
# validates_inclusion_of :operating_system, :in => ["Mac OS X", "Linux", "Windows"]
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# Configuration options:
|
16
|
-
#
|
17
|
-
# * in - a list of acceptable answers
|
18
|
-
# * after_validate - A block that executes following the run of a validation
|
19
|
-
# * message - The message to add to the errors collection when the validation fails
|
20
|
-
# * times - The number of times the validation applies
|
21
|
-
# * level - The level at which the validation should occur
|
22
|
-
# * if - A block that when executed must return true of the validation will not occur
|
23
|
-
# * group - The group that this validation belongs to. A validation can belong to multiple groups
|
24
|
-
def validates_inclusion_of(*args)
|
25
|
-
add_validations(args, ValidatesInclusionOf)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Validatable
|
2
|
-
class ValidatesInclusionOf < ValidationBase #:nodoc:
|
3
|
-
option :allow_blank
|
4
|
-
required_option :in
|
5
|
-
|
6
|
-
def message(instance)
|
7
|
-
super || "is not in the list"
|
8
|
-
end
|
9
|
-
|
10
|
-
def valid?(instance)
|
11
|
-
valid = true
|
12
|
-
value = instance.send(self.attribute)
|
13
|
-
|
14
|
-
if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
15
|
-
return true if allow_blank
|
16
|
-
value = ""
|
17
|
-
end
|
18
|
-
|
19
|
-
@in.include?(value)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|