$30 off During Our Annual Pro Sale. View Details »

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.

Adam Hawkins

April 24, 2014
Tweet

More Decks by Adam Hawkins

Other Decks in Programming

Transcript

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

    View Slide

  2. Agree with
    DHH?

    View Slide

  3. This may be
    the wrong place

    View Slide

  4. I may be an!
    Architecture !
    Astronaut

    View Slide

  5. View Slide

  6. We’re Making
    a Blog!

    View Slide

  7. Patterns

    View Slide

  8. Tests

    View Slide

  9. Service
    Objects

    View Slide

  10. Form Objects

    View Slide

  11. Repository

    View Slide

  12. Chassis

    View Slide

  13. ActiveRecord

    View Slide

  14. ActionPack

    View Slide

  15. Go

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  21. Step 6: pulls/6
    • Introduce a stub “PublishPost” service object
    • It should implement the interface in the acceptance
    tests
    • Don’t add functionality

    View Slide

  22. Step 7: pulls/7
    • Write that implementation
    • Hint: include Chassis::Persistence in Post

    View Slide

  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

    View Slide

  24. Step 9: pulls/9
    • Add Rails,
    • I’ll do this
    • Let’s talk about it

    View Slide

  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

    View Slide

  26. Step 11: pulls/11
    • Make it green

    View Slide

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

    View Slide

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

    View Slide