Casecommons/with_model — pull request #16 by amarshall (2013-12-12 03:02:09+00:00)
Title: Complete refactor

Thoughts @nertzy? This is what I was talking about today. Just opening the PR to get feedback, if any (I’ll take care of merging it). I kinda overhauled everything with these reasons/goals:

- `WithModel::Dsl` was playing the role of both DSL builder as well as constant stubber and model creator/destroyer. It was the crux of everything, and that’s no good.
- Extracting the calling of `before`/`after` as far out as possible in order to reduce coupling to the test runner.
- Extracting table creation out of `before`/`after`.
- Remove `stub_const` dependency so rspec-mocks is not required.
- Remove explicit dependency on RSpec.
- Reduce the complexity of `instance_exec`/`instance_eval`/`class_eval`s, removing entirely if possible.
- Probably other things I don’t remember now that I’m done.

The result is `WithModel::Model` & `WithModel::Table` do all the real work, with `WithModel` being the sole (thin) coupling to the test runner and `WithModel::Model::DSL` being the builder for `with_model` to `instance_exec`.

This also gives us a [4.0 GPA](https://codeclimate.com/github/Casecommons/with_model/compare/next).

(P.S. sorry about 45fea5d, but it’s simpler/clearer this way :worried:)