Ticket #336: tc_foo.rb
| File tc_foo.rb, 314 bytes (added by mike@…, 2 years ago) |
|---|
| Line | |
|---|---|
| 1 | require 'rubygems' |
| 2 | gem 'thoughtbot-shoulda' |
| 3 | require 'shoulda' |
| 4 | require 'test/unit' |
| 5 | |
| 6 | def fact(x) |
| 7 | return 1 if x == 0 |
| 8 | return (1..x).inject(:*) |
| 9 | end |
| 10 | |
| 11 | class TC_Test < Test::Unit::TestCase |
| 12 | context "My factorial method" do |
| 13 | should "return 1 when passed 0" do |
| 14 | assert_equal 1, fact(0) |
| 15 | end |
| 16 | end |
| 17 | end |

