Skip to content

Complex Hash Expectations in RSpec

When spec-ing something that calls method which takes a set of nested hashes (as many Rails methods do), it may be tempting to use #hash_including to test for only the values you care about. However #hash_including won’t work the way we might hope for nested hashes. Take the following (highly contrived) example:

describe CoffeeMaker […]

Testing Private Methods

Periodically the question of how to test private methods comes up at work or online. My answer is: don’t. It may seem trite, but there is some reasoning behind it.

Private methods are, by definition, implementation details. If you are approaching your tests from a behavioral standpoint – and you really should be, […]