I've created a "DatabaseCleaner" for Bitcoin Testnet in a Box. Basically, it stops, cleans, and restarts the Bitcoin daemons for every test. As you can imagine, this is slow. To speed it up, I can use VCR and only restart the daemons if no cassette exists. Is there something like this:
VCR.configure do |c|
c.before_recording_session do
# Restart and clean the Bitcoin Testnet here
end
c.after_recording_session do
# Stop and clean the Bitcoin Testnet here
end
end
If not, would it be a good addition? If it would be a good, I volunteer to add it. Myron, we had a discussion similar to this before. Thanks to your comments, I realized hooks would be a better place. Since cassettes can be recorded in another place other than the filesystem, what more generic method can I call to just get true/false to the question cassette_exists??
Thanks in advance!
I should have stepped through the code before asking. I could have answered one of my questions:
cassette_exists??It looks like there isn't such a method. And right now, there's no way to enforce that custom Persisters will apply this. I thought of two ways around this:
absolute_path_to_file. This isn't ideal, but it will get the job done for me.All persisters should inherit from a Persister class that has a method:
def cassette_exists?(name)
fail NotImplementedError, 'your persister must implement this method'
end