Skip to content

Commit

Permalink
Merge branch 'release/v0.0.3' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
genaromadrid committed Mar 17, 2016
2 parents d018dcd + b12eb82 commit 37bf21e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ group :development, :test do
gem 'coveralls', require: false
gem 'guard'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'terminal-notifier-guard'
end
5 changes: 5 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ guard :rspec, rspec_options do
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(rspec.spec_helper) { rspec.spec_dir }
end

guard :rubocop, all_on_start: true do
watch(/.+\.rb$/)
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
5 changes: 3 additions & 2 deletions lib/coloredcoins/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def new_tx

def broadcast
response = Coloredcoins.broadcast(to_hex)
return response[:txId] if response[:txId]
response
return response unless response[:txid]
txid = response[:txid]
txid.is_a?(Array) ? txid.first[:txid] : txid
end
end
end
2 changes: 1 addition & 1 deletion lib/coloredcoins/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Coloredcoins
VERSION = '0.0.2'.freeze
VERSION = '0.0.3'.freeze
end
29 changes: 22 additions & 7 deletions spec/coloredcoins/multisig_tx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,31 @@
end

describe '#broadcast' do
let!(:tx_id) { 'some-transaction-hash' }
let!(:broadcast_response) { { txId: tx_id } }
shared_examples 'a success broadcast' do
before do
allow(Coloredcoins).to receive(:broadcast).and_return(broadcast_response)
end
before { @response = subject.broadcast }

it { expect(Coloredcoins).to have_received(:broadcast).once }

it { expect(@response).to eq(tx_id) }
end

before do
allow(Coloredcoins).to receive(:broadcast).and_return(broadcast_response)
context 'when receive an object - as mark in the documentation' do
let!(:tx_id) { 'some-transaction-hash' }

it_behaves_like 'a success broadcast' do
let!(:broadcast_response) { { txid: tx_id } }
end
end
before { @response = subject.broadcast }

it { expect(Coloredcoins).to have_received(:broadcast).once }
context 'when receive an array' do
let!(:tx_id) { 'some-transaction-hash' }

it { expect(@response).to eq(tx_id) }
it_behaves_like 'a success broadcast' do
let!(:broadcast_response) { { txid: [{ txid: tx_id }] } }
end
end
end
end

0 comments on commit 37bf21e

Please sign in to comment.