[Rspec-devel] rails_plugin_fix merged to trunk

James Mead jamesmead44 at gmail.com
Tue Aug 1 07:22:05 EDT 2006

On 7/31/06, David Chelimsky <dchelimsky at gmail.com> wrote:
> I want isolated tests for controllers. That's actually why I'm working
> on the mock framework - to support an acts_as_mock plugin that lets
> you stub out class level methods like new and find. That way
> controller specs can avoid the database entirely and specs for model
> stuff (like validation) can live in the model where it is implemented.

Hi David. I really like what you guys are doing with RSpec. I was
wondering if you'd seen Stubba (http://mocha.rubyforge.org). It allows
you to stub class methods like :new and :find and avoid hitting the
database. Here's a trivial example...

def test_should_find_expected_product
  expected_product = Product.new
  assert_equal expected_product, Product.find(123)

- The Product class reverts to its original behaviour after each test.
- You can specify different return values in different tests.
- The test is explicit, because the return value is defined in the test.

We're using it on Rails projects at Reevoo.


More information about the Rspec-devel mailing list