Left of the Dev

Articles tagged rspec

Replacing system tests with unit tests

Is your testing strategy too top-heavy? Here are some techniques to spread coverage down the testing pyramid. (June 01, 2024)

Notes from migrating from Minitest to RSpec, with help from GitHub Copilot

Artificial intelligence hasn't replaced us yet, but how does it handle the boring parts of our jobs? (March 13, 2024)

Write resilient tests with matchers that take other matchers

Here's a short, neat trick to help save time when updating RSpec specs to reflect new test data. (December 07, 2023)

Test-driven development in the age of artificial intelligence

How ChatGPT, GitHub Copilot, and TDD made me a professional Go programmer in less than an hour. Kind of. (June 26, 2023)

2 ways to test Rails log messages with RSpec

If you're like me and don't need to test log output on a regular basis, you may not find the solutions to be immediately obvious. Here are two ways (that I know of) to approach the problem. (August 10, 2020)

Work around flaky test failures in Rails with rspec-retry

Nobody likes an intermittently failing test. Here's one way to keep your test suite running green, even when a test sometimes fails. (June 08, 2020)

How to TDD when TDD is hard

Sometimes, TDD gets in the way, does more to confuse than guide, or generally just slows development to a monotonous crawl. Here's a set of five go-to strategies I use to get out of test-fueled frustration, and back to productivity. (July 09, 2019)

Rails test coverage: Measuring what matters with SimpleCov

Many developers strive for 100% test coverage in their Rails applications, but what does that mean? And does it matter? Here's how I use the wonderful SimpleCov to help guide my testing. (March 23, 2018)

Upgrading to RSpec 3.7.2 and system specs

Support for Rails 5.1 system testing is now available to RSpec fans like you and me. Here's how I moved my book's feature specs to system specs. (January 08, 2018)

Replacing RSpec controller tests, part 3: Removing business logic from controllers

Do you need yet another reason to move code out of controllers and into service (or whatever you want to call them) objects? How about better, forward-thinking testability? (November 20, 2017)

Replacing RSpec controller specs, part 2: Feature specs

In part two of a series on ditching controller specs, let's move a complicated controller example into a more reasonable, future-proof feature spec. (September 05, 2016)

Replacing RSpec controller specs, part 1: Request specs

Does your application's test suite rely heavily on controller specs? It's time to consider alternatives, as controller testing has changed in Rails 5. Here's one way to replace a common use of these specs, even if you haven't upgraded to Rails 5 yet. (August 29, 2016)

Using RSpec in Atom

I love how extensible GitHub's Atom editor is. Here are some useful packages for using it to edit and run RSpec tests. (August 27, 2015)

How do assigns and reload work in Rails tests?

Rails offers a couple of methods to access persisted test data, but how do they work? Let's get some answers, with the help of Pry. (April 05, 2015)

Switching from Selenium to Poltergeist in RSpec feature specs

A quick one, for readers of my RSpec book: Moving to a headless driver for faster JavaScript testing with Capybara. (January 27, 2015)

A great example of outside-in testing from Ruby Tapas

How do you turn testing knowledge into a testing habit? Learn from an expert. (January 15, 2014)

I wrote a view spec

When is it beneficial to include a view spec in your Rails app's test suite? Here's one example. (November 15, 2013)

Diary of a Rails rescue project, part 2: Testing

Notes on using tests to learn about legacy software. (April 16, 2013)

How I learned to test my Rails applications, Part 5: Request specs

Integration testing with RSpec request specs make sure your application's various parts are working in cohesion. Here's a primer on getting started. (April 24, 2012)

How I learned to test my Rails applications, Part 4: Controller specs

Controllers are the glue in a Rails application, and should be tested just like any other code. This primer will guide you to better coverage in your own apps' controllers. (April 07, 2012)

How I learned to test my Rails applications, Part 3: Model specs

How can you make sure your application's core building blocks are doing what you expect them to? Let's start by using RSpec to test model functionality. (March 19, 2012)

How I learned to test my Rails applications, Part 2: Setting up RSpec

Our series on getting comfortable with Rails testing continues as we set up RSpec for an existing application. (March 12, 2012)

How I learned to test my Rails applications, Part 1: Introduction

Are you still wrapping your head around Rails testing techniques? Here are the tools and techniques that helped me go from zero to decent test coverage. (March 12, 2012)

Test with confidence!

If you liked my series on practical advice for adding reliable tests to your Rails apps, check out the expanded ebook version. Lots of additional, exclusive content and a complete sample Rails application.

Newsletter

Software development news and tips, and other ideas and surprises from Aaron at Left of the Dev. Delivered to your inbox on no particular set schedule.