test: migrate the suite from RSpec to Minitest - #3
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports all six spec files to
Minitest::Testwith plain assertions, and drops the RSpec dependency.What changed
Minitest::Test+assert_equal/refute_nil/assert_raises, no spec DSL. Thecontextblocks that shared oneit_behaves_likeexample are now tables driven throughdefine_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.FakeApirecords 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.FakeCacheStorealways misses, which is what the specs did —cache_responsewas declared but never overridden.rspec→minitest ~> 6.0in the gemspec,RSpec::Core::RakeTask→Rake::TestTask, both workflows runbundle exec rake test..rspec,spec/and the.rspec_statusignore rule are gone.t.warning = false.Rake::TestTaskturns on-wby default, andunicode_utilsandpunkt-segmenteremit enough warnings to bury anything of ours.Notes
spacing_spec.rbhad a vestigial 4th element in each of its data rows that the destructuring ignored; the two cases are now written out explicitly.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.Spacing.restoreto drop the padding turns 3 tests red, and they go green again when it is restored.https://claude.ai/code/session_01Pda49PcgziFVnibkKKjXRE