helloblock-ruby 0.0.1

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.
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe HelloBlock::Client, '#env' do
4
+ it 'defaults to testnet' do
5
+ client = HelloBlock::Client.new
6
+
7
+ expect(client.network).to eq :testnet
8
+ end
9
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe HelloBlock::Client::Endpoints, '#base_url' do
4
+ let(:client) { HelloBlock::Client.new }
5
+
6
+ it 'returns a path to the api url given the network subdomain' do
7
+ client.network = :testnet
8
+
9
+ expect(client.base_url).to eq 'http://testnet.helloblock.io'
10
+ end
11
+ end
12
+
13
+ describe HelloBlock::Client::Endpoints, '#post_request?' do
14
+ let(:client) { HelloBlock::Client.new }
15
+ before :each do
16
+ stub_const('HelloBlock::Client::Endpoints::POST_REQUESTS', [:propagate])
17
+ end
18
+
19
+ it 'is true if the method called is a post request' do
20
+ expect(client.post_request?(:propagate)).to eq true
21
+ end
22
+
23
+ it 'is false otherwise' do
24
+ expect(client.post_request?(:bitcoin)).to eq false
25
+ end
26
+ end
27
+
28
+ describe HelloBlock::Client::Endpoints, '#endpoint_defined?' do
29
+ let(:client) { HelloBlock::Client.new }
30
+ before :each do
31
+ stub_const('HelloBlock::Client::Endpoints::ADDRESSES_PATH', '/addresses')
32
+ end
33
+
34
+ it 'is true if the endpoint suffixed with "_PATH" maps to a path' do
35
+ expect(client.endpoint_defined?(:addresses)).to eq true
36
+ end
37
+
38
+ it 'is false otherwise' do
39
+ expect(client.endpoint_defined?(:bitcoin)).to eq false
40
+ end
41
+ end
42
+
43
+ describe HelloBlock::Client::Endpoints, '#navigate_to_path' do
44
+ let(:client) { HelloBlock::Client.new }
45
+ before :each do
46
+ stub_const('HelloBlock::Client::Endpoints::ADDRESSES_PATH', '/addresses')
47
+ end
48
+
49
+ it 'routes a GET method to a GET route' do
50
+ client.stub(:get)
51
+
52
+ client.navigate_to_path(:addresses, addresses: ['abc', '123'])
53
+
54
+ expect(client).to have_received(:get).with(
55
+ '/addresses', addresses: ['abc', '123']
56
+ )
57
+ end
58
+
59
+ it 'routes a POST method to a POST route' do
60
+ stub_const('HelloBlock::Client::Endpoints::POST_REQUESTS', [:addresses])
61
+ client.stub(:post)
62
+
63
+ client.navigate_to_path(:addresses, addresses: ['abc', '123'])
64
+
65
+ expect(client).to have_received(:post).with(
66
+ '/addresses', body: { addresses: ['abc', '123'] }
67
+ )
68
+ end
69
+ end
70
+
71
+ describe HelloBlock::Client::Endpoints, '#method_missing' do
72
+ let(:client) { HelloBlock::Client.new }
73
+
74
+ it 'navigates to an endpoint if the method resembles an endpoint' do
75
+ stub_const('HelloBlock::Client::Endpoints::BANANAS_PATH', '/bananas')
76
+ client.stub(:navigate_to_path)
77
+
78
+ client.bananas(variety: 'chaquita')
79
+
80
+ expect(client).to have_received(:navigate_to_path).with(
81
+ :bananas, variety: 'chaquita'
82
+ )
83
+ end
84
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe HelloBlock::Client::Request, '#get' do
4
+ let(:client) { HelloBlock::Client.new }
5
+ let(:connection) { double(:connection).as_null_object }
6
+
7
+ it 'makes a GET request to the provided path and with the provided params' do
8
+ client.stub(:connection).and_return(connection)
9
+
10
+ client.get('/addresses', addresses: ['abc', '123'])
11
+
12
+ expect(connection).to have_received(:get).with(
13
+ '/addresses', { addresses: 'abc&addresses=123' }, {
14
+ accept: '*/*', content_type: 'application/json; charset=UTF-8'
15
+ }
16
+ )
17
+ end
18
+ end
19
+
20
+ describe HelloBlock::Client::Request, '#post' do
21
+ let(:client) { HelloBlock::Client.new }
22
+ let(:connection) { double(:connection).as_null_object }
23
+
24
+ it 'makes a POST request to the provided path and with the provided body' do
25
+ client.stub(:connection).and_return(connection)
26
+
27
+ client.post('/addresses', addresses: ['abc', '123'])
28
+
29
+ expect(connection).to have_received(:post).with(
30
+ '/addresses', { body: { addresses: ['abc', '123'] } }, {
31
+ accept: '*/*', content_type: 'application/json; charset=UTF-8'
32
+ }
33
+ )
34
+ end
35
+ end
@@ -0,0 +1,8 @@
1
+ require 'helloblock'
2
+ require 'rspec'
3
+ require 'vcr'
4
+
5
+ VCR.configure do |config|
6
+ config.cassette_library_dir = 'spec/fixture/vcr_cassettes'
7
+ config.hook_into :webmock
8
+ end
metadata ADDED
@@ -0,0 +1,229 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: helloblock-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nathaniel Wroblewski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.17'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.17'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.8'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '4.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '4.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: multi_json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.9'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yajl-ruby
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.2'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '1.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: faraday_middleware
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '0.9'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '0.9'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rash
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: '0.4'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: '0.4'
153
+ description: Ruby wrapper for the HelloBlock.io API
154
+ email:
155
+ - nathanielwroblewski@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - .gitignore
161
+ - Gemfile
162
+ - LICENSE.txt
163
+ - README.md
164
+ - Rakefile
165
+ - fixture/vcr_cassettes/addresses.yml
166
+ - helloblock-ruby.gemspec
167
+ - lib/helloblock.rb
168
+ - lib/helloblock/client.rb
169
+ - lib/helloblock/client/connection.rb
170
+ - lib/helloblock/client/endpoints.rb
171
+ - lib/helloblock/client/request.rb
172
+ - lib/helloblock/version.rb
173
+ - spec/fixture/vcr_cassettes/addresses.yml
174
+ - spec/fixture/vcr_cassettes/blocks.yml
175
+ - spec/fixture/vcr_cassettes/faucet.yml
176
+ - spec/fixture/vcr_cassettes/latest_blocks.yml
177
+ - spec/fixture/vcr_cassettes/latest_transaction.yml
178
+ - spec/fixture/vcr_cassettes/propagate.yml
179
+ - spec/fixture/vcr_cassettes/transactions.yml
180
+ - spec/fixture/vcr_cassettes/transactions_for_address.yml
181
+ - spec/fixture/vcr_cassettes/unspents.yml
182
+ - spec/fixture/vcr_cassettes/wallet.yml
183
+ - spec/fixture/vcr_cassettes/withdrawal.yml
184
+ - spec/integration/calls_api_spec.rb
185
+ - spec/lib/client_spec.rb
186
+ - spec/lib/helloblock/endpoints_spec.rb
187
+ - spec/lib/helloblock/request_spec.rb
188
+ - spec/spec_helper.rb
189
+ homepage: http://www.github.com/nathanielwroblewski/helloblock-ruby
190
+ licenses:
191
+ - MIT
192
+ metadata: {}
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ requirements: []
208
+ rubyforge_project:
209
+ rubygems_version: 2.0.5
210
+ signing_key:
211
+ specification_version: 4
212
+ summary: Ruby wrapper for the HelloBlock.io API
213
+ test_files:
214
+ - spec/fixture/vcr_cassettes/addresses.yml
215
+ - spec/fixture/vcr_cassettes/blocks.yml
216
+ - spec/fixture/vcr_cassettes/faucet.yml
217
+ - spec/fixture/vcr_cassettes/latest_blocks.yml
218
+ - spec/fixture/vcr_cassettes/latest_transaction.yml
219
+ - spec/fixture/vcr_cassettes/propagate.yml
220
+ - spec/fixture/vcr_cassettes/transactions.yml
221
+ - spec/fixture/vcr_cassettes/transactions_for_address.yml
222
+ - spec/fixture/vcr_cassettes/unspents.yml
223
+ - spec/fixture/vcr_cassettes/wallet.yml
224
+ - spec/fixture/vcr_cassettes/withdrawal.yml
225
+ - spec/integration/calls_api_spec.rb
226
+ - spec/lib/client_spec.rb
227
+ - spec/lib/helloblock/endpoints_spec.rb
228
+ - spec/lib/helloblock/request_spec.rb
229
+ - spec/spec_helper.rb