O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

BDD for Rails Legacy Code

2.171 visualizações

Publicada em

Publicada em: Tecnologia
  • Seja o primeiro a comentar

BDD for Rails Legacy Code

  1. 1. BDD for Rails Legacy Code
  2. 2. About Me  Lu Wei Jen  Rails Developer  http://blog.weijen.net  http://www.facebook.com/ weijenlu  Twitter: weijenlu 
  3. 3. 10
  4. 4. 10
  5. 5. Legacy Code
  6. 6. Agenda • • BDD • BDD • Legacy Code • Legacy Code
  7. 7. • • • •
  8. 8. Changes Changes Changes Changes Changes Changes
  9. 9. BDD • Behavior Driven Development • •
  10. 10. BDD Tools for Rails • Cucumber • Webrat • RSpec
  11. 11. Cucumber • • •
  12. 12. Cucumber
  13. 13. Cucumber
  14. 14. Cucumber Mock Object
  15. 15. Webrat • • • • form •
  16. 16. Webrat: • visit "http://rubyconf.tw" • click_link " "
  17. 17. Webrat: Form • file_in " ", :with => "weijen" • check " " • select " ", :from => " " • click_button
  18. 18. Webrat: • response.should contain(" ") • response.should have_selector("img.photo")
  19. 19. RSpec
  20. 20. • • • • •
  21. 21. • • •
  22. 22. • Waybill model #set_customer • Waybills_controller #create
  23. 23. Model
  24. 24. Model
  25. 25. Mock Object • • • •
  26. 26. Mock Object • my_mock = mock(name) • my_mock = mock(name, stubs) • my_mock = mock_model(name, stubs)
  27. 27. • my_mock.stub!(:msg).with(args).and_return(value)
  28. 28. Message Expectation • my_mock.should_receive(:msg).with(args).and_r eturn(value)
  29. 29. Mock
  30. 30. Controller
  31. 31. Controller
  32. 32. Cucumber
  33. 33.
  34. 34. • +
  35. 35. • No Silver Bullet • •
  36. 36. Q &A

×