Complex rspec specs can intermittently fail in continuous integration

We use an external service to perform our full suite of unit and integration rspec tests on every push of changes to our revision control repository.

We’ve found that tests that pass locally end up failing or, even worse, intermittently failing (flap) when run by the Continuous Integration service.

This is often due to dependencies that are available locally but are not part of our project or correctly prepared for in our tests.

Another common reason is complex test code that becomes fragile in the context of the third party CI environment.

So, here are some things I look to clean up when I see a ‘flapping’ spec:

  • Use factories. Rather than update models after creating them change the factory to accept a transient attribute and modify or add dependent models in an after build or create block. In other words try not to persist to the database in code in the spec itself particularly if it is a feature spec.
  • Assign variables using let blocks rather than within tests or before blocks.
  • code>mkdir_p before writing files to tmp directories to ensure the directory will exist when you need it.
  • Create straightforward assertions. Have one expectation per test unless the runtime savings of combining a group into a single test clearly outweighs the complexity and potential fragility you’re introducing.

Most of these are best practice for rspec tests. As with many things in software, following a recommended pattern avoids unpleasant surprises because smart people have solved problems before you can stumble into them.

Before cleanup

After cleanup

Force bundler to rebuild your Ruby on Rails project gemset

I got myself into a bad place after migrating a Rails project to a newer version of Ruby where my gemset was built with the wrong native libraries (rbenv rehash?).

Resulting error when running rspec:

dyld: lazy symbol binding failed: Symbol not found: _rb_funcall2

I had to delete and rebuild my gems but bundler itself doesn’t offer a pristine option.

The easiest way I found was to temporarily remove all gems from my Gemfile so that my Gemfile looked like.

source ''

ruby '2.1.2'


bundle clean --force

Then undo and re-save my complete Gemfile and:

bundle install

Good to go.

Unintelligent design – the abuse of ‘inspect and adapt’ in Agile practice

Are you Agile if you don’t ____?

I just read an unpublished experience report. The report observes a team with over a year’s experience together within an organization that has several other Agile teams. Each team has a adopted different set of practices.

Specifically, this team followed Scrum with the following notable exceptions: 1) they didn’t contribute to the product vision because it is not the corporate culture 2) the team didn’t retrospect because they didn’t believe they had time.

The author then went on to conclude:

Customizing practices has allowed them to apply Agile in an effective way.

A conclusion I characterize as:

a) since the team has altered or omitted some Agile practices, and b) they consider themselves successful therefore c) the compromises were necessary and effective.

I will also note that all the adaptations described were compromises to the team’s Agile practice itself and the rationale for those adaptations was to fit into the existing corporate culture.

While the case study observes the team with some rigor, it leaps to three conclusions: that the team is effective, that the specific adaptations they note contribute to the team’s effectiveness, and that the examples are evidence of a successful Agile adoption.

I believe this is a pretty common take on Agile adoption, if not in words, in execution. And it is a fundamental misreading of the goals of continuous improvement in Agile practice.

Adaptation is both a tool for survival and optimization


When we strive after Agile software development, we encounter obstacles from outside our team, from team members and within ourselves. In the face of an obstacle we ask ourselves, “Can I remove it or do I move around it?” The pragmatic and necessary answer, may be to adjust our tactics, compromise our practices and move on.

Then, as our team becomes more adept some of the ceremonies may prove unnecessary as the values which those ceremonies re-enforce become ingrained as habits. And so, again, we relax our embrace of certain practices.

As we adapt our practices, we must regularly and skeptically inspect the assumptions behind those adaptations.

We must reflect on any claim that “we have to do ______” or “we don’t need to do ______”.

So, specific to the team the doesn’t hold retros, I have two lines of enquiry:

If they don’t have time to hold retrospectives but they believe they’re important then how are they going to make time?

If they don’t believe retrospectives are valuable enough for the time they take then what about their attempts are ineffective? Do they understand why retrospection is valuable? Do they know how to facilitate one? More profoundly, is something missing in their organization: low trust among the team, no authority to act on anything that arises, or lack of trust by management? These obstacles are worse than a simple lack of time management and will cripple the team’s collective ownership.

Even a necessary, pragmatic adaptation of the moment, if pursued un-reflectively will at some point hold a team back because it either protects and carries forward a dysfunction or encourages new ones to arise around it.

When reviewing your team’s practices ask yourself: have circumstances or people changed? Has the team earned enough trust, achieved enough success to take on a previously intractable obstacle? Is it the same team? Maybe it’s time to re-adopt or refresh? Have we gained wisdom or humility? Sometimes, we cannot grasp the value we unlock if we pursue a practice until it becomes a habit. It is our job to learn, to have courage, and to make that case both to our leaders and to our peers.

As Agile practitioners, we have to understand that adaptation requires contemplation and a larger perspective. We have to challenge both the immediate obstacle and the premise behind our own decision to avoid it. We have to revisit decisions over time. And we have to embrace a vision of what we are trying to achieve that is larger than the immediate problem.

My next post will go more into the last of those concerns. A vision of what Agile adoption is meant to achieve and what I see as the great danger of naive, unreflective adaptation of its practices — surrender to the cynical misuse of the development team…

Our weekly rhythm (iterations)


(Clock image by simpologist on Flickr)

Establishing a rhythm to our weeks and days has provided our team a sustainable pattern for predictably delivering work with quality. Our performance is an outcome of executing within this pattern repeatedly over time.

I learned the concept of a team rhythm from Jeff Sutherland and ours is a scrum and has the shape of a game: a short time frame (one week), an achievable goal that constitutes “winning”, alternating periods of focused team work with opportunities to regroup, strategize and rest.

Rolling Planning

Each day after stand up, as needed, the developers and product people have a 30-45 min. conversation to co-author, clarify, scope and estimate stories for next week. The narrative of the story is not as important as that we have discussed it as a group and that it has mutually understood acceptance criteria.

By Thursday, the product people have force ranked next week’s work reviewed the work and ranking with our sponsor, the Chief Digital Officer.

Do we need to estimate stories? That depends on whether the conversation over the estimate adds focus to the conversation over the scope and acceptance criteria of the story, surfaces risks, raises alternatives. It also depends on whether estimates affect when or whether a story is played or how it gets prioritized. It also depends on whether your team makes an iteration commitment.

We estimate.


On Monday morning, the team is ready to decide how far down that list of work we are confident we will complete this week. We usually start and complete additional work during the week but this is the floor.

Is the commitment necessary? It is a definitional practice in Scrum but the answer depends on whether anyone considers achieving the commitment a meaningful measure of success. It also depends on whether the conversation over what is or is not in that commitment will affect what the team is asked to work on and what gets delivered at the end of the week.

For us, the fact of a commitment helps maintain trust with our sponsor, the product people like the ability to make commitments to others with assurance we have their back, it helps the team work opportunistically on the backlog — to self-organize around the work and pull stories in a way they believe will lead to the best outcome that week while still having a reminder of which stories need to get done. So, we have a commitment.


As a department, we hold a a 30 min. showcase where the product team and two developers present the work we delivered the prior week. That bleeds into another 60 minutes of roadmap conversations which the developers are free to duck out of at their discretion depending on the relevance.

This showcase cycles in and out of being a meaningful exercise for the developers themselves but it continues to be a useful touchpoint with the rest of our department. Whether the developers find the following roadmap discussion useful is the degree to which they feel a need to get in sync with our department goals and how our work feeds into those goals. It also depends on how well that meeting addresses that need — which varies.


Having made our commitment for this week, we hold a 30 minute retrospective with the product people and developers. A developer usually facilitates.

This is one of the most important tasks in our week and yet it is also the one practice we control that needs most improvement. We need to do a better job and focusing in on root causes of both what is going well and what is not. We need to do a better job of identifying concrete things we should do in response. We need to do a better job of holding ourselves accountable for doing things and observing whether they actually help.


We deploy on Mondays. We do more as needed. We have a theoretical one touch deploy but the reality of our environment is Zombie Unicorns that sometimes wont die and so we are not yet at a point where we deploy without hesitation. We are working on our environment with our hosting provider to get past this.

Though the reality is, we find a balance point between frequency of deploys and branch management. A single weekly deployment has the advantage of allowing us a 1-2 day lag between QA’d and signed off without requiring us to maintain a rolling production deploy branch. We usually can simply deploy master. More frequent deploys would require either a more just in time sign off or a disciplined practice that connects sign off to which features are merged into/turned on in the deploy branch.


After Monday, each day follows a rhythm: morning standup with product (15 min.), the product planning time (30-45min.), morning pair session (2.5 hours), lunch and personal work time (1.5 hours), dev team check in (15min.), afternoon pair session (3.5 hours)

The afternoon check in is something the developers themselves started that functions as part standup, part opportunity to share something they learned that morning or a problem they ran into. It also is a second opportunity in the day to rotate pairs if it makes sense.


One of the downsides of a joint product/dev retro is that many of the issues the developers want to discuss aren’t relevant to the product team. So, the developers themselves started holding a Kaizen at the end of the week, while things are still fresh, to share and improve our development practices and code quality.

Because the Kaizen arose from the team itself and is more focused in scope, it tends to work better than our retros.


So, this is how our week falls out. It is what we as a group have arrived at over time and it is continually evolving. New obstacles or constraints may drive new practices. Practices that were a solution to a specific problem can remain like vestigial limbs long after the problem has ceased to exist and need to be discontinued.