{"id":13878189,"url":"https://github.com/fnando/minitest-utils","last_synced_at":"2026-03-05T22:05:44.598Z","repository":{"id":31267915,"uuid":"34829677","full_name":"fnando/minitest-utils","owner":"fnando","description":"Some utilities for your Minitest day-to-day usage.","archived":false,"fork":false,"pushed_at":"2025-03-28T16:52:00.000Z","size":4657,"stargazers_count":52,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:04:30.445Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"MobClub/MobPush-for-Android","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["fnando"],"custom":["https://www.paypal.me/nandovieira/🍕"]}},"created_at":"2015-04-30T02:25:12.000Z","updated_at":"2025-03-28T16:52:03.000Z","dependencies_parsed_at":"2024-06-19T00:11:01.046Z","dependency_job_id":"9269045f-9659-4f55-b30f-1c39b02ab504","html_url":"https://github.com/fnando/minitest-utils","commit_stats":{"total_commits":74,"total_committers":5,"mean_commits":14.8,"dds":0.2567567567567568,"last_synced_commit":"577586aed1f5244a7acb0b24d3583dfb162a5a1a"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fminitest-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fminitest-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fminitest-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fminitest-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/minitest-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226213,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:42.267Z","updated_at":"2026-03-05T22:05:39.562Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","funding_links":["https://github.com/sponsors/fnando","https://www.paypal.me/nandovieira/🍕"],"categories":["Ruby","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# Minitest::Utils\n\nSome utilities for your Minitest day-to-day usage.\n\nIncludes:\n\n- A better reporter (see screenshot below)\n- A [TestNotifier](http://github.com/fnando/test_notifier) reporter\n- Some Rails niceties (set up FactoryBot, WebMock and Capybara)\n- Add a `t` and `l` methods (i18n)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'minitest-utils'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install minitest-utils\n\n## Defining tests\n\nThis gem adds the `Minitest::Test.test` method, so you can easy define your\nmethods like the following:\n\n```ruby\nclass SampleTest \u003c Minitest::Test\n  test \"useless test\" do\n    assert true\n  end\nend\n```\n\nThis is equivalent to defining a method named `test_useless_test`. You can also\nskip the block, which will define a\n[flunk](https://github.com/seattlerb/minitest/blob/77120c5b2511c4665610cda06c8058c801b28e7f/lib/minitest/assertions.rb#L477-L480)\ncall.\n\nYou can also define `setup` and `teardown` steps.\n\n```ruby\nclass SampleTest \u003c Minitest::Test\n  setup do\n    DB.connect\n  end\n\n  teardown do\n    DB.disconnect\n  end\n\n  test \"useless test\" do\n    assert true\n  end\nend\n```\n\nIf you want to skip slow tests, you can use the `slow_test` method, which only\nruns the test when `MT_RUN_SLOW_TESTS` environment variable is set.\n\n```ruby\n# Only run slow tests in CI. You can bypass it locally by using\n# something like `MT_RUN_SLOW_TESTS=1 rake`.\nENV[\"MT_RUN_SLOW_TESTS\"] ||= ENV[\"CI\"]\n\nclass SampleTest \u003c Minitest::Test\n  test \"useless test\" do\n    slow_test\n    sleep 1\n    assert true\n  end\nend\n```\n\nYou can change the default threshold by setting `Minitest::Test.slow_threshold`.\nThe default value is `0.1` (100ms).\n\n```ruby\nMinitest::Test.slow_threshold = 0.1\n```\n\nThis config can also be changed per class:\n\n```ruby\nclass SampleTest \u003c Minitest::Test\n  self.slow_threshold = 0.1\n\n  test \"useless test\" do\n    slow_test\n    sleep 1\n    assert true\n  end\nend\n```\n\nFinally, you can also use `let`.\n\n```ruby\nclass SampleTest \u003c Minitest::Test\n  let(:token) { \"secret\" }\n\n  test \"set token\" do\n    assert_equal \"secret\", token\n  end\nend\n```\n\n## Running tests\n\n`minitest-utils` comes with a runner: `mt` or `minitest`.\n\n\u003e [!WARNING]\n\u003e\n\u003e When using this test runner, you must change your test helper and replace\n\u003e `require \"minitest/autorun\"` with\n\u003e `require \"minitest/autorun\" unless ENV[\"MT_RUNNER\"]`. This way you can use\n\u003e both the runner and rake.\n\nYou can run specific files by using `file:number`.\n\n```console\n$ mt test/models/user_test.rb:42\n```\n\nYou can also run files by the test name (caveat: you need to underscore the\nname):\n\n```console\n$ mt test/models/user_test.rb --name /validations/\n```\n\nYou can also run specific directories:\n\n```console\n$ mt test/models\n```\n\nTo exclude tests by name, use --exclude:\n\n```console\n$ mt test/models --exclude /validations/\n```\n\nIt supports `.minitestignore`, which only matches file names partially. Comments\nstarting with `#` are ignored.\n\n```\n# Ignore all tests in test/fixtures\ntest/fixtures\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e This command is also available as the long form `minitest`, for linux users.\n\u003e Linux has a `mt` command for managing magnetic tapes.\n\n## Screenshots\n\n![](https://raw.githubusercontent.com/fnando/minitest-utils/main/screenshots/detect-slow-tests.png)\n![](https://raw.githubusercontent.com/fnando/minitest-utils/main/screenshots/replay-command.png)\n![](https://raw.githubusercontent.com/fnando/minitest-utils/main/screenshots/slow-tests.png)\n\n## Rails extensions\n\nminitest-utils sets up some things for your Rails application.\n\n- [Capybara](https://github.com/jnicklas/capybara): includes `Capybara::DSL`,\n  sets default driver before every test, resets session and creates a helper\n  method for setting JavaScript driver. If you have\n  [poltergeist](https://github.com/teampoltergeist/poltergeist) installed, it\n  will be used as the default JavaScript driver.\n- [FactoryBot](https://github.com/thoughtbot/factory_bot): adds methods to\n  `ActiveSupport::TestCase`.\n- [WebMock](https://github.com/bblimke/webmock): disables external requests\n  (except for codeclimate) and tracks all requests on `WebMock.requests`.\n- locale routes: sets `Rails.application.routes.default_url_options[:locale]`\n  with your current locale.\n- [DatabaseCleaner](https://github.com/DatabaseCleaner/database_cleaner):\n  configure database before running each test. You can configure the strategy by\n  settings `DatabaseCleaner.strategy = :truncation`, for instance. It defaults\n  to `:deletion`.\n- Other: `t` and `l` alias to I18n.\n\n```ruby\nclass SignupTest \u003c ActionDispatch::IntegrationTtest\n  use_javascript! #=\u003e enables JavaScript driver\nend\n```\n\nAlso, if you're using routes like `:locale` scope, you can load this file to\nautomatically set your route's `:locale` param.\n\n```ruby\nrequire 'minitest/utils/rails/locale'\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run\n`bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release` to create a git tag for the version, push git commits\nand tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\n1. Fork it ( https://github.com/fnando/minitest-utils/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fminitest-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Fminitest-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fminitest-utils/lists"}