You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: testing-with-tap/ruby.md
+20-22
Original file line number
Diff line number
Diff line change
@@ -7,41 +7,39 @@ title: Testing with Ruby
7
7
8
8
Testing with Ruby is pretty easy, however, there is a lesser known Ruby program, that produces TAP output (on demand). This handy program is [bacon](http://github.com/chneukirchen/bacon/tree/master). You can install it using the RubyGems Ruby package management system. Just do (possibly as a privileged user):
9
9
10
-
```
11
-
# gem install bacon
10
+
```bash
11
+
$ gem install bacon
12
12
```
13
13
14
14
Now you can create tests. Create a Ruby file test.rb (or something like that):
15
15
16
-
```
17
-
18
-
describe "a example test suite" do
19
-
it "should consider true as the truth" do
20
-
true.should.be.true
21
-
end
22
-
23
-
it "should consider false as the truth, too" do
24
-
false.should.be.true
25
-
end
16
+
```ruby
17
+
describe "a example test suite"do
18
+
it "should consider true as the truth"do
19
+
true.should.be.true
26
20
end
27
21
22
+
it "should consider false as the truth, too"do
23
+
false.should.be.true
24
+
end
25
+
end
28
26
```
29
27
30
28
Once you created your this file, you can issue the command
31
29
32
-
```
30
+
```bash
33
31
$ bacon test.rb --tap
34
32
```
35
33
36
34
which, in turn, produces the following TAP output (Version 12)
37
35
38
36
```
39
-
ok 1 - should consider true as the truth
40
-
not ok 2 - should consider false as the truth, too: FAILED
41
-
# Bacon::Error: false.true?() failed
42
-
# ./test.rb:7: a example test suite - should consider false as the truth, too
43
-
# ./test.rb:6
44
-
# ./test.rb:1
45
-
1..2
46
-
# 2 tests, 2 assertions, 1 failures, 0 errors
47
-
```
37
+
ok 1 - should consider true as the truth
38
+
not ok 2 - should consider false as the truth, too: FAILED
39
+
# Bacon::Error: false.true?() failed
40
+
# ./test.rb:7: a example test suite - should consider false as the truth, too
0 commit comments