gocardless 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ require 'mocha'
2
+ require 'json'
3
+ require 'gocardless'
4
+
5
+ RSpec.configure do |config|
6
+ config.mock_with :mocha
7
+ end
8
+
9
+ def stub_get(client, data)
10
+ response = mock
11
+ response.stubs(:parsed).returns(data)
12
+
13
+ token = client.instance_variable_get(:@access_token)
14
+ token.stubs(:get).returns response
15
+ end
16
+
17
+ def unset_ivar(obj, var)
18
+ obj.instance_variable_set "@#{var}", nil if obj.instance_variable_get "@#{var}"
19
+ end
20
+
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoCardless::Utils do
4
+
5
+ describe "string helpers" do
6
+ describe ".camelize" do
7
+ it "converts underscored words to camel case" do
8
+ GoCardless::Utils.camelize("a_test_string").should == "ATestString"
9
+ end
10
+ end
11
+
12
+ describe ".underscore" do
13
+ it "converts camel case words to underscored form" do
14
+ GoCardless::Utils.underscore("ATestString").should == "a_test_string"
15
+ end
16
+ end
17
+
18
+ describe ".singularize" do
19
+ it "removes trailing 's' characters" do
20
+ GoCardless::Utils.singularize("desks").should == "desk"
21
+ end
22
+
23
+ it "converts 'i' suffix to 'us'" do
24
+ GoCardless::Utils.singularize("cacti").should == "cactus"
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "hash helpers" do
30
+ describe ".symbolize_keys" do
31
+ it "converts keys to symbols" do
32
+ hash = {'string' => true, 123 => true, :symbol => true}
33
+ keys = GoCardless::Utils.symbolize_keys(hash).keys
34
+ keys.length.should == 3
35
+ keys.should include :string
36
+ keys.should include :'123'
37
+ keys.should include :symbol
38
+ end
39
+
40
+ it "preserves the original hash" do
41
+ hash = {'string' => true}
42
+ GoCardless::Utils.symbolize_keys(hash)
43
+ hash.keys.should == ['string']
44
+ end
45
+
46
+ it "doesn't overwrite existing symbol keys" do
47
+ hash = {'x' => 1, :x => 2}
48
+ GoCardless::Utils.symbolize_keys(hash).should == hash
49
+ end
50
+
51
+ it "works with sinatra params' default proc" do
52
+ hash = Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
53
+ hash['x'] = 1
54
+ GoCardless::Utils.symbolize_keys(hash).should == {:x => 1}
55
+ end
56
+ end
57
+
58
+ describe ".symbolize_keys!" do
59
+ it "modifies the original hash" do
60
+ hash = {'string' => true}
61
+ GoCardless::Utils.symbolize_keys!(hash)
62
+ hash.keys.should == [:string]
63
+ end
64
+ end
65
+ end
66
+
67
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gocardless
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Harry Marr
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-23 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: oauth2
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 15424071
29
+ segments:
30
+ - 0
31
+ - 5
32
+ - 0
33
+ - rc
34
+ - 1
35
+ version: 0.5.0.rc1
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: json
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ hash: 5
47
+ segments:
48
+ - 1
49
+ - 5
50
+ - 3
51
+ version: 1.5.3
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ hash: 15
63
+ segments:
64
+ - 2
65
+ - 6
66
+ version: "2.6"
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 35
78
+ segments:
79
+ - 0
80
+ - 9
81
+ - 12
82
+ version: 0.9.12
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: yard
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 5
94
+ segments:
95
+ - 0
96
+ - 7
97
+ - 3
98
+ version: 0.7.3
99
+ type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: redcarpet
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ hash: 87
110
+ segments:
111
+ - 1
112
+ - 17
113
+ - 2
114
+ version: 1.17.2
115
+ type: :development
116
+ version_requirements: *id006
117
+ description: A Ruby wrapper for the GoCardless API
118
+ email:
119
+ - harry@gocardless.com
120
+ executables: []
121
+
122
+ extensions: []
123
+
124
+ extra_rdoc_files: []
125
+
126
+ files:
127
+ - .gitignore
128
+ - .rspec
129
+ - Gemfile
130
+ - Guardfile
131
+ - LICENSE
132
+ - README.md
133
+ - Rakefile
134
+ - gocardless.gemspec
135
+ - lib/gocardless.rb
136
+ - lib/gocardless/bill.rb
137
+ - lib/gocardless/client.rb
138
+ - lib/gocardless/errors.rb
139
+ - lib/gocardless/merchant.rb
140
+ - lib/gocardless/payment.rb
141
+ - lib/gocardless/pre_authorization.rb
142
+ - lib/gocardless/resource.rb
143
+ - lib/gocardless/subscription.rb
144
+ - lib/gocardless/user.rb
145
+ - lib/gocardless/utils.rb
146
+ - lib/gocardless/version.rb
147
+ - spec/bill_spec.rb
148
+ - spec/client_spec.rb
149
+ - spec/gocardless_spec.rb
150
+ - spec/merchant_spec.rb
151
+ - spec/resource_spec.rb
152
+ - spec/spec_helper.rb
153
+ - spec/utils_spec.rb
154
+ homepage: https://github.com/gocardless/gocardless-ruby
155
+ licenses: []
156
+
157
+ post_install_message:
158
+ rdoc_options: []
159
+
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ hash: 3
168
+ segments:
169
+ - 0
170
+ version: "0"
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ hash: 3
177
+ segments:
178
+ - 0
179
+ version: "0"
180
+ requirements: []
181
+
182
+ rubyforge_project:
183
+ rubygems_version: 1.8.10
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: Ruby wrapper for the GoCardless API
187
+ test_files:
188
+ - spec/bill_spec.rb
189
+ - spec/client_spec.rb
190
+ - spec/gocardless_spec.rb
191
+ - spec/merchant_spec.rb
192
+ - spec/resource_spec.rb
193
+ - spec/spec_helper.rb
194
+ - spec/utils_spec.rb
195
+ has_rdoc: