bitcoin_cleaner 1.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.gitmodules +9 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +1 -0
- data/bitcoin_cleaner.gemspec +24 -0
- data/lib/bitcoin_cleaner.rb +44 -0
- data/lib/bitcoin_cleaner/booter.rb +36 -0
- data/lib/bitcoin_cleaner/check_vcr_cassette.rb +9 -0
- data/lib/bitcoin_cleaner/detector.rb +15 -0
- data/lib/bitcoin_cleaner/determine_run.rb +23 -0
- data/lib/bitcoin_cleaner/executes.rb +10 -0
- data/lib/bitcoin_cleaner/executor.rb +20 -0
- data/lib/bitcoin_cleaner/prepares_command.rb +9 -0
- data/lib/bitcoin_cleaner/stopper.rb +23 -0
- data/lib/bitcoin_cleaner/vcr_integrator.rb +31 -0
- data/lib/bitcoin_cleaner/version.rb +3 -0
- data/spec/bitcoin_testnet/check_vcr_cassette_spec.rb +36 -0
- data/spec/bitcoin_testnet/determine_run_spec.rb +101 -0
- data/spec/bitcoin_testnet/executes_spec.rb +21 -0
- data/spec/bitcoin_testnet/executor_spec.rb +15 -0
- data/spec/bitcoin_testnet/prepares_command_spec.rb +14 -0
- data/spec/bitcoin_testnet/vcr_integrator_spec.rb +15 -0
- data/spec/spec_helper.rb +6 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13e0b9e2b053325e5440e4fe6bdc3ef0b014e3fa
|
4
|
+
data.tar.gz: 361f83cda81da4476da8db34163c0dd57c51f7c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0956d30f1d26251d94d5d66bd82831f278edbda6e4d4ef8baf59a183bb5a10d4a59aa84bc1dd0168896761aa4e978c7281488153c5e16fb69126b752f5fa8121
|
7
|
+
data.tar.gz: ce78594ba00148cab2b2137418d88b76d6c62c359086178fb265a728bf1ea941d084604377df002f532dd9de85b8101ff56dd73be74f2630274af5009d7afd8e
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
[submodule "git:/github.com/freewil/bitcoin-testnet-box.git"]
|
2
|
+
path = git:/github.com/freewil/bitcoin-testnet-box.git
|
3
|
+
url = ./testnet
|
4
|
+
[submodule "git@github.com:freewil/bitcoin-testnet-box.git"]
|
5
|
+
path = git@github.com:freewil/bitcoin-testnet-box.git
|
6
|
+
url = ./testnet
|
7
|
+
[submodule "testnet"]
|
8
|
+
path = testnet
|
9
|
+
url = git://github.com/freewil/bitcoin-testnet-box.git
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# 1.0.0.beta.1
|
2
|
+
|
3
|
+
- Rename project from BitcoinTestnet to BitcoinCleaner
|
4
|
+
- Use `-regtest` switch on bitcoind instead of the testnet
|
5
|
+
|
6
|
+
# v0.6.0
|
7
|
+
|
8
|
+
- remove embedded testnet
|
9
|
+
|
10
|
+
# v0.5.1
|
11
|
+
|
12
|
+
- Do not record the vcr cassette if the example fails [#6]
|
13
|
+
|
14
|
+
# v0.5.0
|
15
|
+
|
16
|
+
- Redirect all bitcoin make logging to /dev/null -- makes things more quiet when running specs
|
17
|
+
|
18
|
+
# v0.4.1
|
19
|
+
|
20
|
+
- Loosen constraint on ActiveSupport version
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 - 2014 Ramon Tayag
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# BitcoinCleaner
|
2
|
+
|
3
|
+
Makes development with Bitcoin a little easier. It has helpers that can be used to start, stop, clean the bitcoin daemon. The bitcoin daemon will be run in regtest mode.
|
4
|
+
|
5
|
+
This gem been written using Bitcoin Core `0.9.2.1`. BitcoinCleaner takes advantage of the `regtest` option in the new version of Bitcoin Core. Starting `bitcoind -regtest` will create a private network that's a lot faster than the testnet, and easier to manage then a private testnet.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
1. Make sure that Bitcoin Core is installed in your system and `bitcoind` and `bitcoin-cli` are in your path.
|
10
|
+
2. Require the library in your `test_helper`/`spec_helper`: `require 'bitcoin_cleaner'`. Now, you have access to `BitcoinCleaner`.
|
11
|
+
3. In your `test_helper`/`spec_helper` add `BitcoinCleaner.conf_dir = "/path/to/conf/dir"`. This is the folder that contains the bitcoin.conf, and more importantly, the `regtest`. The wallet in `regtest/wallet.dat` will be deleted between runs to make the wallet pristine again. It normally looks like this:
|
12
|
+
|
13
|
+
```
|
14
|
+
~ ❯❯❯ ls ~/.bitcoin
|
15
|
+
blocks chainstate regtest bitcoin.conf db.log debug.log peers.dat wallet.dat
|
16
|
+
```
|
17
|
+
|
18
|
+
4. Tell `BitcoinCleaner` when to do its work by adding `bitcoin_cleaner: true` to the metadata.
|
19
|
+
|
20
|
+
Sample with RSpec:
|
21
|
+
|
22
|
+
```
|
23
|
+
it "sends bitcoin to the given address", bitcoin_cleaner: true
|
24
|
+
```
|
25
|
+
|
26
|
+
### RSpec and VCR
|
27
|
+
|
28
|
+
Cleaning the daemon every time is slow. If you have VCR, you can make this a lot faster by calling `BitcoinCleaner.configure_with_rspec_and_vcr!` in your spec helper. With this, you won't need to call `BitcoinCleaner#start` and `BitcoinCleaner#stop`.
|
29
|
+
|
30
|
+
## Tip
|
31
|
+
|
32
|
+
To make integration tests faster, use something like [VCR](https://github.com/vcr/vcr) to record the communication between your project and the daemon.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
I suggest you do your development in this [Vagrant box](https://github.com/ramontayag/ruby-bitcoin-box). I use it for my development.
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
43
|
+
|
44
|
+
If you find this useful, consider sharing some BTC love: `1PwQWijmJ39hWXk9X3CdAhEdExdkANEAPk`
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bitcoin_cleaner/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "bitcoin_cleaner"
|
8
|
+
gem.version = BitcoinCleaner::VERSION
|
9
|
+
gem.authors = ["Ramon Tayag"]
|
10
|
+
gem.email = ["ramon.tayag@gmail.com"]
|
11
|
+
gem.description = %q{A gem of helpers for making integration tests with the Bitcoind a little easier.}
|
12
|
+
gem.summary = %q{A gem of helpers for making integration tests with the Bitcoind a little easier.}
|
13
|
+
gem.homepage = "https://github.com/ramontayag/ruby-bitcoin_cleaner"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'activesupport'
|
21
|
+
gem.add_dependency 'wait', '~> 0.5.1'
|
22
|
+
gem.add_development_dependency 'rspec', "~> 3.0"
|
23
|
+
gem.add_development_dependency 'vcr'
|
24
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'wait'
|
2
|
+
require "bitcoin_cleaner/version"
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
|
5
|
+
require 'bitcoin_cleaner/detector'
|
6
|
+
require 'bitcoin_cleaner/executor'
|
7
|
+
require 'bitcoin_cleaner/booter'
|
8
|
+
require 'bitcoin_cleaner/stopper'
|
9
|
+
require 'bitcoin_cleaner/executes'
|
10
|
+
require 'bitcoin_cleaner/prepares_command'
|
11
|
+
require 'bitcoin_cleaner/vcr_integrator'
|
12
|
+
require 'bitcoin_cleaner/check_vcr_cassette'
|
13
|
+
require 'bitcoin_cleaner/determine_run'
|
14
|
+
|
15
|
+
module BitcoinCleaner
|
16
|
+
|
17
|
+
mattr_accessor :dir
|
18
|
+
@@dir = nil
|
19
|
+
|
20
|
+
mattr_accessor :current_test
|
21
|
+
@@current_test = nil
|
22
|
+
|
23
|
+
def self.start
|
24
|
+
Booter.boot
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.stop
|
28
|
+
Stopper.stop
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.configure_with_rspec_and_vcr!
|
32
|
+
RSpec.configure do |c|
|
33
|
+
c.before(:each) { VcrIntegrator.start(example) }
|
34
|
+
c.after(:each) { VcrIntegrator.stop(example) }
|
35
|
+
end
|
36
|
+
|
37
|
+
VCR.configure do |c|
|
38
|
+
c.before_record do |interaction|
|
39
|
+
interaction.ignore! if BitcoinCleaner.current_test.exception
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module BitcoinCleaner
|
2
|
+
class Booter
|
3
|
+
|
4
|
+
def self.boot(*args)
|
5
|
+
Stopper.stop if Detector.exists?
|
6
|
+
|
7
|
+
pid_file = File.join(BitcoinCleaner.dir, "regtest", "bitcoind.pid")
|
8
|
+
thread = Thread.new do
|
9
|
+
Executes.command "bitcoind -regtest -daemon -pid=#{pid_file}"
|
10
|
+
end
|
11
|
+
|
12
|
+
Wait.new.until do
|
13
|
+
thread.status == false && Detector.exists?
|
14
|
+
end
|
15
|
+
|
16
|
+
if Detector.exists?
|
17
|
+
generate_coins
|
18
|
+
else
|
19
|
+
message = [
|
20
|
+
"The bitcoin processes didn't seem to start",
|
21
|
+
"Please ensure that the bitcoind can be started",
|
22
|
+
]
|
23
|
+
fail message*". "
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.generate_coins
|
28
|
+
Executes.command "bitcoin-cli -regtest setgenerate true 101"
|
29
|
+
Wait.new.until do
|
30
|
+
default_account_balance = `bitcoin-cli -regtest getbalance ""`.to_f
|
31
|
+
default_account_balance > 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BitcoinCleaner
|
2
|
+
class DetermineRun
|
3
|
+
|
4
|
+
def self.execute(rspec_example)
|
5
|
+
return true unless defined?(VCR)
|
6
|
+
|
7
|
+
bitcoin_cleaner_metadata = rspec_example.metadata[:bitcoin_cleaner]
|
8
|
+
vcr_metadata = rspec_example.metadata[:vcr]
|
9
|
+
return false unless bitcoin_cleaner_metadata == true
|
10
|
+
if vcr_metadata != true && !vcr_metadata.nil?
|
11
|
+
return false if vcr_metadata[:record] == :once && cassette_exists?
|
12
|
+
end
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def self.cassette_exists?
|
19
|
+
CheckVcrCassette.exists?(VCR.current_cassette)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BitcoinCleaner
|
2
|
+
class Executor
|
3
|
+
|
4
|
+
def self.execute(*args)
|
5
|
+
self.new(*args).execute
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(*commands)
|
9
|
+
@commands = commands
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute
|
13
|
+
Dir.chdir BitcoinCleaner.dir do
|
14
|
+
commands = @commands.map { |c| "#{c} > /dev/null 2>&1"}
|
15
|
+
system commands.join(' && ')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BitcoinCleaner
|
2
|
+
class Stopper
|
3
|
+
|
4
|
+
def self.stop
|
5
|
+
kill_bitcoind if Detector.exists?
|
6
|
+
Wait.new.until { !Detector.exists? }
|
7
|
+
fail "Looks like it didn't stop" if Detector.exists?
|
8
|
+
remove_regtest_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def self.kill_bitcoind
|
14
|
+
system %Q(kill -9 `ps -ef | grep "bitcoind -regtest" | grep -v grep | awk '{print $2}'`)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.remove_regtest_dir
|
18
|
+
regtest_dir = File.join(BitcoinCleaner.dir, "regtest")
|
19
|
+
FileUtils.rm_rf regtest_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BitcoinCleaner
|
2
|
+
class VcrIntegrator
|
3
|
+
|
4
|
+
def self.start(*args)
|
5
|
+
self.new(*args).start
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.stop(*args)
|
9
|
+
self.new(*args).stop
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(rspec_example)
|
13
|
+
BitcoinCleaner.current_test = @rspec_example = rspec_example
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
BitcoinCleaner.start if should_perform?
|
18
|
+
end
|
19
|
+
|
20
|
+
def stop
|
21
|
+
BitcoinCleaner.stop if should_perform?
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def should_perform?
|
27
|
+
DetermineRun.execute(@rspec_example)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module BitcoinCleaner
|
4
|
+
describe CheckVcrCassette, ".exists?" do
|
5
|
+
|
6
|
+
subject { described_class.exists?(current_cassette) }
|
7
|
+
|
8
|
+
context "there is a cassette" do
|
9
|
+
let(:current_cassette) { double(file: file_path) }
|
10
|
+
let(:file_path) { File.join(SPEC_DIR, "..", "tmp", "cassette.xml") }
|
11
|
+
|
12
|
+
context "there is a file" do
|
13
|
+
context "file exists in the disk" do
|
14
|
+
before { FileUtils.touch(file_path) }
|
15
|
+
it { is_expected.to be true }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "file does not exist on the disk" do
|
19
|
+
before { FileUtils.rm(file_path) }
|
20
|
+
it { is_expected.to be false }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "there is no file" do
|
25
|
+
let(:cassette_file) { nil }
|
26
|
+
it { is_expected.to be false }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "there is no cassette" do
|
31
|
+
let(:current_cassette) { nil }
|
32
|
+
it { is_expected.to be false }
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module BitcoinCleaner
|
4
|
+
describe DetermineRun, ".execute" do
|
5
|
+
|
6
|
+
let(:rspec_example) do
|
7
|
+
double(
|
8
|
+
metadata: {
|
9
|
+
vcr: vcr_metadata,
|
10
|
+
bitcoin_cleaner: bitcoin_cleaner_metadata,
|
11
|
+
}
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:current_cassette) { double }
|
16
|
+
let(:vcr_metadata) { nil }
|
17
|
+
|
18
|
+
subject { described_class.execute(rspec_example) }
|
19
|
+
|
20
|
+
before do
|
21
|
+
allow(VCR).to receive(:current_cassette).and_return(current_cassette)
|
22
|
+
end
|
23
|
+
|
24
|
+
context "bitcoin_cleaner is false" do
|
25
|
+
let(:bitcoin_cleaner_metadata) { false }
|
26
|
+
|
27
|
+
it { is_expected.to be false }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "bitcoin_cleaner is true" do
|
31
|
+
let(:bitcoin_cleaner_metadata) { true }
|
32
|
+
context "vcr metadata is true and cassette exists" do
|
33
|
+
let(:vcr_metadata) { true }
|
34
|
+
|
35
|
+
before do
|
36
|
+
allow(CheckVcrCassette).to receive(:exists?).with(current_cassette).
|
37
|
+
and_return(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it { is_expected.to be true }
|
41
|
+
end
|
42
|
+
|
43
|
+
context "vcr metadata is true and cassette does not exist" do
|
44
|
+
let(:vcr_metadata) { true }
|
45
|
+
|
46
|
+
before do
|
47
|
+
allow(CheckVcrCassette).to receive(:exists?).with(current_cassette).
|
48
|
+
and_return(false)
|
49
|
+
end
|
50
|
+
|
51
|
+
it { is_expected.to be true }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "vcr metadata is set to record all and cassette exists" do
|
55
|
+
let(:vcr_metadata) { {record: :all} }
|
56
|
+
before do
|
57
|
+
allow(CheckVcrCassette).to receive(:exists?).with(current_cassette).
|
58
|
+
and_return(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
it { is_expected.to be true }
|
62
|
+
end
|
63
|
+
|
64
|
+
context "vcr metadata is set to record all and cassette does not exist" do
|
65
|
+
let(:vcr_metadata) { {record: :all} }
|
66
|
+
before do
|
67
|
+
allow(CheckVcrCassette).to receive(:exists?).with(current_cassette).
|
68
|
+
and_return(false)
|
69
|
+
end
|
70
|
+
|
71
|
+
it { is_expected.to be true }
|
72
|
+
end
|
73
|
+
|
74
|
+
context "vcr metadata is set to record once and cassette exists" do
|
75
|
+
let(:vcr_metadata) { {record: :once} }
|
76
|
+
before do
|
77
|
+
allow(CheckVcrCassette).to receive(:exists?).with(current_cassette).
|
78
|
+
and_return(true)
|
79
|
+
end
|
80
|
+
|
81
|
+
it { is_expected.to be false }
|
82
|
+
end
|
83
|
+
|
84
|
+
context "vcr metadata is set to record once and cassette does not exist" do
|
85
|
+
let(:vcr_metadata) { {record: :once} }
|
86
|
+
before do
|
87
|
+
allow(CheckVcrCassette).to receive(:exists?).with(current_cassette).
|
88
|
+
and_return(false)
|
89
|
+
end
|
90
|
+
|
91
|
+
it { is_expected.to be true }
|
92
|
+
end
|
93
|
+
|
94
|
+
context "vcr metadata is not set" do
|
95
|
+
let(:vcr_metadata) { nil }
|
96
|
+
it { is_expected.to be true }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module BitcoinCleaner
|
4
|
+
describe Executes do
|
5
|
+
|
6
|
+
describe ".command" do
|
7
|
+
it "executes the prepared command" do
|
8
|
+
command = "do this"
|
9
|
+
prepared_command = "do this prepared"
|
10
|
+
|
11
|
+
allow(PreparesCommand).to receive(:for_silence).with(command).
|
12
|
+
and_return(prepared_command)
|
13
|
+
|
14
|
+
expect(described_class).to receive(:system).with(prepared_command)
|
15
|
+
|
16
|
+
described_class.command(command)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module BitcoinCleaner
|
4
|
+
describe PreparesCommand do
|
5
|
+
|
6
|
+
describe ".for_silence" do
|
7
|
+
it "redirects stdout and stderr to /dev/null" do
|
8
|
+
expect(described_class.for_silence("some command")).
|
9
|
+
to eq("some command > /dev/null 2>&1")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module BitcoinCleaner
|
4
|
+
describe VcrIntegrator do
|
5
|
+
|
6
|
+
describe ".start" do
|
7
|
+
it "sets the BitcoinCleaner.current_test to be the given test" do
|
8
|
+
test = double(metadata: {})
|
9
|
+
described_class.start(test)
|
10
|
+
expect(BitcoinCleaner.current_test).to eq(test)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bitcoin_cleaner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.beta.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ramon Tayag
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: wait
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A gem of helpers for making integration tests with the Bitcoind a little
|
70
|
+
easier.
|
71
|
+
email:
|
72
|
+
- ramon.tayag@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .gitmodules
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bitcoin_cleaner.gemspec
|
85
|
+
- lib/bitcoin_cleaner.rb
|
86
|
+
- lib/bitcoin_cleaner/booter.rb
|
87
|
+
- lib/bitcoin_cleaner/check_vcr_cassette.rb
|
88
|
+
- lib/bitcoin_cleaner/detector.rb
|
89
|
+
- lib/bitcoin_cleaner/determine_run.rb
|
90
|
+
- lib/bitcoin_cleaner/executes.rb
|
91
|
+
- lib/bitcoin_cleaner/executor.rb
|
92
|
+
- lib/bitcoin_cleaner/prepares_command.rb
|
93
|
+
- lib/bitcoin_cleaner/stopper.rb
|
94
|
+
- lib/bitcoin_cleaner/vcr_integrator.rb
|
95
|
+
- lib/bitcoin_cleaner/version.rb
|
96
|
+
- spec/bitcoin_testnet/check_vcr_cassette_spec.rb
|
97
|
+
- spec/bitcoin_testnet/determine_run_spec.rb
|
98
|
+
- spec/bitcoin_testnet/executes_spec.rb
|
99
|
+
- spec/bitcoin_testnet/executor_spec.rb
|
100
|
+
- spec/bitcoin_testnet/prepares_command_spec.rb
|
101
|
+
- spec/bitcoin_testnet/vcr_integrator_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: https://github.com/ramontayag/ruby-bitcoin_cleaner
|
104
|
+
licenses: []
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>'
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 1.3.1
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: A gem of helpers for making integration tests with the Bitcoind a little
|
126
|
+
easier.
|
127
|
+
test_files:
|
128
|
+
- spec/bitcoin_testnet/check_vcr_cassette_spec.rb
|
129
|
+
- spec/bitcoin_testnet/determine_run_spec.rb
|
130
|
+
- spec/bitcoin_testnet/executes_spec.rb
|
131
|
+
- spec/bitcoin_testnet/executor_spec.rb
|
132
|
+
- spec/bitcoin_testnet/prepares_command_spec.rb
|
133
|
+
- spec/bitcoin_testnet/vcr_integrator_spec.rb
|
134
|
+
- spec/spec_helper.rb
|