huh 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +61 -0
- data/lib/huh.rb +30 -0
- metadata +72 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Justin Baker
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
Intro
|
2
|
+
=========
|
3
|
+
|
4
|
+
A tiny(<30 lines) library for unit testing
|
5
|
+
|
6
|
+
Install
|
7
|
+
=========
|
8
|
+
|
9
|
+
sudo gem install huh
|
10
|
+
|
11
|
+
or from source
|
12
|
+
|
13
|
+
git clone git://github.com/justinbaker/huh.git
|
14
|
+
cd huh
|
15
|
+
rake
|
16
|
+
gem install huh-1.0.0.gem
|
17
|
+
|
18
|
+
Usage
|
19
|
+
=========
|
20
|
+
|
21
|
+
class PostTest < Huh
|
22
|
+
|
23
|
+
test "should_not_save" do
|
24
|
+
@post = Post.new
|
25
|
+
assert !@post.save
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
Assertions
|
31
|
+
============
|
32
|
+
|
33
|
+
The current list of assertions available:
|
34
|
+
|
35
|
+
- assert(a): expects a to be true
|
36
|
+
- assert_equal(a, b): expects a == b
|
37
|
+
- assert_nil(a): expects a == nil
|
38
|
+
- flunk: fails always
|
39
|
+
|
40
|
+
License
|
41
|
+
===========
|
42
|
+
Copyright (c) 2010 Justin baker
|
43
|
+
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
45
|
+
a copy of this software and associated documentation files (the
|
46
|
+
"Software"), to deal in the Software without restriction, including
|
47
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
48
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
+
permit persons to whom the Software is furnished to do so, subject to
|
50
|
+
the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be
|
53
|
+
included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
56
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
57
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
58
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
59
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
60
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
61
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/huh.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Huh
|
2
|
+
class Failure < StandardError; end
|
3
|
+
class << self
|
4
|
+
attr_accessor :a, :t, :f
|
5
|
+
def test(name, &block)
|
6
|
+
@t= oz(@t)+1
|
7
|
+
begin
|
8
|
+
yield
|
9
|
+
rescue Failure => e
|
10
|
+
print "Testing #{name} [\033[1;49;31mFAILED\033[0m]\n"
|
11
|
+
else
|
12
|
+
print "Testing #{name} [\033[1;49;32mPASSED\033[0m]\n"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def assert(truth)
|
16
|
+
unless !!truth
|
17
|
+
@f = oz(@f) + 1
|
18
|
+
raise Failure
|
19
|
+
else
|
20
|
+
@a = oz(@a)+1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
def oz(v); v or 0; end # value or_zero
|
24
|
+
def flunk; assert(false); end # always fails
|
25
|
+
def assert_equal(a,b); assert(a == b); end # true == true..yes
|
26
|
+
def assert_nil(a); assert(a.nil?); end # true == true..yes
|
27
|
+
def finish!;puts "\n#{oz(@t)} tests, #{oz(@a)} assertions, #{oz(@f)} failures. #{(((@t-@f).to_f/@t.to_f)*100).to_i}% passing tests"; end # spit out info
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: huh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Justin Baker
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-18 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A tiny(<30 lines) library for unit testing
|
23
|
+
email:
|
24
|
+
- bakermoto@gmail.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- lib/huh.rb
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/justinbaker/huh
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 3
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 23
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 3
|
62
|
+
- 6
|
63
|
+
version: 1.3.6
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project: huh
|
67
|
+
rubygems_version: 1.3.7
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: 30 line ruby unit testing library
|
71
|
+
test_files: []
|
72
|
+
|