diff --git a/.rubocop.yml b/.rubocop.yml index 8685f88..ce1de33 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,6 @@ AllCops: Exclude: - db/**/* - config/**/* - - test/* - Vagrantfile TargetRubyVersion: 2.3 diff --git a/test/test_config.rb b/test/test_config.rb index 49af82c..8ad7369 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -20,17 +20,18 @@ class TestConfig < Test::Unit::TestCase end def test_00_config - data = { gpg_key: 'test@example.com', - lang: 'en', - wallet_dir: '/tmp/test', - gpg_exe: '', - } + data = { + gpg_key: 'test@example.com', + lang: 'en', + wallet_dir: '/tmp/test', + gpg_exe: '' + } @config = MPW::Config.new @config.setup(data) @config.load_config - data.each do |k,v| + data.each do |k, v| assert_equal(v, @config.send(k)) end @@ -39,11 +40,12 @@ class TestConfig < Test::Unit::TestCase end def test_01_password - data = { pwd_alpha: false, - pwd_numeric: false, - pwd_special: true, - pwd_length: 32, - } + data = { + pwd_alpha: false, + pwd_numeric: false, + pwd_special: true, + pwd_length: 32 + } @config = MPW::Config.new @config.load_config diff --git a/test/test_item.rb b/test/test_item.rb index 751e1b0..961834e 100644 --- a/test/test_item.rb +++ b/test/test_item.rb @@ -16,22 +16,22 @@ class TestItem < Test::Unit::TestCase I18n.load_path = Dir['./i18n/cli/*.yml'] I18n.default_locale = :en - puts end def test_00_add_without_name - assert_raise(RuntimeError){MPW::Item.new} + assert_raise(RuntimeError) { MPW::Item.new } end def test_01_add_new - data = { group: @fixtures['add_new']['group'], - host: @fixtures['add_new']['host'], - protocol: @fixtures['add_new']['protocol'], - user: @fixtures['add_new']['user'], - port: @fixtures['add_new']['port'], - comment: @fixtures['add_new']['comment'], - } + data = { + group: @fixtures['add_new']['group'], + host: @fixtures['add_new']['host'], + protocol: @fixtures['add_new']['protocol'], + user: @fixtures['add_new']['user'], + port: @fixtures['add_new']['port'], + comment: @fixtures['add_new']['comment'] + } item = MPW::Item.new(data) @@ -47,15 +47,16 @@ class TestItem < Test::Unit::TestCase end def test_02_add_existing - data = { id: @fixtures['add_existing']['id'], - group: @fixtures['add_existing']['group'], - host: @fixtures['add_existing']['host'], - protocol: @fixtures['add_existing']['protocol'], - user: @fixtures['add_existing']['user'], - port: @fixtures['add_existing']['port'], - comment: @fixtures['add_existing']['comment'], - created: @fixtures['add_existing']['created'], - } + data = { + id: @fixtures['add_existing']['id'], + group: @fixtures['add_existing']['group'], + host: @fixtures['add_existing']['host'], + protocol: @fixtures['add_existing']['protocol'], + user: @fixtures['add_existing']['user'], + port: @fixtures['add_existing']['port'], + comment: @fixtures['add_existing']['comment'], + created: @fixtures['add_existing']['created'] + } item = MPW::Item.new(data) @@ -73,13 +74,14 @@ class TestItem < Test::Unit::TestCase end def test_03_update - data = { group: @fixtures['add_new']['group'], - host: @fixtures['add_new']['host'], - protocol: @fixtures['add_new']['protocol'], - user: @fixtures['add_new']['user'], - port: @fixtures['add_new']['port'], - comment: @fixtures['add_new']['comment'], - } + data = { + group: @fixtures['add_new']['group'], + host: @fixtures['add_new']['host'], + protocol: @fixtures['add_new']['protocol'], + user: @fixtures['add_new']['user'], + port: @fixtures['add_new']['port'], + comment: @fixtures['add_new']['comment'] + } item = MPW::Item.new(data) @@ -89,13 +91,14 @@ class TestItem < Test::Unit::TestCase created = item.created last_edit = item.last_edit - data = { group: @fixtures['update']['group'], - host: @fixtures['update']['host'], - protocol: @fixtures['update']['protocol'], - user: @fixtures['update']['user'], - port: @fixtures['update']['port'], - comment: @fixtures['update']['comment'], - } + data = { + group: @fixtures['update']['group'], + host: @fixtures['update']['host'], + protocol: @fixtures['update']['protocol'], + user: @fixtures['update']['user'], + port: @fixtures['update']['port'], + comment: @fixtures['update']['comment'] + } sleep(1) assert(item.update(data)) @@ -114,13 +117,14 @@ class TestItem < Test::Unit::TestCase end def test_05_update_one_element - data = { group: @fixtures['add_new']['group'], - host: @fixtures['add_new']['host'], - protocol: @fixtures['add_new']['protocol'], - user: @fixtures['add_new']['user'], - port: @fixtures['add_new']['port'], - comment: @fixtures['add_new']['comment'], - } + data = { + group: @fixtures['add_new']['group'], + host: @fixtures['add_new']['host'], + protocol: @fixtures['add_new']['protocol'], + user: @fixtures['add_new']['user'], + port: @fixtures['add_new']['port'], + comment: @fixtures['add_new']['comment'] + } item = MPW::Item.new(data) @@ -130,7 +134,7 @@ class TestItem < Test::Unit::TestCase last_edit = item.last_edit sleep(1) - assert(item.update({comment: @fixtures['update']['comment']})) + assert(item.update(comment: @fixtures['update']['comment'])) assert_equal(@fixtures['add_new']['group'], item.group) assert_equal(@fixtures['add_new']['host'], item.host) @@ -143,13 +147,14 @@ class TestItem < Test::Unit::TestCase end def test_05_delete - data = { group: @fixtures['add_new']['group'], - host: @fixtures['add_new']['host'], - protocol: @fixtures['add_new']['protocol'], - user: @fixtures['add_new']['user'], - port: @fixtures['add_new']['port'], - comment: @fixtures['add_new']['comment'], - } + data = { + group: @fixtures['add_new']['group'], + host: @fixtures['add_new']['host'], + protocol: @fixtures['add_new']['protocol'], + user: @fixtures['add_new']['user'], + port: @fixtures['add_new']['port'], + comment: @fixtures['add_new']['comment'] + } item = MPW::Item.new(data) diff --git a/test/test_mpw.rb b/test/test_mpw.rb index 30c9028..dd005ca 100644 --- a/test/test_mpw.rb +++ b/test/test_mpw.rb @@ -33,13 +33,14 @@ class TestMPW < Test::Unit::TestCase end def test_02_add_item - data = { group: @fixtures['add_new']['group'], - host: @fixtures['add_new']['host'], - protocol: @fixtures['add_new']['protocol'], - user: @fixtures['add_new']['user'], - port: @fixtures['add_new']['port'], - comment: @fixtures['add_new']['comment'], - } + data = { + group: @fixtures['add_new']['group'], + host: @fixtures['add_new']['host'], + protocol: @fixtures['add_new']['protocol'], + user: @fixtures['add_new']['user'], + port: @fixtures['add_new']['port'], + comment: @fixtures['add_new']['comment'] + } item = MPW::Item.new(data) @@ -53,7 +54,7 @@ class TestMPW < Test::Unit::TestCase assert_equal(1, @mpw.list.length) item = @mpw.list[0] - @fixtures['add_new'].each do |k,v| + @fixtures['add_new'].each do |k, v| if k == 'password' assert_equal(v, @mpw.get_password(item.id)) else @@ -69,7 +70,7 @@ class TestMPW < Test::Unit::TestCase assert_equal(1, @mpw.list.length) item = @mpw.list[0] - @fixtures['add_new'].each do |k,v| + @fixtures['add_new'].each do |k, v| if k == 'password' assert_equal(v, @mpw.get_password(item.id)) else @@ -80,13 +81,9 @@ class TestMPW < Test::Unit::TestCase def test_04_delete_item @mpw.read_data - assert_equal(1, @mpw.list.length) - @mpw.list.each do |item| - item.delete - end - + @mpw.list.each(&:delete) assert_equal(0, @mpw.list.length) @mpw.write_data @@ -96,13 +93,14 @@ class TestMPW < Test::Unit::TestCase @mpw.read_data @fixtures.each_value do |v| - data = { group: v['group'], - host: v['host'], - protocol: v['protocol'], - user: v['user'], - port: v['port'], - comment: v['comment'], - } + data = { + group: v['group'], + host: v['host'], + protocol: v['protocol'], + user: v['user'], + port: v['port'], + comment: v['comment'] + } item = MPW::Item.new(data) diff --git a/test/test_translate.rb b/test/test_translate.rb index 6334a78..d4bb002 100644 --- a/test/test_translate.rb +++ b/test/test_translate.rb @@ -11,7 +11,7 @@ class TestTranslate < Test::Unit::TestCase lang = File.basename(yaml, '.yml') translate = YAML.load_file(yaml) - `grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2`.each_line do |line| + %x(grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2).each_line do |line| begin t = translate[lang] line.strip.split('.').each do |v|