I currently have a base class and 2 subclasses. I'm struggling with finding the best way to test them. This is the current situation.

The base class is called AbstractServer. It's not really abstract because it can be instantiated and used, but some important methods are defined as no-ops, and are meant to be overrided by child classes. The spec for AbstractServer looks like:

  describe AbstractServer do
    it_should_behave_like "AbstractServer-like behavior"

    ... AbstractServer tests ...
  end

For the child classes, their specs look like this:

  describe ApplicationSpawner do
    it_should_behave_like "AbstractServer-like behavior"

    ... ApplicationSpawner-specific tests ...
  end

  describe FrameworkSpawner do
    it_should_behave_like "AbstractServer-like behavior"

    ... FrameworkSpawner-specific tests ...
  end

However, this looks very ugly. 'it_should_behave_like "AbstractServer-like behavior"' doesn't read like a normal sentence, and saying that AbstractServer has AbstractServer-like behavior is redundant.

What's the best way to solve this? What are good practices for testing inherited behavior? Should I be testing my child classes for parent class behavior at all? Right now I'm doing it anyway in order to detect bugs that I might have missed otherwise.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to