Skip to content

test: migrate the suite from RSpec to Minitest - #3

Merged
Halvanhelv merged 1 commit into
mainfrom
test/migrate-to-minitest
Sep 7, 2026
Merged

Halvanhelv merged 1 commit into
mainfrom
test/migrate-to-minitest

Conversation

@Halvanhelv

Copy link
Copy Markdown
Owner

Summary

Ports all six spec files to Minitest::Test with plain assertions, and drops the RSpec dependency.

What changed

  • Style. Minitest::Test + assert_equal / refute_nil / assert_raises, no spec DSL. The context blocks that shared one it_behaves_like example are now tables driven through define_method, so every case still reports under its own name (test_tokenizes_a_notranslate_span_inside_another_span, …) rather than collapsing into a loop with one opaque failure.
  • Doubles → fakes. The request test's RSpec doubles are replaced by two small classes. FakeApi records what it was asked to translate, so the test asserts on the call itself (assert_equal [[%w[One Two], :en, :ru, {}]], api.calls) instead of hiding the expectation inside a stub's argument matcher. FakeCacheStore always misses, which is what the specs did — cache_response was declared but never overridden.
  • Plumbing. rspecminitest ~> 6.0 in the gemspec, RSpec::Core::RakeTaskRake::TestTask, both workflows run bundle exec rake test. .rspec, spec/ and the .rspec_status ignore rule are gone.
  • Warnings. The test task sets t.warning = false. Rake::TestTask turns on -w by default, and unicode_utils and punkt-segmenter emit enough warnings to bury anything of ours.

Notes

  • Coverage is unchanged: 267/282 lines, same 28 cases.
  • spacing_spec.rb had a vestigial 4th element in each of its data rows that the destructuring ignored; the two cases are now written out explicitly.
  • No new coverage was added — this is a port, not a test-writing pass. The cache-hit path is still untested, same as before.

Test plan

  • bundle exec rake test — 28 runs, 34 assertions, 0 failures, on both Ruby 4.0.5 and 3.2.4.
  • bundle exec rubocop — 0 offenses.
  • Sanity-checked that the assertions bite: breaking Spacing.restore to drop the padding turns 3 tests red, and they go green again when it is restored.

https://claude.ai/code/session_01Pda49PcgziFVnibkKKjXRE

Port all six spec files to Minitest::Test with plain assertions. The
cases that were `context` blocks sharing one example are now tables
driven through define_method, so each case still reports under its own
name.

Replace the RSpec doubles in the request test with two small fakes.
FakeApi records what it was asked to translate, which lets the test
assert on the API call directly instead of encoding the expectation in
a stub. FakeCacheStore always misses, matching what the specs did.

Swap the rspec development dependency for minitest, replace the RSpec
rake task with Rake::TestTask, and point both workflows at
`rake test`. Warnings are off in the test task because the
dependencies are noisy under -w and drown out our own.

Coverage is unchanged at 267/282 lines, and the suite still runs 28
cases on Ruby 3.2 through 4.0.
@Halvanhelv
Halvanhelv merged commit c82eb7a into main Sep 7, 2026
5 checks passed
@Halvanhelv
Halvanhelv deleted the test/migrate-to-minitest branch September 7, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant