breadmachine 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/lib/breadmachine/dto/card.rb +22 -0
- data/lib/breadmachine/dto/customer_info.rb +16 -0
- data/lib/breadmachine/dto/order_info.rb +13 -0
- data/lib/breadmachine/dto/three_d_secure_credentials.rb +13 -0
- data/lib/breadmachine/extensions/money.rb +9 -0
- data/lib/breadmachine/extensions.rb +1 -0
- data/lib/breadmachine/secure_trading/auth_request.rb +38 -0
- data/lib/breadmachine/secure_trading/auth_reversal_request.rb +36 -0
- data/lib/breadmachine/secure_trading/auth_reversal_response.rb +6 -0
- data/lib/breadmachine/secure_trading/card_xml.rb +23 -0
- data/lib/breadmachine/secure_trading/config.rb +21 -0
- data/lib/breadmachine/secure_trading/customer_info_auth_xml.rb +40 -0
- data/lib/breadmachine/secure_trading/customer_info_enrolment_xml.rb +21 -0
- data/lib/breadmachine/secure_trading/order_info_xml.rb +21 -0
- data/lib/breadmachine/secure_trading/payment_methods.rb +28 -0
- data/lib/breadmachine/secure_trading/st_3d_auth_request.rb +41 -0
- data/lib/breadmachine/secure_trading/st_3d_auth_response.rb +25 -0
- data/lib/breadmachine/secure_trading/st_3d_card_query_request.rb +37 -0
- data/lib/breadmachine/secure_trading/st_3d_card_query_response.rb +46 -0
- data/lib/breadmachine/secure_trading/three_d_secure_credentials_xml.rb +23 -0
- data/lib/breadmachine/secure_trading/xpay.rb +25 -0
- data/lib/breadmachine/secure_trading/xpay_socket.rb +22 -0
- data/lib/breadmachine/secure_trading.rb +32 -0
- data/lib/breadmachine.rb +27 -0
- data/spec/blueprints.rb +38 -0
- data/spec/breadmachine_spec.rb +5 -0
- data/spec/extensions/money_spec.rb +24 -0
- data/spec/secure_trading/auth_request_spec.rb +58 -0
- data/spec/secure_trading/bread_machine_spec.rb +16 -0
- data/spec/secure_trading/card_xml_spec.rb +56 -0
- data/spec/secure_trading/config_spec.rb +12 -0
- data/spec/secure_trading/customer_info_auth_xml_spec.rb +94 -0
- data/spec/secure_trading/customer_info_enrolment_xml_spec.rb +31 -0
- data/spec/secure_trading/order_info_xml_spec.rb +31 -0
- data/spec/secure_trading/st_3d_auth_request_spec.rb +63 -0
- data/spec/secure_trading/st_3d_auth_response_spec.rb +5 -0
- data/spec/secure_trading/st_3d_card_query_request_spec.rb +63 -0
- data/spec/secure_trading/st_3d_card_query_response_spec.rb +79 -0
- data/spec/secure_trading/st_auth_request_spec.rb +0 -0
- data/spec/secure_trading/st_auth_reversal_request_spec.rb +0 -0
- data/spec/secure_trading/st_refund_request_spec.rb +0 -0
- data/spec/secure_trading/st_refund_reversal_request_spec.rb +0 -0
- data/spec/secure_trading/st_settlement_request_spec.rb +0 -0
- data/spec/secure_trading/three_d_secure_credentials_xml_spec.rb +42 -0
- data/spec/secure_trading/xpay_socket_spec.rb +14 -0
- data/spec/secure_trading/xpay_spec.rb +9 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/matchers/have_tag.rb +112 -0
- metadata +163 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
require 'breadmachine'
|
6
|
+
require 'spec'
|
7
|
+
require 'spec/autorun'
|
8
|
+
|
9
|
+
require 'spec/blueprints'
|
10
|
+
|
11
|
+
# Requires supporting files with custom matchers and macros, etc,
|
12
|
+
# in ./support/ and its subdirectories.
|
13
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
14
|
+
|
15
|
+
Spec::Runner.configure do |config|
|
16
|
+
config.include(HaveTagMatcher)
|
17
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module HaveTagMatcher
|
2
|
+
class HaveTag
|
3
|
+
def initialize(selector, inner_text_or_options, options, &block)
|
4
|
+
@selector = selector
|
5
|
+
if Hash === inner_text_or_options
|
6
|
+
@inner_text = nil
|
7
|
+
@options = inner_text_or_options
|
8
|
+
else
|
9
|
+
@inner_text = inner_text_or_options
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def matches?(actual, &block)
|
15
|
+
@actual = actual
|
16
|
+
@hdoc = hdoc_for(@actual)
|
17
|
+
|
18
|
+
matched_elements = @hdoc.search(@selector)
|
19
|
+
if matched_elements.empty?
|
20
|
+
return @options[:count] == 0
|
21
|
+
end
|
22
|
+
|
23
|
+
if @inner_text
|
24
|
+
matched_elements = filter_on_inner_text(matched_elements)
|
25
|
+
end
|
26
|
+
|
27
|
+
if block
|
28
|
+
matched_elements = filter_on_nested_expectations(matched_elements, block)
|
29
|
+
end
|
30
|
+
|
31
|
+
@actual_count = matched_elements.length
|
32
|
+
return false if not acceptable_count?(@actual_count)
|
33
|
+
|
34
|
+
!matched_elements.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def failure_message
|
38
|
+
explanation = @actual_count ? "but found #{@actual_count}" : "but did not"
|
39
|
+
"expected\n#{@hdoc.to_s}\nto have #{failure_count_phrase} #{failure_selector_phrase}, #{explanation}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def negative_failure_message
|
43
|
+
explanation = @actual_count ? "but found #{@actual_count}" : "but did"
|
44
|
+
"expected\n#{@hdoc.to_s}\nnot to have #{failure_count_phrase} #{failure_selector_phrase}, #{explanation}"
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def hdoc_for(input)
|
49
|
+
if Nokogiri::XML::Document === input
|
50
|
+
input
|
51
|
+
elsif input.respond_to?(:body)
|
52
|
+
Nokogiri::HTML(input.body)
|
53
|
+
else
|
54
|
+
Nokogiri::HTML(input.to_s)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def filter_on_inner_text(elements)
|
59
|
+
elements.select do |el|
|
60
|
+
next(el.inner_text =~ @inner_text) if @inner_text.is_a?(Regexp)
|
61
|
+
el.inner_text == @inner_text
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def filter_on_nested_expectations(elements, block)
|
66
|
+
elements.select do |el|
|
67
|
+
begin
|
68
|
+
block.call(el)
|
69
|
+
rescue Spec::Expectations::ExpectationNotMetError
|
70
|
+
false
|
71
|
+
else
|
72
|
+
true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def acceptable_count?(actual_count)
|
78
|
+
if @options[:count]
|
79
|
+
return false unless @options[:count] === actual_count
|
80
|
+
end
|
81
|
+
if @options[:minimum]
|
82
|
+
return false unless actual_count >= @options[:minimum]
|
83
|
+
end
|
84
|
+
if @options[:maximum]
|
85
|
+
return false unless actual_count <= @options[:maximum]
|
86
|
+
end
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def failure_count_phrase
|
91
|
+
if @options[:count]
|
92
|
+
"#{@options[:count]} elements matching"
|
93
|
+
elsif @options[:minimum] || @options[:maximum]
|
94
|
+
count_explanations = []
|
95
|
+
count_explanations << "at least #{@options[:minimum]}" if @options[:minimum]
|
96
|
+
count_explanations << "at most #{@options[:maximum]}" if @options[:maximum]
|
97
|
+
"#{count_explanations.join(' and ')} elements matching"
|
98
|
+
else
|
99
|
+
"an element matching"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def failure_selector_phrase
|
104
|
+
phrase = @selector.inspect
|
105
|
+
phrase << (@inner_text ? " with inner text #{@inner_text.inspect}" : "")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def have_tag(selector, inner_text_or_options = nil, options = {}, &block)
|
110
|
+
HaveTag.new(selector, inner_text_or_options, options, &block)
|
111
|
+
end
|
112
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: breadmachine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Southerden
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-05 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: money
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: builder
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: notahat-machinist
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: cucumber
|
67
|
+
type: :development
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
description: BreadMachine facilitates payment processing, including 3-D Secure, with the SecureTrading XPay gateway
|
76
|
+
email: matt@localbubble.com
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files:
|
82
|
+
- LICENSE
|
83
|
+
- README.rdoc
|
84
|
+
files:
|
85
|
+
- lib/breadmachine.rb
|
86
|
+
- lib/breadmachine/dto/card.rb
|
87
|
+
- lib/breadmachine/dto/customer_info.rb
|
88
|
+
- lib/breadmachine/dto/order_info.rb
|
89
|
+
- lib/breadmachine/dto/three_d_secure_credentials.rb
|
90
|
+
- lib/breadmachine/extensions.rb
|
91
|
+
- lib/breadmachine/extensions/money.rb
|
92
|
+
- lib/breadmachine/secure_trading.rb
|
93
|
+
- lib/breadmachine/secure_trading/auth_request.rb
|
94
|
+
- lib/breadmachine/secure_trading/auth_reversal_request.rb
|
95
|
+
- lib/breadmachine/secure_trading/auth_reversal_response.rb
|
96
|
+
- lib/breadmachine/secure_trading/card_xml.rb
|
97
|
+
- lib/breadmachine/secure_trading/config.rb
|
98
|
+
- lib/breadmachine/secure_trading/customer_info_auth_xml.rb
|
99
|
+
- lib/breadmachine/secure_trading/customer_info_enrolment_xml.rb
|
100
|
+
- lib/breadmachine/secure_trading/order_info_xml.rb
|
101
|
+
- lib/breadmachine/secure_trading/payment_methods.rb
|
102
|
+
- lib/breadmachine/secure_trading/st_3d_auth_request.rb
|
103
|
+
- lib/breadmachine/secure_trading/st_3d_auth_response.rb
|
104
|
+
- lib/breadmachine/secure_trading/st_3d_card_query_request.rb
|
105
|
+
- lib/breadmachine/secure_trading/st_3d_card_query_response.rb
|
106
|
+
- lib/breadmachine/secure_trading/three_d_secure_credentials_xml.rb
|
107
|
+
- lib/breadmachine/secure_trading/xpay.rb
|
108
|
+
- lib/breadmachine/secure_trading/xpay_socket.rb
|
109
|
+
- LICENSE
|
110
|
+
- README.rdoc
|
111
|
+
has_rdoc: true
|
112
|
+
homepage: http://github.com/mattsoutherden/breadmachine
|
113
|
+
licenses: []
|
114
|
+
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options:
|
117
|
+
- --charset=UTF-8
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: "0"
|
125
|
+
version:
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: "0"
|
131
|
+
version:
|
132
|
+
requirements: []
|
133
|
+
|
134
|
+
rubyforge_project: breadmachine
|
135
|
+
rubygems_version: 1.3.5
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: Make dough with Bread Machine; a ruby library for payment processing.
|
139
|
+
test_files:
|
140
|
+
- spec/blueprints.rb
|
141
|
+
- spec/breadmachine_spec.rb
|
142
|
+
- spec/extensions/money_spec.rb
|
143
|
+
- spec/secure_trading/auth_request_spec.rb
|
144
|
+
- spec/secure_trading/bread_machine_spec.rb
|
145
|
+
- spec/secure_trading/card_xml_spec.rb
|
146
|
+
- spec/secure_trading/config_spec.rb
|
147
|
+
- spec/secure_trading/customer_info_auth_xml_spec.rb
|
148
|
+
- spec/secure_trading/customer_info_enrolment_xml_spec.rb
|
149
|
+
- spec/secure_trading/order_info_xml_spec.rb
|
150
|
+
- spec/secure_trading/st_3d_auth_request_spec.rb
|
151
|
+
- spec/secure_trading/st_3d_auth_response_spec.rb
|
152
|
+
- spec/secure_trading/st_3d_card_query_request_spec.rb
|
153
|
+
- spec/secure_trading/st_3d_card_query_response_spec.rb
|
154
|
+
- spec/secure_trading/st_auth_request_spec.rb
|
155
|
+
- spec/secure_trading/st_auth_reversal_request_spec.rb
|
156
|
+
- spec/secure_trading/st_refund_request_spec.rb
|
157
|
+
- spec/secure_trading/st_refund_reversal_request_spec.rb
|
158
|
+
- spec/secure_trading/st_settlement_request_spec.rb
|
159
|
+
- spec/secure_trading/three_d_secure_credentials_xml_spec.rb
|
160
|
+
- spec/secure_trading/xpay_socket_spec.rb
|
161
|
+
- spec/secure_trading/xpay_spec.rb
|
162
|
+
- spec/spec_helper.rb
|
163
|
+
- spec/support/matchers/have_tag.rb
|