Skip to content

Instantly share code, notes, and snippets.

@selmanj
Created November 15, 2016 18:52
Show Gist options
  • Save selmanj/8fe1a648143e5bc33316e36416ad1972 to your computer and use it in GitHub Desktop.
Save selmanj/8fe1a648143e5bc33316e36416ad1972 to your computer and use it in GitHub Desktop.
require 'minitest/autorun'
# My helper
class AddTestHelper
def self.add_crud_tests(x)
x.send(:define_method, :test_foobar) { puts 'testing foobar' }
end
end
# My test class
class TestMyClass < Minitest::Test
AddTestHelper.add_crud_tests(self)
def test_thing
assert_equal 'foo', 'foo'
end
end
# Output:
# ~/src/ruby-add-test-experiment $ ruby -Ilib:test test_my_class.rb
# Run options: --seed 41063
#
# # Running:
#
# testing foobar
# ..
#
# Finished in 0.000845s, 2367.2841 runs/s, 1183.6421 assertions/s.
#
# 2 runs, 1 assertions, 0 failures, 0 errors, 0 skips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment