[rspec-users] Assumption tests
work at ashleymoran.me.uk
Sat Oct 20 10:01:56 EDT 2007
On Oct 20, 2007, at 5:34 am, Scott Taylor wrote:
> As I see it, the problem is that ActiveRecord is not like a typical
> library, which is completely external. With rails,
> ActiveRecord::Base (and co) *become* your code.
Surely the implication is that the only way to thoroughly spec an
ActiveRecord::Base subclass would be to have shared specs available
for the full behaviour of Base and it_should_behave_like them into
your own specs? As it happens, I use very little inheritance so
possibly there is a better way to handle this.
> Of course, if you wanted to split up your specs into specs/, stories/
> and assumptions/, you would certainly be free to.
I have used assumption specs before, to test things in Rails views
that were not mockable, but I put them immediately before the specs
on my modifications. They are there to flag the thing that needs
fixing. If I felt the need to have an assumption spec folder, I'd
start feeling like there was something fundamentally wrong that
needed a more decisive solution, like switching to a new framework...
> Following up on the last idea: One thing that I don't think is yet
> widely understood is that there is no such thing as a "unit" or
> "integration" test - test happen on a continuum (the classification
> of a test is not a black and white sort of thing).
I'm glad someone said that. For a couple of months now I've been
struggling to define "unit test" and "integration test". I realised
not long ago that to thoroughly test an app with a reasonably complex
object model could easily have 5-10 layers of testing. Each one
would extend the black box from individual objects and messages,
right up firing it off on the command line / web server / whatever
and testing the output. Most of these would be brittle and semi-
redundant, but they would tell you *exactly* where your app was going
blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ home
More information about the rspec-users