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

Version Path
zold-0.15.0 test/commands/test_alias.rb
zold-0.14.53 test/commands/test_alias.rb
zold-0.14.52 test/commands/test_alias.rb
zold-0.14.51 test/commands/test_alias.rb
zold-0.14.50 test/commands/test_alias.rb
zold-0.14.49 test/commands/test_alias.rb
zold-0.14.48 test/commands/test_alias.rb
zold-0.14.47 test/commands/test_alias.rb
zold-0.14.46 test/commands/test_alias.rb
zold-0.14.45 test/commands/test_alias.rb
zold-0.14.44 test/commands/test_alias.rb
zold-0.14.43 test/commands/test_alias.rb
zold-0.14.42 test/commands/test_alias.rb
zold-0.14.41 test/commands/test_alias.rb
zold-0.14.40 test/commands/test_alias.rb
zold-0.14.39 test/commands/test_alias.rb
zold-0.14.38 test/commands/test_alias.rb
zold-0.14.37 test/commands/test_alias.rb
zold-0.14.36 test/commands/test_alias.rb
zold-0.14.35 test/commands/test_alias.rb