コード例 #1
0
class TestCarnivorous(unittest.TestCase):
    def setUp(self):
        self.a_carnivorous = Carnivorous()

    def it_creates_a_carnivorous(self):
        self.a_carnivorous | should | be_instance_of(Carnivorous)

    def it_feeds_the_carnivorous(self):
        self.a_carnivorous.eat("s")
        self.a_carnivorous.stomach | should | contain("s")
        self.a_carnivorous.eat(2)
        self.a_carnivorous.stomach | should | contain(2)
        self.a_carnivorous.stomach | should | equal_to(["s", 2])

    def it_digest_the_feed(self):
        self.a_carnivorous.eat("s")
        self.a_carnivorous.eat(2.0)
        self.a_carnivorous.digest()
        self.a_carnivorous.stomach | should_not | contain("s")
        self.a_carnivorous.stomach | should | contain(2.0)
コード例 #2
0
 def setUp(self):
     self.a_carnivorous = Carnivorous()