huh 1.0.3 → 1.0.4
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/examples/all_assertions.rb +59 -0
- data/lib/huh.rb +13 -2
- metadata +4 -3
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../lib/huh"
|
2
|
+
|
3
|
+
class Test < Huh
|
4
|
+
|
5
|
+
test "the truth" do
|
6
|
+
assert true
|
7
|
+
end
|
8
|
+
|
9
|
+
test "the power of equality" do
|
10
|
+
assert_equal "me", "me"
|
11
|
+
end
|
12
|
+
|
13
|
+
test "the power of inequality" do
|
14
|
+
assert_not_equal "me", "you"
|
15
|
+
end
|
16
|
+
|
17
|
+
test "nil yo" do
|
18
|
+
assert_nil nil
|
19
|
+
end
|
20
|
+
|
21
|
+
test "not nil yo" do
|
22
|
+
assert_not_nil true
|
23
|
+
end
|
24
|
+
|
25
|
+
test "everything is a class" do
|
26
|
+
assert_instance_of Fixnum, 1
|
27
|
+
end
|
28
|
+
|
29
|
+
test "everything is a class" do
|
30
|
+
assert_kind_of Fixnum, 1
|
31
|
+
end
|
32
|
+
|
33
|
+
test "love match" do
|
34
|
+
assert_match /love/, "love"
|
35
|
+
end
|
36
|
+
|
37
|
+
test "no_love_match" do
|
38
|
+
assert_no_match /love/, "loner"
|
39
|
+
end
|
40
|
+
|
41
|
+
test "respond_to?" do
|
42
|
+
assert_respond_to :gsub, "hello"
|
43
|
+
end
|
44
|
+
|
45
|
+
test "should get pissed" do
|
46
|
+
assert_raises do
|
47
|
+
raise "WHAT THE FUCK"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
test "should be true" do
|
52
|
+
assert_block do
|
53
|
+
"dfg"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
finish!
|
58
|
+
|
59
|
+
end
|
data/lib/huh.rb
CHANGED
@@ -15,8 +15,19 @@ class Huh
|
|
15
15
|
end
|
16
16
|
def self.oz(v); v or 0; end # value or_zero
|
17
17
|
def self.flunk; assert(false); end # always fails
|
18
|
-
def self.assert_equal(a
|
19
|
-
def self.
|
18
|
+
def self.assert_equal(e,a); assert(e == a); end # true == true..yes
|
19
|
+
def self.assert_not_equal(e,a); assert(e != a); end
|
20
|
+
def self.assert_same(e,a); assert(e.equal?(a)); end # true == true..yes
|
21
|
+
def self.assert_not_same(e,a); assert(!e.equal?(a)); end
|
22
|
+
def self.assert_nil(a); assert(a.nil?); end # a == nil..yes
|
23
|
+
def self.assert_not_nil(a); assert(!a.nil?); end # a == nil..no
|
24
|
+
def self.assert_instance_of(k,o); assert(o.instance_of?(k)); end # kind, object. object is a kind
|
25
|
+
def self.assert_kind_of(k,o); assert(o.kind_of?(k)); end # kind, object. object is somewhat a kind
|
26
|
+
def self.assert_match(p,s); assert(p.match(s)); end # regex matcher
|
27
|
+
def self.assert_no_match(p,s); assert(!p.match(s)); end # regex doesnt match
|
28
|
+
def self.assert_respond_to(m,o); assert(o.respond_to?(m)); end # you talk like that?
|
29
|
+
def self.assert_raises(&block); assert(begin; yield; rescue; true; end); end
|
30
|
+
def self.assert_block(&block); assert(begin;yield; rescue; false; end); end
|
20
31
|
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
|
21
32
|
end
|
22
33
|
|
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: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Baker
|
@@ -30,6 +30,7 @@ extra_rdoc_files: []
|
|
30
30
|
|
31
31
|
files:
|
32
32
|
- lib/huh.rb
|
33
|
+
- examples/all_assertions.rb
|
33
34
|
- examples/flunk.rb
|
34
35
|
- examples/post_test.rb
|
35
36
|
- examples/basic.rb
|