test/commands/test_push.rb in zold-0.9.5 vs test/commands/test_push.rb in zold-0.9.6
- old
+ new
@@ -17,14 +17,12 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'minitest/autorun'
-require 'tmpdir'
-require 'json'
-require 'time'
require 'webmock/minitest'
+require_relative '../fake_home'
require_relative '../test__helper'
require_relative '../../lib/zold/wallet'
require_relative '../../lib/zold/wallets'
require_relative '../../lib/zold/remotes'
require_relative '../../lib/zold/id'
@@ -35,19 +33,14 @@
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
class TestPush < Minitest::Test
def test_pushes_wallet
- Dir.mktmpdir 'test' do |dir|
- id = Zold::Id.new
- wallets = Zold::Wallets.new(dir)
- wallet = wallets.find(id)
- wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
- remotes = Zold::Remotes.new(File.join(dir, 'remotes.csv'))
- remotes.clean
- stub_request(:put, "http://fake-1/wallet/#{id}").to_return(status: 304)
- Zold::Push.new(wallets: wallets, remotes: remotes, log: $log).run(
- ['--ignore-this-stupid-option', 'push', id.to_s]
+ FakeHome.new.run do |home|
+ wallet = home.create_wallet
+ stub_request(:put, "http://fake-1/wallet/#{wallet.id}").to_return(status: 304)
+ Zold::Push.new(wallets: home.wallets, remotes: home.remotes, log: $log).run(
+ ['--ignore-this-stupid-option', 'push', wallet.id.to_s]
)
end
end
end