huh 1.0.4 → 1.0.5
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.md +15 -0
- data/examples/all_assertions.rb +21 -1
- data/lib/huh.rb +6 -0
- metadata +6 -6
data/README.md
CHANGED
@@ -38,7 +38,22 @@ The current list of assertions available:
|
|
38
38
|
|
39
39
|
- assert(a): expects a to be true
|
40
40
|
- assert_equal(a, b): expects a == b
|
41
|
+
- assert_not_equal(a, b): expects a != b
|
42
|
+
- assert_same(a, b): expects a.equal?(b)
|
43
|
+
- assert_not_same(a, b): expects !a.equal?(b)
|
41
44
|
- assert_nil(a): expects a == nil
|
45
|
+
- assert_not_nil(a): expects a != nil
|
46
|
+
- assert_instance_of(t, o): expects o.instance_of?(t)
|
47
|
+
- assert_kind_of(t, o): expects o.kind_of?(t)
|
48
|
+
- assert_match(p,s): expects p.match(s)
|
49
|
+
- assert_no_match(p,s): expects !p.match(s)
|
50
|
+
- assert_respond_to(m,o): expects o.respond_to?(m)
|
51
|
+
- assert_raises(block): expects block.call to raise an error
|
52
|
+
- assert_block(block): expects block.call to return true
|
53
|
+
- assert_send(array): expects array[0].send(array[1], array[REST OF ARRAY])
|
54
|
+
- assert_in_delta(e,a,d): expects e-a to be less than or equal to d
|
55
|
+
- assert_nothing_thrown(block): expects block to throw nothing
|
56
|
+
- assert_nothing_raised(block): expects block to raise nothing
|
42
57
|
- flunk: fails always
|
43
58
|
|
44
59
|
License
|
data/examples/all_assertions.rb
CHANGED
@@ -50,7 +50,27 @@ class Test < Huh
|
|
50
50
|
|
51
51
|
test "should be true" do
|
52
52
|
assert_block do
|
53
|
-
|
53
|
+
true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
test "should send it" do
|
58
|
+
assert_send [[1,2], :include?, 1]
|
59
|
+
end
|
60
|
+
|
61
|
+
test "delta!!!!" do
|
62
|
+
assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
|
63
|
+
end
|
64
|
+
|
65
|
+
test "shouldn't have no problems throwing" do
|
66
|
+
assert_nothing_thrown do
|
67
|
+
"I'm a good kid :)"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
test "shouldn't have no problems raising" do
|
72
|
+
assert_nothing_raised do
|
73
|
+
"I'm a good kid :)"
|
54
74
|
end
|
55
75
|
end
|
56
76
|
|
data/lib/huh.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
class Huh
|
2
|
+
V = "1.0.5"
|
2
3
|
class Failure < StandardError; end
|
3
4
|
def self.test(name, &block)
|
4
5
|
@t = oz(@t) + 1
|
@@ -28,6 +29,11 @@ class Huh
|
|
28
29
|
def self.assert_respond_to(m,o); assert(o.respond_to?(m)); end # you talk like that?
|
29
30
|
def self.assert_raises(&block); assert(begin; yield; rescue; true; end); end
|
30
31
|
def self.assert_block(&block); assert(begin;yield; rescue; false; end); end
|
32
|
+
def self.assert_operator(a,b,o);assert(a.send(0, b)); end
|
33
|
+
def self.assert_send(a); assert(a[0].send(a[1], *a[2..-1])); end
|
34
|
+
def self.assert_in_delta(e,a,d); assert((e.to_f - a.to_f).abs <= d.to_f); end
|
35
|
+
def self.assert_nothing_thrown(&block); assert(begin; yield; true; rescue; false;end); end
|
36
|
+
def self.assert_nothing_raised(&block); assert(begin; yield;true; rescue; false;end) end
|
31
37
|
def self.finish!;puts "\n#{oz(@t)} tests, #{oz(@a)} assertions, #{oz(@f)} failures. #{(((oz(@t)-oz(@f)).to_f/@t.to_f)*100).to_i}% passing tests"; end # spit out info
|
32
38
|
end
|
33
39
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Baker
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-20 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: A tiny(<
|
22
|
+
description: A tiny(<40 lines) library for unit testing
|
23
23
|
email:
|
24
24
|
- bakermoto@gmail.com
|
25
25
|
executables: []
|
@@ -71,6 +71,6 @@ rubyforge_project: huh
|
|
71
71
|
rubygems_version: 1.3.7
|
72
72
|
signing_key:
|
73
73
|
specification_version: 3
|
74
|
-
summary:
|
74
|
+
summary: 40 line ruby unit testing library
|
75
75
|
test_files: []
|
76
76
|
|