Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD Spree

TDD Spree

SpreeConf 2013 DC with true title: "Component Based, Outside In, Spree Development using Behavior-, Test- and Documentation Driven development."

Peter Berkenbosch

May 20, 2013
Tweet

More Decks by Peter Berkenbosch

Other Decks in Programming

Transcript

  1. TDD Spree SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  2. Component Based, Outside In, Spree Development using Behavior-, Test- and

    Documentation Driven development. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  3. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    Component Based. Ruby Host App Rails Spree component Models component component Views Controllers Assets Overrides Monday, May 20, 13
  4. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    Ruby Host App Rails Spree component Models component component Views Controllers Assets Overrides Outside In Monday, May 20, 13
  5. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    Ruby Host App Rails Spree component Models component component Views Controllers Assets Overrides Outside In Monday, May 20, 13
  6. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    Ruby Host App Rails Spree component Models component component Views Controllers Assets Overrides Outside In Monday, May 20, 13
  7. Behavior & Test Driven Development. SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  8. Documentation Driven Development. SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  9. What to test? SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  10. Test agains the “interface” SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  11. Do NOT test component implementation sample: don’t test you can

    find a record by an id SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  12. Spree App Structure SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Ruby Host App Rails Spree component Models component component Views Controllers Assets Overrides Monday, May 20, 13
  13. Host App SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  14. e Glue SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  15. Spree extensions FTW! SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  16. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    Component Models Views Controllers Assets Overrides Rails::Engine Spree Rails::Engine + Spree Monday, May 20, 13
  17. Sample SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch *

    www.peterberkenbosch.nl Monday, May 20, 13
  18. Tools SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch *

    www.peterberkenbosch.nl Monday, May 20, 13
  19. Usual Suspects rspec capybara factory_girl SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  20. Change the homepage SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  21. Write spec on Host App SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Ruby Host App Rails Spree component Models component component Controllers Assets Overrides Views Host APP Monday, May 20, 13
  22. Write spec on Host App SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Ruby Host App Rails Spree component Models component component Controllers Assets Overrides feature spec Views Host APP Monday, May 20, 13
  23. Spree Testing Support -> Factories SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  24. Add factory_girl SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  25. gem 'factory_girl', '~> 2.6.4' require 'ffaker' config.include FactoryGirl::Syntax::Methods require 'spree/core/testing_support/factories'

    Gemfile spec_helper.rb SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  26. Outside In -> Create Component SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Ruby Host App Rails Spree component Models component component Views Controllers Assets Overrides Monday, May 20, 13
  27. bundle exec spree extension homepage SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  28. bundle exec rake test_app SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  29. Start with feature spec SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  30. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    Component Models Views Controllers Assets Overrides Rails::Engine Spree spree_homepage Monday, May 20, 13
  31. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    Component Models Views Controllers Assets Overrides Rails::Engine Spree feature spec spree_homepage Monday, May 20, 13
  32. Deface Override SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  33. X-Ray Gem! SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  34. Outside In -> Model SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  35. Decorator SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch *

    www.peterberkenbosch.nl Monday, May 20, 13
  36. Unit test model? SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  37. Not yet SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  38. Add migration to extension. SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  39. be rails g migration AddFeaturedToSpreeProducts featured:boolean SpreeConf DC 2013 *

    Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  40. bundle exec rake test_app SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  41. SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl

    gem “spree_homepage”, path: “.” Gemfile Monday, May 20, 13
  42. Where to fix?? SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  43. 1) In the Component SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  44. 2) In the Host App SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  45. Choice: 1 -> Component SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  46. Looks familiar? SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  47. Refactor Host App Spec SpreeConf DC 2013 * Peter Berkenbosch

    * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  48. Add Deface Override SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  49. All green! Done. SpreeConf DC 2013 * Peter Berkenbosch *

    @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  50. API Extensions SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch

    * www.peterberkenbosch.nl Monday, May 20, 13
  51. Implement frontend on Host App SpreeConf DC 2013 * Peter

    Berkenbosch * @pberkenbosch * www.peterberkenbosch.nl Monday, May 20, 13
  52. Questions? SpreeConf DC 2013 * Peter Berkenbosch * @pberkenbosch *

    www.peterberkenbosch.nl Monday, May 20, 13