Project-wise refactoring to follow Ameba

This commit is contained in:
Alex Ling
2020-04-08 06:41:27 +00:00
parent d33cae7618
commit fcf9d39047
10 changed files with 108 additions and 121 deletions

View File

@@ -2,7 +2,7 @@ require "./spec_helper"
describe Config do
it "creates config if it does not exist" do
with_default_config do |config, logger, path|
with_default_config do |_, _, path|
File.exists?(path).should be_true
end
end

View File

@@ -4,7 +4,7 @@ include MangaDex
describe Queue do
it "creates DB at given path" do
with_queue do |queue, path|
with_queue do |_, path|
File.exists?(path).should be_true
end
end

View File

@@ -28,9 +28,9 @@ def get_tempfile(name)
if path.nil? || !File.exists? path
file = File.tempfile name
State.set name, file.path
return file
file
else
return File.new path
File.new path
end
end
@@ -43,7 +43,7 @@ def with_default_config
end
def with_storage
with_default_config do |config, logger|
with_default_config do |_, logger|
temp_db = get_tempfile "mango-test-db"
storage = Storage.new temp_db.path, logger
clear = yield storage, temp_db.path
@@ -54,7 +54,7 @@ def with_storage
end
def with_queue
with_default_config do |config, logger|
with_default_config do |_, logger|
temp_queue_db = get_tempfile "mango-test-queue-db"
queue = MangaDex::Queue.new temp_queue_db.path, logger
clear = yield queue, temp_queue_db.path

View File

@@ -2,7 +2,7 @@ require "./spec_helper"
describe Storage do
it "creates DB at given path" do
with_storage do |storage, path|
with_storage do |_, path|
File.exists?(path).should be_true
end
end