Skip to content

Verifying doubles with mock_model #25

@JasonBarnabe

Description

@JasonBarnabe

Verifying doubles allows you to ensure that you're not mocking up attributes and methods that don't exist on the mocked class.

rspec-activemodel-mocks should support verifying doubles when using mock_model. I was able to enable it by simply changing:

double("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m|

double("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m|

to

instance_double(model_class, stubs).tap do |m|

This works great for how I'm using this gem, but I suspect it might break things for other users, for example if mock_model was passed "A String representing a Class that does not exist" (?)

I would be happy to work on a PR if given some advice on how to proceed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions