test/test_wallets.rb in zold-0.14.28 vs test/test_wallets.rb in zold-0.14.29

- old
+ new

@@ -19,10 +19,11 @@ # 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_relative 'fake_home' require_relative '../lib/zold/key' require_relative '../lib/zold/id' require_relative '../lib/zold/wallets' require_relative '../lib/zold/amount' @@ -34,30 +35,33 @@ class TestWallets < Minitest::Test def test_adds_wallet FakeHome.new.run do |home| wallets = home.wallets id = Zold::Id.new - wallet = wallets.find(id) - wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub')) - assert_equal(1, wallets.all.count) + wallets.find(id) do |wallet| + wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub')) + assert_equal(1, wallets.all.count) + end end end def test_lists_wallets_and_ignores_garbage FakeHome.new.run do |home| wallets = home.wallets FileUtils.touch(File.join(home.dir, '0xaaaaaaaaaaaaaaaaaaahello')) id = Zold::Id.new - wallet = wallets.find(id) - wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub')) - assert_equal(1, wallets.all.count) + wallets.find(id) do |wallet| + wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub')) + assert_equal(1, wallets.all.count) + end end end def test_substracts_dir_path_from_full_path - FakeHome.new.run do |home| - wallets = home.wallets - path = wallets.path - assert_equal('.', wallets.to_s(path)) + Dir.mktmpdir do |dir| + Dir.chdir(dir) do + wallets = Zold::Wallets.new(Dir.pwd) + assert_equal('.', wallets.to_s) + end end end end