bitcoin_testnet 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -35,7 +35,7 @@ Sample with RSpec:
35
35
 
36
36
  ### RSpec and VCR
37
37
 
38
- Cleaning the Testnet every time is slow. If you have VCR, you can make this a lot faster by calling `BitcoinTestnet.configure_rspec_and_vcr!` in your spec helper. With this, you won't need to call `BitcoinTestnet#start` and `BitcoinTestnet#stop`.
38
+ Cleaning the Testnet every time is slow. If you have VCR, you can make this a lot faster by calling `BitcoinTestnet.configure_with_rspec_and_vcr!` in your spec helper. With this, you won't need to call `BitcoinTestnet#start` and `BitcoinTestnet#stop`.
39
39
 
40
40
  ## Installation
41
41
 
@@ -0,0 +1,38 @@
1
+ module BitcoinTestnet
2
+ class VcrIntegrator
3
+
4
+ def self.start
5
+ self.new.start
6
+ end
7
+
8
+ def self.stop
9
+ self.new.stop
10
+ end
11
+
12
+ def start
13
+ BitcoinTestnet.start if should_perform?
14
+ end
15
+
16
+ def stop
17
+ BitcoinTestnet.stop if should_perform?
18
+ end
19
+
20
+ private
21
+
22
+ def should_perform?
23
+ cassette_exists? || allow_unused_http_interactions?
24
+ end
25
+
26
+ def cassette_exists?
27
+ VCR.current_cassette &&
28
+ VCR.current_cassette.file &&
29
+ File.exists?(VCR.current_cassette.file)
30
+ end
31
+
32
+ def allow_unused_http_interactions?
33
+ VCR.configuration.
34
+ default_cassette_options[:allow_unused_http_interactions]
35
+ end
36
+
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module BitcoinTestnet
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -6,6 +6,7 @@ require 'bitcoin_testnet/detector'
6
6
  require 'bitcoin_testnet/executor'
7
7
  require 'bitcoin_testnet/booter'
8
8
  require 'bitcoin_testnet/stopper'
9
+ require 'bitcoin_testnet/vcr_integrator'
9
10
 
10
11
  module BitcoinTestnet
11
12
 
@@ -22,19 +23,8 @@ module BitcoinTestnet
22
23
 
23
24
  def self.configure_with_rspec_and_vcr!
24
25
  RSpec.configure do |c|
25
- c.before(:each) do
26
- if VCR.current_cassette
27
- cassette_file = VCR.current_cassette.file
28
- BitcoinTestnet.start unless File.exists?(cassette_file)
29
- end
30
- end
31
-
32
- c.after(:each) do
33
- if VCR.current_cassette
34
- cassette_file = VCR.current_cassette.file
35
- BitcoinTestnet.stop unless File.exists?(cassette_file)
36
- end
37
- end
26
+ c.before(:each) { VcrIntegrator.start }
27
+ c.after(:each) { VcrIntegrator.stop }
38
28
  end
39
29
  end
40
30
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitcoin_testnet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -63,6 +63,7 @@ files:
63
63
  - lib/bitcoin_testnet/detector.rb
64
64
  - lib/bitcoin_testnet/executor.rb
65
65
  - lib/bitcoin_testnet/stopper.rb
66
+ - lib/bitcoin_testnet/vcr_integrator.rb
66
67
  - lib/bitcoin_testnet/version.rb
67
68
  - testnet/1/bitcoin.conf
68
69
  - testnet/1/testnet3/blk0001.dat