[Rspec-devel] rails_plugin_fix merged to trunk
aslak.hellesoy at gmail.com
Tue Aug 1 08:13:16 EDT 2006
On 8/1/06, James Mead <jamesmead44 at gmail.com> wrote:
> 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.
Didn't we work together a couple of years ago? Or am I getting senile :-)
Anyway - Mocha/Stubba looks very interesting. I like the way it can
get rid of trips to the database. A couple of questions:
1) When you do Product.stubs(:find) - I would assume that this has a
sideeffect by forever changing the find class method? If that's so,
how do you avoid interdependencies between tests/specs? If I'm
mistaken - how does it *not* have a sideeffect?
2) Product.stubs(:find) use define_method or method_missing?
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
More information about the Rspec-devel