>
> In rspec 3.2, we changed to
>     allow(User).to receive(:find_by_user_id_and_type).with(42,
> 'GREAT_USER').and_return(user)


This is not equivalent to what you had before. The equivalent of
`User.should_receive` in the new syntax is `expect(User).to receive`.
 `allow` is the equivalent of a stub.

As for the error you're getting: I believe it is related to verifying
doubles.  It is trying to validate that `find_by_user_id_and_type` is a
valid method -- but to verify that, the schema must be loaded to see if the
model has `user_id` and `type` fields.  If you don't want partial doubles
to have that kind of verification, you can turn it off with a config option:

https://www.relishapp.com/rspec/rspec-mocks/docs/verifying-doubles/partial-doubles

HTH,
Myron

On Tue, Feb 2, 2016 at 11:38 AM, Adam Perry-Pelletier <[email protected]
> wrote:

> In old RSpec, in a Rails Mountable Engine project with no database
> underneath. We have the following expectation set up.
>
>     User.should_receive(:find_by_user_id_and_type).with(42,
> 'GREAT_USER').and_return(user)
>
> The above worked fine.
>
> In rspec 3.2, we changed to
>
>     allow(User).to receive(:find_by_user_id_and_type).with(42,
> 'GREAT_USER').and_return(user)
>
> This now fails with the error:
>
>     ActiveRecord::StatementInvalid: Could not find table 'users'
>
> It appears in rspec 3.4 when the expectation is set up, rspec does try to
> load the ActiveRecord properties from the database. The old rspec did not
> do this. This allowed us to write rspec tests against a Rails Mountable
> Engine project without actually having to load and configure a test
> database. The database for this project is loaded and available in the main
> project which uses this subproject.
>
> Thanks in advance for any help.
> Adam
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/68e6bdcf-a228-45c4-bcd8-c12b1e31af1e%40googlegroups.com
> <https://groups.google.com/d/msgid/rspec/68e6bdcf-a228-45c4-bcd8-c12b1e31af1e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CADUxQmsG1nBVAem0eVA4TumuALAyiAM2_rWACVOzo-iBc7Wrcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to