[Rspec-devel] rails_plugin_fix merged to trunk

Luke Redpath luke at agileevolved.com
Tue Aug 1 07:37:03 EDT 2006


Hi James

Thanks for posting this - I can't believe I hadn't come across this  
before. For mocks, I'm pretty happy with the mocking built into   
rSpec (or FlexMock when I'm using Test::Unit) but I really like the  
look of Stubba - far more elegant than monkey patching existing  
classes with stub methods.

Cheers
Luke

On 1 Aug 2006, at 12:22, James Mead 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
>   Product.stubs(:find).returns(product)
>   assert_equal expected_product, Product.find(123)
> end
>
> - 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.
>
> James.
> http://blog.floehopper.org
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel



More information about the Rspec-devel mailing list