nanotest 0.9 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  doc/
2
2
  pkg/
3
+ .yardoc
@@ -0,0 +1,51 @@
1
+ === Summary
2
+
3
+ Extremely mynymal test framework. Perfect for DIY lovers. NanoTest provides
4
+ the bare mynymum needed; for everything else, there's ruby.
5
+
6
+ === Install
7
+
8
+ gem install nanotest --source http://gemcutter.org
9
+
10
+ === Examples
11
+
12
+ require 'nanotest'
13
+ include NanoTest
14
+
15
+ assert { 1 == 1 }
16
+ assert { 1 >= 1 }
17
+ assert { 1 == 2 } #line 12
18
+
19
+ outputs:
20
+
21
+ ..F
22
+ (examples.rb:012) assertion failed
23
+
24
+ === API
25
+
26
+ NanoTest has a single method: #assert. You can either include NanoTest as
27
+ above, or use its method directly:
28
+
29
+ NanoTest.assert { true }
30
+
31
+ Its block is expected to return a boolean. If it's false (== false) it fails,
32
+ otherwise it passes. Simple as that.
33
+
34
+ #assert also accepts a custom failure message (defaults to "assertion failed"):
35
+
36
+ assert("foo is too small") { @foo > 5 } #line 36
37
+ #=> (examples.rb:036) foo is too small
38
+
39
+ That's pretty much it. Maximum Simplicity. If you insist on doing something
40
+ fancy, check out the wiki for a few tips and tricks.
41
+
42
+ === Links
43
+
44
+ source:: http://github.com/mynyml/nanotest
45
+ docs:: http://rdoc.info/projects/mynyml/nanotest
46
+ wiki:: http://wiki.github.com/mynyml/nanotest
47
+ bugs:: http://github.com/mynyml/nanotest/issues
48
+
49
+
50
+ tl;dr: is small test fw. is fun. assert("msg") { bool }
51
+
data/Rakefile CHANGED
@@ -1,23 +1,18 @@
1
- begin
2
- require 'yard'
3
- rescue LoadError, RuntimeError
4
- end
5
-
6
1
  # --------------------------------------------------
7
2
  # Gem
8
3
  # --------------------------------------------------
9
4
  def gemspec
10
5
  @gemspec ||= Gem::Specification.new do |s|
11
6
  s.name = "nanotest"
12
- s.summary = "Out of my way, test framework!"
13
- s.description = "Most. Miminal. Test Framework. Ever! Perfect for DIY lovers."
7
+ s.summary = "When all you need is #assert"
8
+ s.description = "Extremely mynymal test framework. Perfect for DIY lovers. NanoTest provides the bare mynymum needed; for everything else, there's ruby."
14
9
  s.author = "Martin Aumont"
15
10
  s.email = "mynyml@gmail.com"
16
11
  s.homepage = "http://github.com/mynyml/nanotest"
17
12
  s.rubyforge_project = "nanotest"
18
13
  s.has_rdoc = false
19
14
  s.require_path = "lib"
20
- s.version = "0.9"
15
+ s.version = "0.9.1"
21
16
  s.files = File.read("Manifest").strip.split("\n")
22
17
 
23
18
  s.add_development_dependency 'minitest'
@@ -44,18 +39,32 @@ namespace(:test) do
44
39
  desc "Run all tests"
45
40
  task(:all) do
46
41
  tests = Dir['test/**/test_*.rb'] - ['test/test_helper.rb']
47
- cmd = "ruby -rubygems -Ilib -e'%w( #{tests.join(' ')} ).each {|file| require file }'"
42
+ cmd = "ruby -rubygems -I.:lib -e'%w( #{tests.join(' ')} ).each {|file| require file }'"
48
43
  puts(cmd) if ENV['VERBOSE']
49
44
  system(cmd)
50
45
  end
46
+
47
+ desc "Run all tests on multiple ruby versions (requires rvm)"
48
+ task(:portability) do
49
+ versions = %w( 1.8.6 1.8.7 1.9 1.9.2 jruby jruby\ -v\ 1.4.0RC1 )
50
+ versions.each do |version|
51
+ system <<-BASH
52
+ bash -c 'source ~/.rvm/scripts/rvm;
53
+ rvm use #{version};
54
+ echo "--------- #{version} ----------";
55
+ rake -s test:all'
56
+ BASH
57
+ end
58
+ end
51
59
  end
52
60
 
53
61
  # --------------------------------------------------
54
62
  # Docs
55
63
  # --------------------------------------------------
56
- if defined? YARD
57
- YARD::Rake::YardocTask.new do |t|
58
- t.files = %w( lib/**/*.rb )
59
- t.options = %w( -o doc/yard --readme README.rdoc --files LICENSE )
60
- end
64
+ desc "Generate YARD Documentation"
65
+ task :yardoc do
66
+ require 'yard'
67
+ files = %w( lib/**/*.rb )
68
+ options = %w( -o doc/yard --readme README.rdoc --files LICENSE )
69
+ YARD::CLI::Yardoc.run *(options + files)
61
70
  end
@@ -1,5 +1,4 @@
1
1
  require 'nanotest'
2
-
3
2
  include NanoTest
4
3
 
5
4
  class Foo
@@ -26,6 +25,5 @@ __END__
26
25
  output:
27
26
 
28
27
  ....FF
29
- (examples.rb:22) assertion failed
30
- (examples.rb:23) boom
31
-
28
+ (examples.rb:021) assertion failed
29
+ (examples.rb:022) boom
@@ -7,7 +7,7 @@ module NanoTest
7
7
  if block.call == false
8
8
  file ||= caller.first.split(':')[0]
9
9
  line ||= caller.first.split(':')[1]
10
- FAILURES << "(#{file}:#{line}) #{msg}"
10
+ FAILURES << "(%s:%0.3d) %s" % [file,line,msg]
11
11
  print 'F'
12
12
  else
13
13
  print '.'
@@ -18,9 +18,9 @@ end
18
18
  # --------------------------------------------------
19
19
  # Watchr Rules
20
20
  # --------------------------------------------------
21
- watch( '^examples\.rb' ) { |m| run( "ruby -rubygems -Ilib %s" % m[0] ) }
22
- watch( '^test.*/test_.*\.rb' ) { |m| run( "ruby -rubygems -Ilib %s" % m[0] ) }
23
- watch( '^lib/(.*)\.rb' ) { |m| run( "ruby -rubygems -Ilib test/test_%s.rb" % m[1] ) }
21
+ watch( '^examples\.rb' ) { |m| system( "ruby -rubygems -Ilib %s" % m[0] ) }
22
+ watch( '^test.*/test_.*\.rb' ) { |m| run( "ruby -rubygems -Ilib %s" % m[0] ) }
23
+ watch( '^lib/(.*)\.rb' ) { |m| run( "ruby -rubygems -Ilib test/test_%s.rb" % m[1] ) }
24
24
  watch( '^test/test_helper\.rb' ) { run_all_tests }
25
25
 
26
26
  # --------------------------------------------------
@@ -1,5 +1,10 @@
1
1
  require 'minitest/autorun'
2
2
  require 'nanotest'
3
+ begin
4
+ require 'redgreen'
5
+ require 'phocus'
6
+ rescue LoadError, RuntimeError
7
+ end
3
8
 
4
9
  class MiniTest::Unit::TestCase
5
10
  def self.test(name, &block)
@@ -33,13 +33,13 @@ class TestNanoTest < MiniTest::Unit::TestCase
33
33
  @line = __LINE__; NanoTest.assert { false }
34
34
  end
35
35
  assert_equal 1, NanoTest::FAILURES.size
36
- assert_includes NanoTest::FAILURES, "(#{__FILE__}:#{@line}) assertion failed"
36
+ assert_includes NanoTest::FAILURES, "(%s:%0.3d) assertion failed" % [__FILE__, @line]
37
37
  end
38
38
 
39
39
  test "custom failure message, file, line" do
40
40
  capture_io do
41
41
  NanoTest.assert('foo','bar',2) { false }
42
42
  end
43
- assert_includes NanoTest::FAILURES, "(bar:2) foo"
43
+ assert_includes NanoTest::FAILURES, "(bar:002) foo"
44
44
  end
45
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanotest
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.9"
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Aumont
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-28 00:00:00 -04:00
12
+ date: 2009-10-30 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
- description: Most. Miminal. Test Framework. Ever! Perfect for DIY lovers.
25
+ description: Extremely mynymal test framework. Perfect for DIY lovers. NanoTest provides the bare mynymum needed; for everything else, there's ruby.
26
26
  email: mynyml@gmail.com
27
27
  executables: []
28
28
 
@@ -69,6 +69,6 @@ rubyforge_project: nanotest
69
69
  rubygems_version: 1.3.5
70
70
  signing_key:
71
71
  specification_version: 3
72
- summary: Out of my way, test framework!
72
+ summary: "When all you need is #assert"
73
73
  test_files: []
74
74