It's bad when code to support your testing has bugs that give an unearned green bar when you invoke them with a typo.
Such is the case with the current MiniTest::Assertions::AssertRequiresInitializeParameterasserter class which we use to verify that a class requires specific named parameters to its #initialise method.
Given a class
class Foo
def initialise(foo:, bar:)
# ...
end
# ...
end
we can write a MiniTest::Spec assertion such as
# ...
let(:params) { { foo: foo, bar: bar } }
# ...
it 'requires a :bar parameter for initialisation' do
expect(Foo).must_require_initialize_parameter params, :bar
end
and get a legitimate green bar.
Writing the test with a typo, such as
# ...
let(:params) { { foo: foo, bar: bar } }
# ...
it 'requires a :bar parameter for initialisation' do
expect(Foo).must_require_initialize_parameter params, :bear
end
will give an illegitimate green bar; the asserter deletes the entry specified by the second parameter from (a copy of) the Hash specified by the first, and attempts to instantiate the class with the result. In the code as of Commit 376ca33, deleting the nonexistent key silently has no effect, and the instantiation, receiving valid parameters, succeeds.
The implementation extracted to the new prolog_minitest_matchers Gem solves this (and therefore conflicts with the current implementation in this Gem). The prolog-use_cases implementation should be removed and the prolog_minitest_matchers Gem added as a development dependency instead.
It's bad when code to support your testing has bugs that give an unearned green bar when you invoke them with a typo.
Such is the case with the current
MiniTest::Assertions::AssertRequiresInitializeParameter
asserter class which we use to verify that a class requires specific named parameters to its#initialise
method.Given a class
we can write a MiniTest::Spec assertion such as
and get a legitimate green bar.
Writing the test with a typo, such as
will give an illegitimate green bar; the asserter deletes the entry specified by the second parameter from (a copy of) the Hash specified by the first, and attempts to instantiate the class with the result. In the code as of Commit 376ca33, deleting the nonexistent key silently has no effect, and the instantiation, receiving valid parameters, succeeds.
The implementation extracted to the new
prolog_minitest_matchers
Gem solves this (and therefore conflicts with the current implementation in this Gem). Theprolog-use_cases
implementation should be removed and theprolog_minitest_matchers
Gem added as a development dependency instead.