coloredcoins 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc8e4c5b4f4d87e29d1ce9c2e0d5b22890dd75c3
4
- data.tar.gz: 3ffc996218444f1665ca80199d326244c33d7a78
3
+ metadata.gz: 5ff06df2a3869d6b48c15bd1bfa61955e4910393
4
+ data.tar.gz: af62dad99c005945113dcfdedfd5e65b7fefcdb4
5
5
  SHA512:
6
- metadata.gz: 3e207996c656637f96f0f30aaf55cc52b10ac68bf5dc4335447de584e2e78a60c80a86d1c0dc1703a90c79cd38b7192d9d4c6edf2b1957bb6baa3c8db87a30f9
7
- data.tar.gz: 1d74d40c5008bad348de132ce5d285d0f9fdf22c312fe04ea6e1954483a1e3df151bd89a8c834d09ebdb4ecc59d650bfb21484293e3a16a19cf4046de23844e5
6
+ metadata.gz: cbfecf418c0d040f8e6778acf9ab24c0a43970afe6a1224ae792e98e36e702ff1fed7e063db70096e98f13b5bfa9630215c068a9eb785596c88e59de5b237f40
7
+ data.tar.gz: a7535aefe05fb8632af482a3b52592a31e5de1be113718be45c1b6466ea4993d83cb596519aae446f9b455d8124be9b8ea1446d112a602f8571e727d9ef5f989
data/Gemfile CHANGED
@@ -7,5 +7,6 @@ group :development, :test do
7
7
  gem 'coveralls', require: false
8
8
  gem 'guard'
9
9
  gem 'guard-rspec'
10
+ gem 'guard-rubocop'
10
11
  gem 'terminal-notifier-guard'
11
12
  end
data/Guardfile CHANGED
@@ -21,3 +21,8 @@ guard :rspec, rspec_options do
21
21
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
22
22
  watch(rspec.spec_helper) { rspec.spec_dir }
23
23
  end
24
+
25
+ guard :rubocop, all_on_start: true do
26
+ watch(/.+\.rb$/)
27
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
28
+ end
@@ -35,8 +35,9 @@ module Coloredcoins
35
35
 
36
36
  def broadcast
37
37
  response = Coloredcoins.broadcast(to_hex)
38
- return response[:txId] if response[:txId]
39
- response
38
+ return response unless response[:txid]
39
+ txid = response[:txid]
40
+ txid.is_a?(Array) ? txid.first[:txid] : txid
40
41
  end
41
42
  end
42
43
  end
@@ -1,3 +1,3 @@
1
1
  module Coloredcoins
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -206,16 +206,31 @@ describe Coloredcoins::MultisigTx do
206
206
  end
207
207
 
208
208
  describe '#broadcast' do
209
- let!(:tx_id) { 'some-transaction-hash' }
210
- let!(:broadcast_response) { { txId: tx_id } }
209
+ shared_examples 'a success broadcast' do
210
+ before do
211
+ allow(Coloredcoins).to receive(:broadcast).and_return(broadcast_response)
212
+ end
213
+ before { @response = subject.broadcast }
214
+
215
+ it { expect(Coloredcoins).to have_received(:broadcast).once }
216
+
217
+ it { expect(@response).to eq(tx_id) }
218
+ end
211
219
 
212
- before do
213
- allow(Coloredcoins).to receive(:broadcast).and_return(broadcast_response)
220
+ context 'when receive an object - as mark in the documentation' do
221
+ let!(:tx_id) { 'some-transaction-hash' }
222
+
223
+ it_behaves_like 'a success broadcast' do
224
+ let!(:broadcast_response) { { txid: tx_id } }
225
+ end
214
226
  end
215
- before { @response = subject.broadcast }
216
227
 
217
- it { expect(Coloredcoins).to have_received(:broadcast).once }
228
+ context 'when receive an array' do
229
+ let!(:tx_id) { 'some-transaction-hash' }
218
230
 
219
- it { expect(@response).to eq(tx_id) }
231
+ it_behaves_like 'a success broadcast' do
232
+ let!(:broadcast_response) { { txid: [{ txid: tx_id }] } }
233
+ end
234
+ end
220
235
  end
221
236
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coloredcoins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genaro Madrid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client