Lucian Ghinda Profile picture
Aug 22 7 tweets 2 min read Read on X
So let's talk about #testing and #Ruby and specifically about test design.

I think this could be a good conversation to sparkle so I am going to start sharing more about what I think about testing with some focus on Ruby and Ruby on Rails.

I will start with testing guidelines
I think it is important when speaking about tests to think about 3 situations a developer can be when dealing with tests:

1️⃣ Verify requirements/document how it works

That is when writing the feature code and want to verify either (a) requirements and/or (b) document how it works.
2️⃣ When changing the existing logic
When you have a change request and you have to change the code and adapt the tests.

3️⃣ When debugging
When time passes, and you have a bug and want to fix it. The details of both the code and test are fuzzy and there can be time pressure
Taking these in consideration when thinking about a set of rules for writing tests, I would recommend to keep in mind the following:

Choose rules that will help with all situations but the importance is:
First make debugging easy
Then make changing easy
Then make verifying requirements easy
When writing the code for the feature, you have all the context loaded in your head.

You might work for a couple of days on that, so it does not seem to matter how you name your tests, where you place the preconditions, or how you set up the system's state.
The risk is that you will try to write smart code in tests and DRY them out.

You should think about how you organise your tests so that when you read one single test, it should be easy to understand.
Optimise for the case where you are trying to grep and find the test that is executing a behavior you are debugging. Or you are just seeing a test fail after fixing a bug and so you are opening that file to the line where that test is and you try to understand it.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Lucian Ghinda

Lucian Ghinda Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @lucianghinda

Aug 9, 2023
Ruby is on the rise according to the Stack Overflow Developer Survey 2023! Here are some insights I extracted from survey results:
In the Most Popular Technology section, Ruby's adoption has grown to 6.23% in 2023, up from 6.05% in 2022. For professional developers, it's even higher at 6.94%
However, for those learning to code, Ruby adoption is slower, at 2.55% in 2023, only slightly up from 2.52% in 2022. The good news is that more beginner-friendly content is being created.
Read 9 tweets
Sep 7, 2022
Here is a simple and opinionated way to learn Ruby

I think learning Ruby has three parts:

1. Ruby Syntax
2. OOP + SOLID in Ruby
3. Idiomatic Ruby

What follows assumes you already know how to program in any other programming language.
1. Ruby Syntax:
First, read a bit about the Ruby syntax. You can find a short introduction to Ruby. (shameless plug) I tried to collect a lot of resources here, but you can also find some resources here. Do some small exercises if you feel like it just to get the syntax.
2. Watch some videos of Sandi Metz.
I recommend starting with SOLID Object-Oriented Design by Sandi Metz:

Some things might make sense, some not.
No worries, this is just a kind of preparation for your thinking process about how to code in Ruby.
Read 20 tweets
Aug 22, 2022
I created the sixth issue of the @shortrubynews #shortruby

Read the entire issue here: newsletter.shortruby.com/p/issue-6-2022

So here is what happened in #Ruby on Twitter last week
@shortrubynews @justalever @chalmagean shared some topics that a junior developer should focus on along with learning the language or framework:
Read 52 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(