스프링노트팀 팀세미나 시간에 BDD에 대해 이야기하며 사용한 발표자료입니다.
URL
EMBED
Page 0:
Page 1: BDD
with
rspec & Cucumber
deepblue @ springnote
Page 2:  


http://toby.epril.com/?p=500
Page 3: http://www.flickr.com/photos/xollob58/528204122/
Page 4: 
Page 5: 


Page 6: 


Registration
register() registrations
.
Page 7: 




Page 8: 
Page 9:
Page 10:
Page 11:
Page 12: 


Page 13: 기능 
   
   
   
Page 14:               
      
    
Page 15:
Page 16: Given /^ end Given /^ end When /^ end Then /^ end Then /^ end Add
50 70
$/ do $/ do $/ do 120 Fixnum $/ do $/ do
Page 17:
Page 18: require 'spec/expectations' $:.unshift(File.dirname(__FILE__) + '/../../lib') require 'cucumber/formatters/unicode' require 'calculator' Before do @calc = Calculator.new end
Page 19:
Page 20: class Calculator end
Page 21: Given /^계산기에 (\d+)을 입력했다$/ do |n| @calc.push n.to_i end
Page 22:
Page 23: class Calculator def push(n) end end
Page 24: When /^내가 (\w+) 버튼을 누른다$/ do |cmd| @calc.send cmd.downcase.to_sym end
Page 25:
Page 26: class Calculator def push(n) end def add end end
Page 27: Then /^화면에 숫자 (\d+)이 출력될 것이다$/ do |n| @calc.last_result.should == n.to_i end Then /^출력된 값은 (\w+)이다$/ do |name| @calc.last_result.class.name.should == name end
Page 28:
Page 29: class Calculator attr_reader :last_result def push(n) end def add end end
Page 30:
Page 31: 

 




Page 32: 


Page 33: $:.unshift(File.dirname(__FILE__) + '/../lib') require 'calculator' describe Calculator do before do @calc = Calculator.new end it "처음에는 stack이 비어있다" do @calc.stack.should be_empty end end
Page 34:
Page 35: class Calculator attr_reader :last_result, :stack def initialize @stack = [] end def push(n) end def add end end
Page 36:
Page 37: it "stack에 숫자를 추가한다" do @calc.push(1) @calc.stack.last.should == 1 end
Page 38:
Page 39: class Calculator attr_reader :last_result, :stack def initialize @stack = [] end def push(n) @stack.push(n) end def add end end
Page 40: it "숫자 2개를 더해서 last_result에 저장한다" do @calc.should_receive(:top).with(2).and_return [3,4] @calc.add @cals.last_result.should == 3+4 end
Page 41:
Page 42: class Calculator attr_reader :last_result, :stack def initialize @stack = [] end def push(n) @stack.push(n) end def add @last_result = end end
top(2).inject{|sum, n| sum + n}
Page 43: it "stack의 숫자 2개를 반환한다" do @calc.should_receive(:stack).and_return [1,2,3,4] @calc.top(2).should == [3,4] end
Page 44:
Page 45: class Calculator attr_reader :last_result, :stack def initialize @stack = [] end def push(n) @stack.push(n) end def top(n) stack.slice!(-n, n) end def add
@last_result = top(2).inject{|sum, n| sum + n}
end end
Page 46:
Page 47:
Page 48: : . : 3 2 Divide 1.5 Float
Page 49: Then /^화면에 숫자 ([.\d]+)(이|가) 출력될 것이다$/ do |n,_| @calc.last_result.to_f.should == n.to_f end
Page 50:
Page 51: class Calculator attr_reader :last_result, :stack def initialize @stack = [] end def push(n) @stack.push(n) end def top(n) stack.slice!(-2, 2) end def add @last_result = top(2).inject{|sum, n| sum + n} end def divide end end
Page 52:
Page 53: it "숫자 2개를 나눠서 last_result에 저장한다" do @calc.should_receive(:top).with(2).and_return [3,2] @calc.divide @calc.last_result.should == 3.0/2.0 end
Page 54:
Page 55: class Calculator attr_reader :last_result, :stack def initialize @stack = [] end def push(n) @stack.push(n) end def top(n) stack.slice!(-2, 2) end def add @last_result = top(2).inject{|sum, n| sum + n} end def divide n1, n2 = top(2) @last_result = n1.to_f / n2.to_f end end
Page 56:
Page 57:
Page 58: 

Page 59:
Page 60:
Page 61:
Page 62: