Created
September 15, 2008 09:42
-
-
Save drnic/10829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PonyList | |
def initialize(ponies = []) | |
@ponies = ponies | |
end | |
def empty? | |
@ponies.empty? | |
end | |
def add(pony) | |
@ponies << pony | |
end | |
end | |
if $0 == __FILE__ | |
require "test/unit" | |
require "rubygems" | |
require "Shoulda" | |
class Test::Unit::TestCase | |
def self.should_be_empty | |
should "be empty" do | |
assert(@list.empty?) | |
end | |
end | |
def self.should_not_be_empty | |
should "not be empty" do | |
assert(!@list.empty?) | |
end | |
end | |
end | |
class TestPonyLists < Test::Unit::TestCase | |
def test_case_name | |
assert(true, "Failure message.") | |
end | |
context "new PonyList" do | |
setup { @list = PonyList.new } | |
should_be_empty | |
context "with an extra Pony" do | |
setup { @list.add "Grey" } | |
should_not_be_empty | |
should "contain names of pony types" do | |
end | |
end | |
end | |
context "PonyList with ponies" do | |
setup do | |
@list = PonyList.new(%w[White Black]) | |
end | |
should_not_be_empty | |
should "be not empty" do | |
assert(!@list.empty?) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment