Because there are no existing test frameworks for Rubyβ’
This is just a toy project. Don't take it seriously.
I'm not pushing this to RubyGems.org because it's a toy personal project and it would be poor form to junk up RubyGems.
So, reference this Github repo directly from your Gemfile and do the usual $ bundle install dance.
gem "tinytest", github: "booty/tinytest"Alternatively, if you're not using Bundler you can use the specific_install gem to install TinyTest straight from Github. Neat.
gem install specific_install
gem specific_install booty/tinytest
Define some tests in myfile.rb:
require "tinytest"
class DoSomeTests
include TinyTest
# Have multiple test per method. Sure, why not.
def test_something
assert_equal(
"olleH", # expected result
"Hello".reverse, # actual result
"value set correctly" # label for your test
)
assert(
(42.to_s == "42"), # a thing that should be true
"conversion works" # label for your test
)
end
# Method names will be used as headers/separators
# in the output
def test_something_else
assert(
(1 == 2), # a thing that should be true
"this will fail" # label for your test
)
end
endRun: (if not using Bundler)
ruby myfile.rbRun: (if using Bundler)
bundle exec ruby myfile.rbSample output:
----[ test_something ]----
π value set correctly
π conversion works
----[ test_something_else ]----
π« this will fail
----[ RESULTS ]----
π passed:2 failed:1
I mean, okay.