[rspec-users] Easy AR association stubbing
lists at artofmission.com
Fri Oct 26 10:10:26 EDT 2007
On 10/5/07, Andrew WC Brown <omen.king at gmail.com> wrote:
> I've added a method to the mock class that makes it pretty easy to
> stub associations in rails. I've been using it for awhile and it seems
> to cut down on a lot of setup code for the controller and model specs
> that use associations.
Thanks for this tip. I tried refactoring my subdomain as account keys
004157.html) with stub_association!, but am having some trouble.
Here's my setup method:
@request.host = "subdomain.test.host"
@item = mock_model(Item)
@current_company = mock_model(Company)
@current_company.stub_association!(:items, :find => [@item])
it "should find the item requested" do
... fails with:
Mock 'Company_1005' expected :find with ("1") once, but received it 0
I'm using subdomains as account keys, as in my code example here:
- Ryan Heneise
More information about the rspec-users