Created
November 21, 2012 18:37
-
-
Save lazyatom/4126745 to your computer and use it in GitHub Desktop.
An example of using kintama to run tests while some things are being defined
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__) | |
ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = "true" | |
at_exit { $reporter.show_final_results } | |
require 'kintama' | |
$contexts = [] | |
class TomReporter < Kintama::Reporter::Inline | |
def show_final_results | |
puts | |
puts test_summary | |
puts "\n" + failure_messages.join("\n\n") if runner.failures.any? | |
end | |
def show_results | |
# noop | |
end | |
end | |
$reporter = TomReporter.new | |
def test(*args, &block) | |
context = Class.new(Kintama::Runnable) | |
context.send(:include, Kintama::Context) | |
context.test(*args, &block) | |
runner = Kintama::Runner::Default.new | |
runner.with(context).run($reporter) | |
$contexts << context | |
end | |
# ------ | |
class Foo | |
end | |
test "foos be instantiated" do | |
foo = Foo.new | |
assert foo.is_a?(Foo) | |
end | |
class Foo | |
def greet | |
"Hello" | |
end | |
end | |
test "Foos can greet people" do | |
foo = Foo.new | |
assert_equal "Hello", foo.greet | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment