I am suggesting chaning minitest structure on the ruby track to fit the spec style of minitest. I think this would improve overall readability of the test files. Also would allow us to be able to not use the skip tag and instead use it/pending, which would I think could improve tdd
Here is a compersion of the change (we could use the spec style of comperring if there is interest but I am more interested in describe/it/pending etc):
new syntax:
require "minitest/autorun"
describe Meme do
it "kitty can eat" do
assert_equal "OHAI!", Meme.i_can_has_cheezburger?
end
it "it will not blend" do
refute_match /^no/i, Meme.will_it_blend?
end
pending "will_be_skipped" do
# test this later
end
end
current syntax:
require "minitest/autorun"
class TestMeme < Minitest::Test
def test_that_kitty_can_eat
assert_equal "OHAI!", Meme.i_can_has_cheezburger?
end
def test_that_it_will_not_blend
refute_match /^no/i, Meme.will_it_blend?
end
def test_that_will_be_skipped
skip "test this later"
end
end
With this system do I believe the learning experience for learning Ruby could improve and this change wont require any new dependencies.
However, when we are also changing the test system (if we are), I think exploring bringing the test runner (finally) to v3 could be possible. Either by using describe groups as a way to get task id or by implementing our own libraries to add custom tags to minitest or to switch fully to Rspec (both of the later would require dependency, but the former one would only require it on concept exercise).
I think the testing system on the Ruby track would really need some more love so I think some changes could really benefit the learning experience. But I also think this is such a large change that the opinions and ideas from the rest of the Exercism community has to be heard.
I have used the MinitestSpec format in example blocks for students while mentoring to add tests, and there is almost no difference between using the Spec and Test syntax.
What is the benefit in learning that you are seeing?
There is a customization that I believe Jeremy brought in (probably related to debug) for the platform, and at some point I changed how I did “additional tests in a test guard” section at the bottom of some exercises (not delivered, but pasted by the student if they chose to keep that portion of the note in their iterations).
Unsure if this is still something that can be done, but this is what I used to do:
# Determine if a word or phrase is an isogram.
class Isogram
# Student design of the solution
end
if defined?(Minitest)
require 'minitest/reporters'
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
describe 'Custom Test for Numeric Isogram' do
it 'must report "4321871" as not an isogram' do
_(Isogram.isogram?('4321871')).must_equal false
end
it 'must report "432871" as not an isogram' do
_(Isogram.isogram?('432871')).must_equal true
end
end
end
This would allow us to talk about additional tests and the more if we were talking about the testing mechanisms for Minitest, and the platform did not (used to) get in the way of that, with this guard. Indeed, if they ran the tests locally or remotely the reporting would happen.
At some point, this broke, and I had other workarounds for the student code so we could expand on what is there and explore things.
If you would like me to research how this type of additional testing has changed over the decade, let me know. I very likely have the history and knowledge still stored.
They are (on the platform) ran in a specific order already and so the only thing we have not yet done is group them.
The skip tag is a method call. And we can remove those trivially, but they are there for the practice tests due to. They are not used for the concept exercises.
As an example, this is how we can intermix the syntax using TwoFer:
describe TwoFer do
describe 'No names given' do
it 'no_name_given' do
# skip
_(TwoFer.two_fer).must_equal 'One for you, one for me.'
end
describe 'Use names as given' do
it 'must use the name given when it is Alice' do
skip
_(TwoFer.two_fer('Alice')).must_equal 'One for Alice, one for me.'
end
it 'works with the rspec style assertions as well' do
skip
assert_equal 'One for you, one for me.', TwoFer.two_fer
end
def test_another_name_given
# skip
_(TwoFer.two_fer('Bob')).must_equal 'One for Bob, one for me.'
end
end
end
end
Or we can do this:
require 'minitest/autorun'
require_relative 'two_fer'
# Common test data version: 1.2.0 4fc1acb
class TwoFerTest < Minitest::Test
describe 'First group of test(s)' do
def test_no_name_given
# skip
assert_equal 'One for you, one for me.', TwoFer.two_fer
end
end
describe 'Second group of test(s)' do
def test_a_name_given
skip
assert_equal 'One for Alice, one for me.', TwoFer.two_fer('Alice')
end
def test_another_name_given
skip
assert_equal 'One for Bob, one for me.', TwoFer.two_fer('Bob')
end
end
end