madx-mtest 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +45 -0
- data/Rakefile +12 -0
- data/VERSION +1 -0
- data/lib/mtest.rb +39 -0
- metadata +56 -0
data/README
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
‘‘ MTest ’’
|
3
|
+
|
4
|
+
|
5
|
+
MTest (stands for MicroTest) is a tiny and fast TDD framework.
|
6
|
+
|
7
|
+
It provides the Kernel#MTest method that takes an array of test as a parameter.
|
8
|
+
|
9
|
+
Need an example? Right.
|
10
|
+
|
11
|
+
|
12
|
+
require 'mtest'
|
13
|
+
|
14
|
+
tests = [
|
15
|
+
"This is a simple test",
|
16
|
+
["Sum 40+2", proc {
|
17
|
+
40 + 2
|
18
|
+
}, 42]
|
19
|
+
]
|
20
|
+
|
21
|
+
MTest(tests)
|
22
|
+
|
23
|
+
|
24
|
+
MTests returns a hash that represents the results of a test. Example!
|
25
|
+
|
26
|
+
|
27
|
+
tests = [
|
28
|
+
"This is a simple test",
|
29
|
+
["Sum 40+2", proc { 40 + 2 }, 42],
|
30
|
+
|
31
|
+
"This one fails",
|
32
|
+
["FAIL", proc { true }, false]
|
33
|
+
]
|
34
|
+
|
35
|
+
res = MTest(tests)
|
36
|
+
|
37
|
+
res # => {:pass => 1, :err => 0, :fail => 1}
|
38
|
+
|
39
|
+
|
40
|
+
** Contributing **
|
41
|
+
|
42
|
+
Everyone is welcome to contribute to MTest. The only restriction is that
|
43
|
+
mtest.rb must be less than 51 lines long.
|
44
|
+
|
45
|
+
But feel free to submit your own tools, examples, hacks, etc.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
|
5
|
+
MTEST_GEMSPEC = eval(File.read('mtest.gemspec'))
|
6
|
+
|
7
|
+
Rake::GemPackageTask.new(MTEST_GEMSPEC) do |pkg|
|
8
|
+
pkg.need_tar_bz2 = true
|
9
|
+
end
|
10
|
+
task :default => "pkg/#{MTEST_GEMSPEC.name}-#{MTEST_GEMSPEC.version}.gem" do
|
11
|
+
puts "generated latest version"
|
12
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.3
|
data/lib/mtest.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Format
|
2
|
+
def self.included(parent)
|
3
|
+
{:_r => '31', :_g => '32', :_p => "35", :_w => "1;37"}.each do |m, c|
|
4
|
+
parent.class_eval { define_method(m) { "\e[#{c}m#{self}\e[00m" } }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
String.send(:include, Format)
|
9
|
+
|
10
|
+
def MTest(tests)
|
11
|
+
threads = []; results = {:pass => 0, :fail => 0, :err => 0}
|
12
|
+
tests.each do |t|
|
13
|
+
if t.is_a?(String)
|
14
|
+
puts t
|
15
|
+
else
|
16
|
+
e,p,v = *t
|
17
|
+
threads << Thread.new do
|
18
|
+
begin
|
19
|
+
if (r = p.call) == v
|
20
|
+
results[:pass] += 1
|
21
|
+
puts ". #{e}"._g
|
22
|
+
else
|
23
|
+
results[:fail] += 1
|
24
|
+
puts "! #{e} was #{r}, expected #{v}"._r
|
25
|
+
end
|
26
|
+
rescue => x
|
27
|
+
results[:err] += 1
|
28
|
+
file, line = x.backtrace[0].split(':')
|
29
|
+
puts "@ #{x.class} at line #{line} in #{File.basename(file)}"._p
|
30
|
+
puts " (#{e})"
|
31
|
+
puts " #{x.message}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
threads.join
|
37
|
+
sleep(0.1) # This is a dirty fix so joining doesn't screws newlines
|
38
|
+
results
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: madx-mtest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Fran\xC3\xA7ois Vaux"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-25 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: MTest is a microframework for testing your Ruby programs. It is inspired from Paul Barry's "One line test framework" which you can found at http://paulbarry.com/articles/2008/05/23/a-ruby-test-framework-in-one-line.
|
17
|
+
email: root+mtest@yapok.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/mtest.rb
|
26
|
+
- README
|
27
|
+
- VERSION
|
28
|
+
- Rakefile
|
29
|
+
has_rdoc: false
|
30
|
+
homepage: http://yapok.org/
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
requirements: []
|
49
|
+
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.2.0
|
52
|
+
signing_key:
|
53
|
+
specification_version: 2
|
54
|
+
summary: A micro test framework
|
55
|
+
test_files: []
|
56
|
+
|