In my last post on RSpec, I talked about cleaning up the stacktrace and
exception thrown by the specification that I'd written. It turns out that
this is all according to the design of RSpec, and the only way I'm going
to get things cleaned up is to write some code to make things work —
fortunately this is pretty easy to do. All we'll need to do is add a baz
method to our Foo class, like so:
def baz false end
Once we've done this, we're able to rerun our spec file, and everything
spec rspec_foo.rb .. Finished in 0.000429 seconds 1 context, 2 specifications, 0 failures
None of this really feels like I'm testing behavior though, it's all pretty much normal TDD style test code. I'm going to junk the whole thing, and see if I can't make a better go of it. Before I start though, it probably makes sense to understand why I'm looking at RSpec for checkr.
When Sean and I talked about BDD, he identified three things that he felt were more in line with his thinking:
- We're specifying behavior instead of state.
- Creating smaller units of specification increases the cohesion of tests while decreasing coupling between them.
- There's no link between program and test structure.