Sha256: 120843d13b6a3835ca7406ca31f61e518fdea7c3a44718d7591b21ff25bf9828

Contents?: true

Size: 1.38 KB

Versions: 16

Compression:

Stored size: 1.38 KB

Contents

require "capybara/cuprite"
require "capybara/rspec"
require "database_cleaner/sequel"
require "rack/test"
require "spec_helper"

ENV["HANAMI_ENV"] = "test"

require "hanami/prepare"
require_relative "support/database"
require_relative "support/factory"

using Refinements::Pathname

Capybara.app = Hanami.app
Capybara.server = :puma, {Silent: true, Threads: "0:1"}
Capybara.javascript_driver = :cuprite
Capybara.save_path = Hanami.app.root.join "tmp/capybara"
Capybara.register_driver :cuprite do |app|
  browser_options = {"disable-gpu" => nil, "disable-dev-shm-usage" => nil, "no-sandbox" => nil}
  Capybara::Cuprite::Driver.new app, browser_options:, window_size: [1920, 1080]
end

DatabaseCleaner[:sequel].strategy = :transaction

Pathname.require_tree SPEC_ROOT.join("support/factories")

RSpec.configure do |config|
  config.include Capybara::DSL, Capybara::RSpecMatchers, :web
  config.include Rack::Test::Methods, type: :request
  config.include Test::Database, :db
  config.include_context "with Hanami application", type: :request

  config.before :suite do
    Hanami.app.start :persistence
    DatabaseCleaner[:sequel].clean_with :truncation
  end

  config.prepend_before :each, :db do |example|
    DatabaseCleaner[:sequel].strategy = example.metadata[:js] ? :truncation : :transaction
    DatabaseCleaner[:sequel].start
  end

  config.append_after(:each, :db) { DatabaseCleaner[:sequel].clean }
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hanamismith-0.41.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.40.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.39.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.38.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.37.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.34.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.33.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.32.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.31.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.30.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.29.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.28.1 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.28.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.27.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.26.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb
hanamismith-0.25.0 lib/hanamismith/templates/%project_name%/spec/hanami_helper.rb.erb