Linearly dependant Rspec 'behavior'

December 31, 2014
rspec ruby

The problem: You finish writing your test in rspec, and after you have carefully described the scenario, you go to write your next test. For your next test you need to check that after you do everything for the first test, the next thing doesn’t break.

Potential hacks:

a) Well, it is just this one time, I can ignore the description of the spec and just throw in another assertion after my test.

While you’re at it, why don’t you just do everything in one test, I’m sure you’ll be able to figure it out when it fails.

b) There isn’t that much setup, I can just do the same thing I did in the last test as setup!

Lets pretend we don’t care about performance, I hope we can guarantee that the first test won’t change and that the setup state of the second test won’t get out of touch with reality!

But wait, there’s another solutions…

There you are waisting time, money, and CPU cycles wishing three was a better way. Well, thanks to my coworker Alex there is.

Contextualizing with DSLs

December 19, 2014
dsl ruby thoughts

Use your YAML fixtures as documentation

December 10, 2014
yaml documentation ruby
comments powered by Disqus