Benito Serna
Trying to build software that works
Spec by Spec
La técnica del "Memory Palace"

He estado leyendo un libro muy interesante que se llama, “A mind for numbers” de Barbara Oakley, Ph.D.

En el libro me topé con una técnica, muy interesante que le llaman “Memory Palace”, me llamó mucho la atención, porque la técnica esta realmente...

Read more
Intro to Active Record - The CRUD superpowers

Did you complete a Ruby on Rails tutorial, but want a more focused practice on Active Record?

Do you know other languages and frameworks and want to learn the basics of the magic on Active Record?

Read more

A decoupled CRUD on Rails

As I said in the last post as ruby/rails developers is very common to start our projects with something very similar to the Rails scaffold…

Read more

A decoupled CRUD example

For us, ruby/rails developers is very common to start our projects/apps with something very similar to the Rails scaffold….

Read more

Truncating multiple line text... (read-more behavior) with Stimulus.js

Are you looking for a way of implementing a read-more behavior but based on the number of lines instead of on the number of words?

Read more

Less code in your javascript sprinkles with Stimulus.js

If you are thinking in trying Stimulus.js in your project, maybe this little “before and after” can help you to decide.

Read more

Not using end-to-end tests in your TDD cycle

As I wrote in the previous article about using end-to-end tests in your TDD cycle… This kind of tests can be very helpful in some situations, and I think that is a good thing to try if it works for you and your current project.

Read more

Using end-to-end tests in your TDD cycle

Maybe you have always thought that TDD is about making unit/micro test first… And that is true for some people, other people feel more comfortable starting the cycle with an end-to-end test… And you could be one of them.

But sometimes is not very clear how to do it, because when you are doing TDD…

Read more

A tip for faster Rails Helpers Tests

If you are here, maybe it is because you also like fast tests!… I really like fast tests, and for that reason (and some others…) I always try to decouple my code from Rails and other frameworks…

Read more

Are you testing implementation details?

Have you had started a project trying to do TDD “the right way”, writing “unit tests” for every class and method, trying to hit that famous 100% coverage….

… And then few months later, rewriting many of them just for a little change or refactor!

Read more

Use mocks to design your dependencies when using TDD with a use case approach

Have you been in that situation when you are “mocking” something and you feel that you are not testing anything?

Read more

A guide to help you structure your test when using TDD with a use case approach.

I have already told you that organizing your code in use cases can help you to start your projects using TDD, and also I gave you a tip on how you can organize your app in use cases.

But even if you know what your code should do, is not so obvious how you should structure your tests…

Read more

A simple way to organize your app in use cases

I have already told you that organizing your code in use cases can help you to start your projects using TDD … And other people also recommend it for other purposes… You really should try it!

The problem is, that is not really obvious how to do it!…

Read more

How organizing your code in use cases can help you to start your projects using TDD

After reading a lot of questions and answers on TDD and unit testing, are you still struggling to find the answer to… Where to start from?…

Read more

How and when to use mock objects with ruby and rspec

Are you new to mock objects? Are you trying to learn how to use them? Are you looking for some “hello world” examples for Mock Objects?

Mock objects can be a really good tool sometimes, but not always. This is a guide, to help you learn how and when you can use them.

Read more

How to test that you are creating a record without using the database

Do you want to know how you can use a test double or mock to test the creation of a record? Are you looking for an example of using mocks?… Maybe this post can help you =)

Read more

How to test that an specific email was sent

There are different practices, that I know, to test that an email was sent in Rails…

Read more

How dependency injection saved me some hours of work

Do you want to know how dependency injection can help you and your team to actually doing less work?

I have an story for you…

Read more

Slow Tests?... How to remove the database from your tests and make them fast!

Is a common problem in a Rails app to have very slow test suites. There are a lot of test suites that need more than 10 or even 30 minutes to run!…

Is your app in this group?

Read more

The secret for Unit Testing on Rails

Maybe you or your team have decided to code “in the right way” and go hard on TDD and unit testing on your Rails app…

Read more

Writing unit tests as feature tests

Are you struggling trying to define what to test on your unit tests? Maybe is easier for you to identify what to test on your feature tests or system tests because the user story or approval criteria, in a certain way “tells you” what to test or what is expected to happen.

But with your unit tests is different…

Read more

A little template for testing record creation via unit test on your App

Do you struggle with understanding what to test and how to test it?… Maybe you know that “you need to test the behavior of your objects”, but of those behaviors, what do you test?, and how do you test it?… are you looking for some kind of simple steps or methodology to apply? a repeatable process?

Read more

Three different ways of testing your Rails App

Do you have problems deciding what to test or how to test you rails app? Don’t worry, this is a very common problem… I think that there are a lot of reasons why this is hard for many people, but I have found that one of the problems is that are many ways to do it.

Read more

Clean a controller action being explicit about the business rules

Imagine that you have the next controller action that works, but when you see it you feel that you can make it cleaner.

Read more

Unit Tests …. ¿Que es una unidad? ¿Puedo hacer un mock de una unidad?

Estas preguntas me vienen constantemente, y hoy fue una de esas veces… Estuve trabajando en construyendo una estructura de datos que debería tener información de varias fuentes de la aplicación.

Read more

5 Reglas para desacoplar tu aplicación de Rails y tener pruebas realmente rápidas

En los últimos proyectos que he trabajado, tanto solo como en equipo, poco a poco he ido descubriendo ciertas practicas o reglas que usamos y que quiero compartir porque creo que también te pueden servir.

Read more

Rails no es mi app…. pero ¿Que tanto debería delegar al modelo?

En esta idea de “Rails is not my app” es necesario definir cuales son las cosas que va hacer tu aplicación y cuales va a delegar.

Read more

Fast tests for apps that use Rails (slides)

This is are the slides of a presentation that I gave at the Ruby Meetup Monterrey, the last year.

Read more

Deciding who to invite to your wedding using ruby

Maybe some of you know that I am planning to get marry the next year. If not know you know =).

Read more

Testing functions with side effects in elixir (by a functional noob)

Talking about object oriented programming, Sandy Metz propose that when you are testing “outgoing messages with side effects” what you should do is just assert that the “outgoing message” has been sent. For example in ruby we can do something like…

Read more

Your first feature spec

Maybe you are in this transition to become a professional programmer (congrats!!) and you have seen that if you want to be “a professional programmer” you have to use TDD and test all your code.

Read more

Guía para empezar a usar Git

Esta es una pequeña guía aprenderas lo suficiente de git para integrarte a tu equipo de desarrollo.

Read more

A controller that knows less

I want to show you a way you can “draw a line” between your application “main logic” and your Rails controllers.

Read more

Thinking small programs

Lately I have been working with Abi in a way to separate the core of an application in small modules using rails just as a platform that uses those small modules/programs to build a real web application.

Read more

Building simpler models, using custom PORO validators

The validations of your ActiveRecord models look very convenient, because they are easy to use and have a pretty DSL. Use them is the “rails way” so you think that is what you must use. But…

Read more

Como hacer modelos más simples, usando validadores especializados.

Las validaciones de tus modelos de ActiveRecord parecieran muy convenientes, porque son muy fáciles de usar, tiene un DSL muy entendible y rails te las pone ahí a la mano para que las uses. Pero esto no dura para siempre.

Read more

Emberjs vs My frontend hacks - Actualizar Contadores

Aunque javascript no sea el lenguaje mas placentero para trabajar, hoy en día es necesario si queremos dar una agradable experiencia al utilizar una aplicación web.

Read more

Practicar, practicar, practicar

Recuerdo que de niño en la escuela de música mi maestro siempre mencionaba una frase de Arturo Sandoval (uno de los mejores trompetistas en la actualidad y de todos los tiempos) que decía: “Para tocar hay que tocar”. Siempre mencionaba esto para hacerme entender que la única forma de poder tocar bien un instrumento musical, es practicando.

Read more

(Refactor) Dynamic assignment with coffeescript

Today I was working in Commentator, a gem that was extracted from Aventones, and I had a problem trying to assign a lot of configuration, variables in a class.

Read more

User-centric Routing with Devise and Rails

Maybe there is a lot of people know this solution, but before today I didn’t know it, so I want to share this =).

Imagine that you want that the home page of your app for an authenticated user, to be a Dashboard with stadistics or something special, but you want to have an informative page for the people that is not authenticated.

Read more

Your API in your Views, using Jbuilder

When I initialize a Backbone or a Javascript app, in a Rails view, I like to populate the template with the records that I am going to need. This is because if I dont populate this records in the view, then I have to fetch the record in the javascript app, so I need another call to the server :(.

Read more

Refactoring my old cucumber tests

Like a year ago, my style to write cucumber test was to use the cucumber’s web steps, the most I can, and the results were some tests like this one.

Read more

Making a template handler with Markdown and ERb

What you need to have an object compliant with the handler API, is to respond to the call method which receives an instance of ActionView::Template and should return a string with valid Ruby code.

Read more

Are you also trying to write software that works?

Maybe you can join the newsletter and we can try together.