Hanami 3 finally supports using Minitest!
e.g,
hanami new my_app --test=minitest
But how do you actually run those tests?
There’s no hanami test command, though it’s been discussed as a possible feature.
simple fix
Here’s a simple fix - create a local bin/test with the following content:
#!/usr/bin/env ruby
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "rubygems"
require "bundler/setup"
ENV["HANAMI_ENV"] ||= "test"
require "hanami/setup"
require "hanami/prepare"
$LOAD_PATH << Hanami.app.root.join("test")
paths = ARGV
.reject { it.start_with?("-") }
.map do |path|
if Dir.exist?(path)
Dir.glob(File.join(path, "**/*_test.rb"))
elsif File.exist?(path)
path
else
raise "missing ``"
end
end.flatten
paths = Hanami.app.root.glob("test/**/*_test.rb") if paths.empty?
paths.each do |file|
Kernel.load file
end
require "minitest/autorun"
Then you can run tests like so:
bin/test
bin/test path/to/some_test.rb
bin/test test/features
Options work as expected:
bin/test -h
bin/test --pride --seed=42 -v test/features