Permalink
Browse files

Rename NanoTest -> Nanotest

  • Loading branch information...
1 parent 4753962 commit 20fad965fc5dd29578fa41d0b0153783cb88ead2 @mynyml committed Nov 27, 2009
Showing with 32 additions and 32 deletions.
  1. +4 −4 README.rdoc
  2. +2 −2 lib/nanotest.rb
  3. +1 −1 nanotest.gemspec
  4. +25 −25 test/test_nanotest.rb
View
@@ -1,6 +1,6 @@
=== Summary
-Extremely mynymal test framework. Perfect for DIY lovers. NanoTest provides
+Extremely mynymal test framework. Perfect for DIY lovers. Nanotest provides
the bare mynymum needed; for everything else, there's ruby.
=== Install
@@ -10,7 +10,7 @@ the bare mynymum needed; for everything else, there's ruby.
=== Examples
require 'nanotest'
- include NanoTest
+ include Nanotest
assert { 1 == 1 }
assert { 2 > 1 }
@@ -26,10 +26,10 @@ There's also a real life example at http://github.com/mynyml/phocus/blob/master/
=== API
-NanoTest has a single method: #assert. You can either include NanoTest as
+Nanotest has a single method: #assert. You can either include Nanotest as
above, or use its method directly:
- NanoTest.assert { true }
+ Nanotest.assert { true }
Its block is expected to return a boolean. If it's false it fails, otherwise
it passes. Simple as that.
View
@@ -1,4 +1,4 @@
-module NanoTest
+module Nanotest
extend self
@@failures, @@dots = [], []
@@ -14,7 +14,7 @@ def assert(msg="assertion failed", file=nil, line=nil, &block)
end
end
- def self.results
+ def self.results #:nodoc:
@@dots.join + "\n" + @@failures.join("\n")
end
View
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = "nanotest"
s.summary = "When all you need is #assert"
- s.description = "Extremely mynymal test framework. Perfect for DIY lovers. NanoTest provides the bare mynymum needed; for everything else, there's ruby."
+ s.description = "Extremely mynymal test framework. Perfect for DIY lovers. Nanotest provides the bare mynymum needed; for everything else, there's ruby."
s.author = "Martin Aumont"
s.email = "mynyml@gmail.com"
s.homepage = "http://github.com/mynyml/nanotest"
View
@@ -1,7 +1,7 @@
require 'minitest/autorun'
require 'test/test_helper'
-module NanoTest
+module Nanotest
class << self
def failures() @@failures end
def dots() @@dots end
@@ -14,67 +14,67 @@ def at_exit() end
# fixture class for nanotest mixin
class Foo
- include NanoTest
+ include Nanotest
end
-class TestNanoTest < MiniTest::Unit::TestCase
+class TestNanotest < MiniTest::Unit::TestCase
def self.test(name, &block)
define_method("test_#{name.gsub(/\s/,'_')}", &block)
end
def teardown
- NanoTest::dots.clear
- NanoTest::failures.clear
+ Nanotest::dots.clear
+ Nanotest::failures.clear
end
test "api" do
assert_respond_to Foo.new, :assert
- assert_respond_to NanoTest, :assert
+ assert_respond_to Nanotest, :assert
end
test "assertion passes" do
- NanoTest.assert { true }
- assert_equal '.', NanoTest::dots.last
- assert_empty NanoTest::failures
+ Nanotest.assert { true }
+ assert_equal '.', Nanotest::dots.last
+ assert_empty Nanotest::failures
end
test "assertion fails (false)" do
- NanoTest.assert { false }
- assert_equal 'F', NanoTest::dots.last
- refute_empty NanoTest::failures
+ Nanotest.assert { false }
+ assert_equal 'F', Nanotest::dots.last
+ refute_empty Nanotest::failures
end
test "assertion fails (nil)" do
- NanoTest.assert { nil }
- assert_equal 'F', NanoTest::dots.last
- refute_empty NanoTest::failures
+ Nanotest.assert { nil }
+ assert_equal 'F', Nanotest::dots.last
+ refute_empty Nanotest::failures
end
test "failure message" do
- @line = __LINE__; NanoTest.assert { false }
- assert_equal 1, NanoTest::failures.size
- assert_includes NanoTest::failures, "(%s:%0.3d) assertion failed" % [__FILE__, @line]
+ @line = __LINE__; Nanotest.assert { false }
+ assert_equal 1, Nanotest::failures.size
+ assert_includes Nanotest::failures, "(%s:%0.3d) assertion failed" % [__FILE__, @line]
end
test "custom failure message, file, line" do
- NanoTest.assert('foo','bar',2) { false }
- assert_includes NanoTest::failures, "(bar:002) foo"
+ Nanotest.assert('foo','bar',2) { false }
+ assert_includes Nanotest::failures, "(bar:002) foo"
end
test "displays results" do
- NanoTest.assert { true }
- NanoTest.assert { false }; line1 = __LINE__
- NanoTest.assert { false }; line2 = __LINE__
+ Nanotest.assert { true }
+ Nanotest.assert { false }; line1 = __LINE__
+ Nanotest.assert { false }; line2 = __LINE__
expected = <<-OUT.gsub(/^\s*/,'').strip % [__FILE__, line1, __FILE__, line2]
.FF
(%s:%0.3d) assertion failed
(%s:%0.3d) assertion failed
OUT
- assert_equal expected, NanoTest.results
+ assert_equal expected, Nanotest.results
end
test "displays results with no assertions" do
- assert_empty NanoTest.results.strip
+ assert_empty Nanotest.results.strip
end
end

0 comments on commit 20fad96

Please sign in to comment.