Skip to content

Commit f764318

Browse files
committed
:test: Modernize lemon tests.
1 parent 57eaa33 commit f764318

3 files changed

Lines changed: 58 additions & 38 deletions

File tree

test/case_ansicode.rb

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,40 @@
33

44
testcase ANSI::Code do
55

6-
unit :red do
7-
str = ANSI::Code.red
8-
out = "\e[31m"
9-
out.assert == str
10-
end
6+
method :red do
7+
test do
8+
str = ANSI::Code.red
9+
out = "\e[31m"
10+
out.assert == str
11+
end
1112

12-
unit :red => "with block notation" do
13-
str = ANSI::Code.red { "Hello" }
14-
out = "\e[31mHello\e[0m"
15-
out.assert == str
13+
test "with block notation" do
14+
str = ANSI::Code.red { "Hello" }
15+
out = "\e[31mHello\e[0m"
16+
out.assert == str
17+
end
1618
end
1719

18-
unit :blue do
19-
str = ANSI::Code.blue
20-
out = "\e[34m"
21-
out.assert == str
20+
method :blue do
21+
test do
22+
str = ANSI::Code.blue
23+
out = "\e[34m"
24+
out.assert == str
25+
end
26+
27+
test "with block notation" do
28+
str = ANSI::Code.blue { "World" }
29+
out = "\e[34mWorld\e[0m"
30+
out.assert == str
31+
end
2232
end
2333

24-
unit :blue => "with block notation" do
25-
str = ANSI::Code.blue { "World" }
26-
out = "\e[34mWorld\e[0m"
27-
out.assert == str
34+
method :hex do
35+
test do
36+
str = ANSI::Code.hex("#000000")
37+
out = "0"
38+
out.assert == str
39+
end
2840
end
2941

3042
end

test/case_mixin.rb

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@ class ::String
88
include ANSI::Mixin
99
end
1010

11-
unit :red do
12-
str = "Hello".red
13-
out = "\e[31mHello\e[0m"
14-
out.assert == str
11+
method :red do
12+
test do
13+
str = "Hello".red
14+
out = "\e[31mHello\e[0m"
15+
out.assert == str
16+
end
1517
end
1618

17-
unit :blue do
18-
str = "World".blue
19-
out = "\e[34mWorld\e[0m"
20-
out.assert == str
19+
method :blue do
20+
test do
21+
str = "World".blue
22+
out = "\e[34mWorld\e[0m"
23+
out.assert == str
24+
end
2125
end
2226

23-
unit :display do
24-
str = "Hello".display(4,10)
25-
out = "\e[s\e[4;10HHello\e[u"
26-
out.assert == str
27+
method :display do
28+
test do
29+
str = "Hello".display(4,10)
30+
out = "\e[s\e[4;10HHello\e[u"
31+
out.assert == str
32+
end
2733
end
2834

2935
end

test/case_progressbar.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55
testcase ANSI::Progressbar do
66

7-
unit :initialize do
8-
stio = StringIO.new
9-
pbar = ANSI::Progressbar.new("Test Bar", 10, stio) do |b|
10-
b.style(:title => [:red], :bar=>[:blue])
7+
method :initialize do
8+
test do
9+
stio = StringIO.new
10+
pbar = ANSI::Progressbar.new("Test Bar", 10, stio) do |b|
11+
b.style(:title => [:red], :bar=>[:blue])
12+
end
13+
10.times do |i|
14+
sleep 0.1
15+
pbar.inc
16+
end
17+
true
1118
end
12-
10.times do |i|
13-
sleep 0.1
14-
pbar.inc
15-
end
16-
true
1719
end
1820

1921
end

0 commit comments

Comments
 (0)