Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Agree with DHH?

Slide 3

Slide 3 text

This may be the wrong place

Slide 4

Slide 4 text

I may be an! Architecture ! Astronaut

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

We’re Making a Blog!

Slide 7

Slide 7 text

Patterns

Slide 8

Slide 8 text

Tests

Slide 9

Slide 9 text

Service Objects

Slide 10

Slide 10 text

Form Objects

Slide 11

Slide 11 text

Repository

Slide 12

Slide 12 text

Chassis

Slide 13

Slide 13 text

ActiveRecord

Slide 14

Slide 14 text

ActionPack

Slide 15

Slide 15 text

Go

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Step 10: pulls/10 • Time to think in HTML • Use capybara to create failing tests and submits a form and then displays the post

Slide 26

Slide 26 text

Step 11: pulls/11 • Make it green

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

Step 13: pulls/13 • Persistence with ActiveRecord