Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TDD for Rails devs. The long story.
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Volodya Sveredyuk
July 30, 2019
Programming
74
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TDD for Rails devs. The long story.
Volodya Sveredyuk
July 30, 2019
More Decks by Volodya Sveredyuk
See All by Volodya Sveredyuk
AxR - architecture approach for the best ruby programs
sveredyuk
0
7
Other Decks in Programming
See All in Programming
ActionController meets Protocol Buffers
sorah
0
520
気持ちぃ〜角丸 Squircle
ryu1013
0
310
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
180
Event is what happens
moro
2
770
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
180
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
300
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.2k
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
110
ChromeでローカルLLM
ryu1013
0
140
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
How to Talk to Developers About Accessibility
jct
2
580
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Building AI with AI
inesmontani
PRO
1
1.3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
How to Ace a Technical Interview
jacobian
280
24k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
Transcript
VOLODYA SVEREYUK Lviv #pivorak Ruby dev
None
None
None
None
TDD FOR RAILS DEVELOPER
None
Test-driven development (TDD) is a software development process that relies
on the - repetition of a very short development cycle: • Requirements are turned into very specific test cases • Then the software is improved to pass the new tests, only
Kent Back rediscovered 2003
1. Add a test 2. Write a code 3. Run
tests 4. Refactor code 5. Repeat 3-4 WTF is TDD ?
WHY WE NEED TESTS ?
1. Test it's also a code 2. Costs time (money)
3. Slow down delivery 4. Hard. Need to know how to 5. Painful hotfixes or workarounds We don't need tests
Simple code
Naive refactoring
Only tests can save you
Bloody screen
Good test suite - safety sleeping
RED GREEN REFACTOR
RSPEC
RSpec • http://rspec.info/ • Describe • Context • IT (expect)
Cost time No test for 1st time: Write a code
- 10 min Check - 5 min Deliver With test for 1st time: Write a test - 10 min Write a code - 10 min Deliver VS.
Cost time Write code for N time: Write a code
- 10 min Check - 5 min Check dependent code - N x 5 min Deliver
Slow down delivery
HARD • You fight with syntax • You don't know
API • You don't know how to test • You don't know what to test • You are a lazy ass
I don't fu#king care
1. Tests are always part of the development 2. Never
tests should be extracted into separate task or estimation Remember !
HOW 1. Setup ENV 2. Configure ENV 3. Just do
it! https://github.com/rspec/rspec-rails
WHAT 1. Every single class 2. Every public method 3.
Every single endpoint 4. Every single workflow 5. Edge cases
NOT 1. Internet (HTTP) 2. Libraries 3. Framework / Language
TEST UNIT INTEGRATION ACCEPTANCE
USER
TEAM
TEAM
UNIT?
UNIT!
REAL UNIT TEST
NEW GREAT FEATURE!
BDD
None
And one more stupid example
STUPID EXAMPLE
STUPID DB INSERT
YOU DON’T NEED A DB !
2 UNITS 0 INTEGRATION
INTEGRATION ACCEPTANCE UNIT UNIT UNIT UNIT INTEGRATION UNIT UNIT Test
architecture
ATTENTION! REAL WORLD EXAMPLES !!1
SERVICE SPEC
ACCEPTANCE
REST API
https://github.com/brooklynDev/airborne
None
https://github.com/zipmark/rspec_api_documentation
None
GRAPHQL API
https://github.com/vcr/vcr
VCR.use_casette
https://github.com/guard/guard-rspec
None
None
None
https://github.com/colszowka/simplecov
None
spec_helper.rb
Focus
rspec —profile
CI / CD
GOOD TESTS SHOULD BE 1. Easy to write 2. Easy
to read 3. Reliable (coverage >95%) 4. Fast 5. Truly unit, not integration
BAD TESTS CAN BE 1. Mess 2. DB data sets
3. Random fails 4. Slow 5. Coupled
NEVER ASK PERMISSIONS FOR WRITE TESTS 1
YOUR TEST SUITE IS YOUR SAFETY BELT 2
BAD TESTS BETTER THAN THEIR ABSENCE 3
FOR BAD CODE YOU CAN'T WRITE GOOD TEST 4
IF YOUR TEST LOOKS LIKE A S#!T YOUR CODE IS
A S#!T 5
Questions !
t.me/svcast