Applications First, Frameworks Second

Applications First, Frameworks Second

This is the short presentation before the start of my workshop at Railsconf 2014. The deck is short. It's just an introduction to the code found on github. https://github.com/ahawkins/applications-first-frameworks-second see https://github.com/ahawkins/applications-first-frameworks-second/pulls?direction=asc&page=1&sort=created&state=closed to work though the steps.

94378c403019af23a28b08447a34b8e0?s=128

Adam Hawkins

April 24, 2014
Tweet

Transcript

  1. Applications First,! Frameworks Second Railsconf 2014 Workshop by @adman65 https://github.com/ahawkins/applications-first-frameworks-second

    https://github.com/ahawkins/chassis
  2. Agree with DHH?

  3. This may be the wrong place

  4. I may be an! Architecture ! Astronaut

  5. None
  6. We’re Making a Blog!

  7. Patterns

  8. Tests

  9. Service Objects

  10. Form Objects

  11. Repository

  12. Chassis

  13. ActiveRecord

  14. ActionPack

  15. Go

  16. Step 1: pulls/1 • Make “bundle exec rake” run tests

    • Create a failing test to ensure things work correctly • git checkout feature/step-1 ; git checkout HEAD~2
  17. Step 2: pulls/2 • git checkout -b feature/step-1; git checkout

    -b my-step-2 • Create a failing acceptance/integration/system test • This test should create a “Post” with a “title” & “text” attributes • Test that this object is persisted some how • PublishPost — Service Object — instantiated with the form • PublishPostForm — models input — instantiated with a Hash • PostRepo — manages the Posts
  18. Step 3: pulls/3 • git checkout -b feature/step-2 • Write

    a unit test for the “Post” class • Test it can be initialized with a Hash • ruby test/post_test.rb
  19. Step 4: pulls/4 • git checkout -b feature/step-3 • Define

    “PublishPostForm” • Hint: use Chassis.form (see chassis readme) • Hint: nothing to test yet
  20. Step 5: pulls/5 • git checkout feature/step-4 • Create “PostRepo”

    • Use Chassis::Repo::Delegation • Refer to chassis README for an example • No tests needed for this one
  21. Step 6: pulls/6 • Introduce a stub “PublishPost” service object

    • It should implement the interface in the acceptance tests • Don’t add functionality
  22. Step 7: pulls/7 • Write that implementation • Hint: include

    Chassis::Persistence in Post
  23. Step 8: pulls/8 • Add another test case to the

    acceptance test that does not include a “text”/“title” • Make it pass! • Hint: add validation to the form • Chassis.repo.clear
  24. Step 9: pulls/9 • Add Rails, • I’ll do this

    • Let’s talk about it
  25. Step 10: pulls/10 • Time to think in HTML •

    Use capybara to create failing tests and submits a form and then displays the post
  26. Step 11: pulls/11 • Make it green

  27. Step 12: pulls/12 • Make UI handle validation errors

  28. Step 13: pulls/13 • Persistence with ActiveRecord