SlideShare a Scribd company logo
“S is for Spec”:Test Driven Development w/ RSpec


KAKUTANI Shintaro; Eiwa System Management,Inc.; Nihon Ruby-no-kai
✓
✓
✓
✓ http://kakutani.com
S is for Spec
S is for Spec
S is for Spec
RubyKaigi2008


http://jp.rubyist.net/RubyKaigi2008/
S is for Spec
S is for Spec
Red, Green, Refactoring



TEST CLUB
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
Red, Green, Refactoring



TEST CLUB
S is for Spec
✓

✓
✓
✓
S is for Spec
✓
✓
✓
✓
✓
✓
✓
S is for Spec
S is for Spec
S is for Spec
Clean code that works, in
Ron Jeffries’ pithy phrase, is
  the goal of Test-Driven
   Development(TDD).
“Clean code that works”
S is for Spec
“The translation of a
  feeling into a test is a
common theme of TDD.”
S is for Spec
✓
✓
✓
✓
✓
✓
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
http://www.biwa.ne.jp/~mmura/SoftwareDevelopment/WhatIsSoftwareDesignJ.html
✓
✓
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
✓
✓
✓
✓

✓
✓
✓
✓
✓
✓
✓
✓
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
✓
✓
✓
✓
✓
✓
Refactoring
       GREEN
E D
 R
S is for Spec
S is for Spec
✓
✓
✓
✓
✓
✓
S is for Spec
S is for Spec
S is for Spec
RED

  GREEN

Refactoring
S is for Spec
The Art of Agile Development
Think

   RED

  GREEN

Refactoring
S is for Spec
S is for Spec
✓
✓
✓
✓
✓
✓
✓
✓

✓
✓
✓
S is for Spec
✓


✓
S is for Spec
http://jp.rubyist.net/magazine/?0021-Rspec
S is for Spec
describe Class, quot;          quot; do
 before(:each) do
   #
  end

 it quot;               quot; do
    #
  end
end
describe Array, quot;with some entriesquot; do
  before(:each) do
    @array = %w(A B C)
  end

 it quot;should not be nilquot; do
   @array.should_not be_nil
 end

  it quot;should last element is 'C'quot; do
    @array.last.should == 'C'
  end
end
spec -c array_spec.rb
✓
    @array.last.should == 'C'
    # @array.last    'C'



✓
    @array.should_not be_nil
    # @array.nil?   false
✓
✓
✓
✓
✓
✓
✓
✓
S is for Spec
http://jp.rubyist.net/magazine/?0021-Rspec
S is for Spec
S is for Spec
The Bowling Game Kata
                           by Robert C.Martin(Uncle Bob)

                 Bowling Game Kata


             Object Mentor, Inc.
                  www.objectmentor.com
                  blog.objectmentor.com




  fitnesse.org                            www.junit.org
                                                           Copyright 2005 by Object Mentor, Inc
                                                          All copies must retain this page unchanged.




http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata
http://codekata.pragprog.com/
✓
✓
✓
✓
http://codekata.pragprog.com/
✓
✓
✓
✓
✓
✓

✓
1 4 4 5 6      5         0 1 7     6     2 6

 5   14   29   49   60   61   77   97 117 133

1,4,4,5,6,4,5,5, 10, 0,1,7,3,6,4,10,2,8,6
✓
✓
✓
✓
 ✓
 ✓
S is for Spec
✓

✓
✓
✓
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
S is for Spec
Tyler Durden says...

use Rspec.

More Related Content

S is for Spec