Initial commit

This commit is contained in:
2023-01-27 22:55:09 +11:00
commit 833f3ea8b2
130 changed files with 5637 additions and 0 deletions

15
spec/support/db.rb Normal file
View File

@@ -0,0 +1,15 @@
# require_with_metadata: true
# frozen_string_literal: true
require_relative "db/helpers"
require_relative "db/database_cleaner"
RSpec.configure do |config|
config.before :suite do
Hanami.app.start :persistence
end
config.include Test::DB::Helpers, :db
# config.include(Test::DB::FactoryHelper.new, factory: nil)
end

View File

@@ -0,0 +1,18 @@
require "sequel"
require "database_cleaner/sequel"
require_relative "helpers"
DatabaseCleaner[:sequel].strategy = :transaction
RSpec.configure do |config|
config.prepend_before :each, type: :db do |example|
strategy = example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner[:sequel].strategy = strategy
DatabaseCleaner[:sequel].start
end
config.append_after :each, type: :db do
DatabaseCleaner[:sequel].clean
end
end

View File

@@ -0,0 +1,19 @@
module Test
module DB
module Helpers
module_function
def relations
rom.relations
end
def rom
Hanami.app["persistence.rom"]
end
def db
Hanami.app["persistence.db"]
end
end
end
end

12
spec/support/requests.rb Normal file
View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
require "rack/test"
RSpec.shared_context "Hanami app" do
let(:app) { Hanami.app }
end
RSpec.configure do |config|
config.include Rack::Test::Methods, type: :request
config.include_context "Hanami app", type: :request
end

27
spec/support/rspec.rb Normal file
View File

@@ -0,0 +1,27 @@
# frozen_string_literal: true
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
config.filter_run_when_matching :focus
config.disable_monkey_patching!
config.warnings = true
if config.files_to_run.one?
config.default_formatter = "doc"
end
config.profile_examples = 10
config.order = :random
Kernel.srand config.seed
end