Sha256: afa80b7f1d2948af5f43118739ed9223ee8381e9cc8f7dbd5b9d3e46d337371e
Contents?: true
Size: 1.89 KB
Versions: 46
Compression:
Stored size: 1.89 KB
Contents
# frozen_string_literal: true require 'minitest/autorun' require_relative '../test__helper' require_relative '../fake_home' require_relative '../../lib/zold/commands/alias' class TestAlias < Minitest::Test # alias set <wallet> <alias> # @todo #322:30min Implement the set command and unskip this test. # The syntax is already documented in the alias command in the help. def test_set_writes_alias_to_the_alias_file skip FakeHome.new.run do |home| wallet = home.create_wallet Zold::Alias.new(wallets: home.wallets, log: test_log).run(%W[set #{wallet.id} my-alias]) assert_equal read_alias_file(home), %W[my-alias #{wallet.id}] end end # alias remove <alias> # @todo #322:30min Implement the remove command and unskip this test. # The syntax is already documented in the alias command in the help. def test_remove_removes_the_alias_from_the_alias_file skip FakeHome.new.run do |home| wallet = home.create_wallet cmd = Zold::Alias.new(wallets: home.wallets, log: test_log) cmd.run(%W[set #{wallet.id} my-alias]) assert_equal read_alias_file(home), %W[my-alias #{wallet.id}] cmd.run(%w[remove my-alias]) assert_empty read_alias_file(home) end end # alias show <alias> # @todo #322:30min Implement the show command and unskip this test. # The syntax is already documented in the alias command in the help. def test_show_prints_out_the_aliased_wallet_id skip FakeHome.new.run do |home| wallet = home.create_wallet cmd = Zold::Alias.new(wallets: home.wallets, log: test_log) cmd.run(%W[set #{wallet.id} my-alias]) assert_equal read_alias_file(home), %W[my-alias #{wallet.id}] stdout, = capture_io { cmd.run(%w[show my-alias]) } assert_match wallet.id.to_s, stdout end end private def read_alias_file(home) File.read(File.join(home.dir, 'aliases')).split(' ') end end
Version data entries
46 entries across 46 versions & 1 rubygems