This is a little more mocking and solid than I prefer, but you can do it:
subjects = [...] desc_mock = double("desc order mock") desc_mock.should_receive(:desc).with(:created_at).and_return(subjects) conditions = {...} Subject.should_receive(:all).with(conditions).and_return(desc_mock)
You can also simplify this by moving the request to a named object that accepts some parameters. Then your test can confirm that the object received your area with the correct parameters, for example:
Subject.should_receive(:user_company).with(current_user.id).and_return(subjects)
source share