SlideShare a Scribd company logo
2011.05.21
http://www.flickr.com/photos/bruce_mcadam/3214482163/
2011   5   22
2011   5   22
mrkn



           Ruby
           Ruby



http://www.flickr.com/photos/koichiroo/5244581973/
2011   5   22
2011
2010   5
       3   22
           1
http://www.flickr.com/photos/bruce_mcadam/3214482163/
2011   5   22
2011.05.21
http://www.flickr.com/photos/bruce_mcadam/3214482163/
2011   5   22
2011   5   22
http://www.flickr.com/photos/bruce_mcadam/3214482163/
2011   5   22
BDD
                Behavior Driven Development




2011   5   22
TDD
                Test Driven Development




2011   5   22
TDD
                Test Driven Development




2011   5   22
TDD   BDD


2011   5   22
2011   5   22
2011   5   22
2011   5   22
2011   5   22
test-unit

2011   5   22
module System
    class AgeCalculatorTest < Test::Unit::TestCase
      include RR::Adapters::TestUnit

                def setup
                  @calc = AgeCalculator.with_birthday(1981, 7, 20)
                end

                def test_age_on
                  assert_equal(29, @calc.age_on(2011, 7, 19))
                  assert_equal(30, @calc.age_on(2011, 7, 20))
                end

      def test_age_today
        d, m, y = [*Time.now][3..5]
        stub(@calc).age_on
        @calc.age_on_today
        assert_received(@calc) {|c| c.age_on(y, m, d) }
      end
    end
  end




2011   5   22
RSpec

2011   5   22
module System
    describe AgeCalculator do
      context ‘with birthday 1981-07-20’ do
        subject { AgeCalculator.with_birthday(1981, 7, 20) }

                describe ‘#age_on’ do
                  context ‘with 2011-07-19’ do
                    specify ‘the age is 29’ do
                      subject.age_on(2011, 7, 19).should be == 29
                    end
                  end

                  context ‘with 2011-07-20’ do
                    specify ‘the age is 30’ do
                      subject.age_on(2011, 7, 20).should be == 30
                    end
                  end
                end

        describe ‘#age_on_today’ do
          it ‘calls age_on with year, month, and day on today’ do
            d, m, y = [*Time.now][3..5]
            subject.should_receive(:age_on).with(y, m, d)
            subject.age_on_today
          end
        end
      end
    end
  end




2011   5   22
2011   5   22
2011   5   22
2011   5   22
TDD




2011   5   22
!Test"#$%
                     &'()$*
                                                   t-wada
                                       http://d.hatena.ne.jp/t-wada/
                                              2005+7,23-
                                         @J2EE./012103




http://www.ne.jp/asahi/t/wada/articles/Test_in_TDD.pdf
2011   5   22
!"#$%1
                    !   TDD&'()*+,&-.
                    !   "Test"/01213.45%&6784
                        "   9:;<=>?@A
                        "   2B%"Test"CDE&-.FGHIJKLF
                        "   MNO5PQCRS
                    !   '()TUVWXOYZ[4
                        "   9:#/ ]^#/ >?@A_`




http://www.ne.jp/asahi/t/wada/articles/Test_in_TDD.pdf
2011   5   22
!"#$%1
                    !   TDD&'()*+,&-.
                    !   "Test"/01213.45%&6784
                        "   9:;<=>?@A
                        "   2B%"Test"CDE&-.FGHIJKLF
                        "   MNO5PQCRS
                    !   '()TUVWXOYZ[4
                        "   9:#/ ]^#/ >?@A_`




http://www.ne.jp/asahi/t/wada/articles/Test_in_TDD.pdf
2011   5   22
!"#$%2
                    !   TDD%"Test"&'(())%*+%,%
                        "   -./0'(12%345
                    !   TDD%67&89:;<=/>?@ABCD
                        :;EFG>/HIJKL




http://www.ne.jp/asahi/t/wada/articles/Test_in_TDD.pdf
2011   5   22
!"#$%2
                    !   TDD%"Test"&'(())%*+%,%
                        "   -./0'(12%345
                    !   TDD%67&89:;<=/>?@ABCD
                        :;EFG>/HIJKL




http://www.ne.jp/asahi/t/wada/articles/Test_in_TDD.pdf
2011   5   22
http://blogs.itmedia.co.jp/hiranabe/2005/08/sd4__c05e.html
2011   5   22
http://blogs.itmedia.co.jp/hiranabe/2005/10/tdd__bdd__731d.html
2011   5   22
2011   5   22
2011   5   22
module System
    describe AgeCalculator do
      context ‘with birthday 1981-07-20’ do
        subject { AgeCalculator.with_birthday(1981, 7, 20) }

                describe ‘#age_on’ do
                  context ‘with 2011-07-19’ do
                    specify ‘the age is 29’ do
                      subject.age_on(2011, 7, 19).should be == 29
                    end
                  end

                  context ‘with 2011-07-20’ do
                    specify ‘the age is 30’ do
                      subject.age_on(2011, 7, 20).should be == 30
                    end
                  end
                end

        describe ‘#age_on_today’ do
          it ‘calls age_on with year, month, and day on today’ do
            d, m, y = [*Time.now][3..5]
            subject.should_receive(:age_on).with(y, m, d)
            subject.age_on_today
          end
        end
      end
    end
  end




2011   5   22
2011   5   22
http://www.flickr.com/photos/bruce_mcadam/3214482163/
2011   5   22
2011   5   22
2011   5   22
2011   5   22
2011   5   22
http://gihyo.jp/dev/serial/01/ruby/0039
2011   5   22
http://www.nicovideo.jp/watch/sm12975849
2011   5   22
2011   5   22
2011   5   22
gem install rspec



2011   5   22
rspec
                     rspec-core
                rspec-expectations
                    rspec-mocks

2011   5   22
2011   5   22
gem install rspec




2011   5   22
http://www.flickr.com/photos/bruce_mcadam/3214482163/
2011   5   22
2011   5   22
2011   5   22
2011   5   22
2011   5   22
require ‘spec/test/unit’




2011   5   22
‘spec/test/unit’




2011   5   22
http://www.slideshare.net/t_wada/sapporo-rubykaigi01-twada-lt-presentation
2011   5   22
(a.k.a id:t-wada)
                                 Oct, 26, 2008 @SapporoRubyKaigi 01




http://www.slideshare.net/t_wada/sapporo-rubykaigi01-twada-lt-presentation
2011   5   22
2011   5   22
2011   5   22
2011   5   22
2011   5   22
Photo by rla579: http://flickr.com/photos/rla579/2482286520/
2011   5   22
Working Effectively with Legacy tDiary Code
                using Cucumber and RSpec


                KAKUTANI Shintaro; Eiwa System Management,Inc.; Nihon Ruby-no-kai




http://kakutani.com/articles/working_effectively_with_legacy_tdiary_code_using_cucumber_and_rspec.pdf
2011   5   22
2011   5   22
2011   5   22
2011   5   22
FizzBuzzCounter


2011   5   22
2011   5   22
#
  FizzBuzzCounter.new.each do |i|
    p i
  end
  #=> 1
  #   2
  #   “Fizz”
  #   4
  #   “Buzz”


2011   5   22
#
  fbc = FizzBuzzCounter.new
  p fbc.next #=> 1
  p fbc.next #=> 2
  p fbc.next #=> “Fizz”
  fbc.each {|i| break if i > 14 }
  p fbc.next #=> “FizzBuzz”



2011   5   22
# Enumerable
  fbc = FizzBuzzCounter.new
  p fbc.take(3) #=> [1, 2, “Fizz”]
  p fbc.take(3) #=> [4, “Buzz”, “Fizz”]




2011   5   22
2011   5   22
spec/
                spec_helper.rb
                  require ‘spec_helper’


2011   5   22
Live Coding

2011   5   22
RSpec Best Practice
http://jp.rubyist.net/magazine/?0032-TranslationArticle
2011   5   22
describe FizzBuzzCounter do
    describe ‘.filter’ do
      context ‘with 1’ do
        it ‘returns 1’ do
          FizzBuzzCounter.
            filter(1).should be == 1
        end
      end
    end
  end


2011   5   22
describe FizzBuzzCounter do
    describe ‘.filter’ do
      context ‘with 1’ do
        it ‘returns 1’ do
          FizzBuzzCounter.
            filter(1).should be == 1
        end
      end
    end
  end


2011   5   22
Observer Pattern


2011   5   22
observers
                                       1           *




                subject

                          + change()




2011   5   22
2011   5   22
2011   5   22
2011   5   22
2011   5   22
Test Double


2011   5   22
describe ConcreteObservable do
    describe ‘#change’ do
      it ‘calls its notify()’ do
        subject.should_receive(:notify)
        subject.change
      end
    end
  end




2011   5   22
describe ConcreteObservable do
    describe ‘#change’ do
      subject { ConcreteObservable.new }

      it “calls observers’ update()” do
        observer = double(‘an observer’)
        observer.should_receive(:update)
        subject.change
      end
    end
  end



2011   5   22
http://ironruby.codeplex.com/
2011   5   22

More Related Content

DOC
Ejemplos Interfaces Usuario 3
PDF
Writing Sample_3_Roulette
PDF
Practical
PDF
Deep dive into android restoration - DroidCon Paris 2014
PDF
Lesson 7 world_history_medieval_period_new_
PDF
React Back to the Future
DOCX
Final_Project
PDF
jadiditurbulencemodeling
Ejemplos Interfaces Usuario 3
Writing Sample_3_Roulette
Practical
Deep dive into android restoration - DroidCon Paris 2014
Lesson 7 world_history_medieval_period_new_
React Back to the Future
Final_Project
jadiditurbulencemodeling

Viewers also liked (7)

PDF
Ruby 1.9.3 の新機能と変更点
PDF
The world without float literal
PDF
The world without the literal notation for floating-point numbers
PDF
Ruby 拡張モジュール入門
PDF
関数型プログラミングの世界
PDF
Introduction to ATDD with Cucumber and RSpec
PDF
Float is Legacy
Ruby 1.9.3 の新機能と変更点
The world without float literal
The world without the literal notation for floating-point numbers
Ruby 拡張モジュール入門
関数型プログラミングの世界
Introduction to ATDD with Cucumber and RSpec
Float is Legacy
Ad

Similar to Let's begin Behavior Driven Development using RSpec (20)

KEY
Tdd for BT E2E test community
KEY
Test First Teaching
PDF
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
KEY
Test First Teaching and the path to TDD
KEY
あたかも自然言語を書くようにコーディングしてみる
PDF
D Is For Driven
PPT
Behaviour-Driven Development
PDF
Perl Testing Consideration (seen from other languages)
PPTX
Intro to TDD and BDD
PDF
Beyond Testing: Specs and Behavior Driven Development
PDF
Sustainable TDD
PDF
The hitchhicker’s guide to unit testing
PPT
Growing software from examples
PDF
TDD, BDD and mocks
KEY
Advanced Testing on RubyEnRails '09
PDF
BDD style Unit Testing
PDF
Drools Introduction
PDF
Introduction to unit testing
PDF
Achieving Zero Defect with Agile Methods BugDay Bangkok 2012 โดย Varokas Pan...
PPTX
Test Driven Development: Why I hate it; but secretly love it.
Tdd for BT E2E test community
Test First Teaching
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
Test First Teaching and the path to TDD
あたかも自然言語を書くようにコーディングしてみる
D Is For Driven
Behaviour-Driven Development
Perl Testing Consideration (seen from other languages)
Intro to TDD and BDD
Beyond Testing: Specs and Behavior Driven Development
Sustainable TDD
The hitchhicker’s guide to unit testing
Growing software from examples
TDD, BDD and mocks
Advanced Testing on RubyEnRails '09
BDD style Unit Testing
Drools Introduction
Introduction to unit testing
Achieving Zero Defect with Agile Methods BugDay Bangkok 2012 โดย Varokas Pan...
Test Driven Development: Why I hate it; but secretly love it.
Ad

More from Kenta Murata (12)

PDF
Rubyをたのしくするために私が考えていること
PDF
Ruby の懸案事項
PDF
5分弱で分かる量子ビット
PDF
Rubykaigi2010mrkn bigdecimal
PDF
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
PDF
校内勉強会のススメ An encouragement to hold workshops In your school
PDF
Ruby の標準乱数生成器とその改善案
PDF
5分で分かる Measure
PDF
Measure 単位付き数値ライブラリ
PDF
情報学特論#02
PDF
情報学特論#01
PDF
北海道関数型言語勉強会@札幌#2のお知らせ
Rubyをたのしくするために私が考えていること
Ruby の懸案事項
5分弱で分かる量子ビット
Rubykaigi2010mrkn bigdecimal
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
校内勉強会のススメ An encouragement to hold workshops In your school
Ruby の標準乱数生成器とその改善案
5分で分かる Measure
Measure 単位付き数値ライブラリ
情報学特論#02
情報学特論#01
北海道関数型言語勉強会@札幌#2のお知らせ

Let's begin Behavior Driven Development using RSpec