Skip to content

Instantly share code, notes, and snippets.

@jahio
Last active December 27, 2015 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahio/7240249 to your computer and use it in GitHub Desktop.
Save jahio/7240249 to your computer and use it in GitHub Desktop.
ruby test inside script
require "test/unit"
class SomeClass
end
if $0 == __FILE__
class SomeClassTestUnit < Test::Unit::TestCase
def test_something
# does something here
end
end
end
@mattscilipoti
Copy link

Yes. THen you would run `ruby gistfile1.rb'

@mattscilipoti
Copy link

class MyClass
  def speak
    "bark"
  end
end

if $0 == __FILE__
  require "test/unit"
  class MyTestUnit < Test::Unit::TestCase
    # test MyClass here
    def test_speak
      assert_equal 'bark', MyClass.new.speak
    end
  end

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment