Skip to content

BoltSpec {allow,expect}_plan to check a *real* plan signature also #46

@jay7x

Description

@jay7x

Use Case

When testing a plan with execution disabled, if there is any mocked/stubbed sub-plan call, then it's accepted as-is without checking the real plan signature.

E.g. let's say we have plan example::foo (TargetSpec $targets, Hash $options) { ... }, which is called from a plan under tests now.

So we have it mocked like this:

expect_plan('example::foo').with_params('targets' => targets, options => options)

Then, few month latest our coworker has changed this plan signature to (TargetSpec $targets, String $description, Hash $options) for example. But he forgot to update our current plan we're testing.

In ideal world, our tests should fail now, because there is no plan with the signature we're mocking. Though, in BoltSpec there is no such check. So our tests will be fine as long as what we call in the plan matches what we mocked in the test.

Describe the Solution You Would Like

I'd like to have {expect,allow}_plan to check the real plan signature when mock/stub object is created (actually, IIRC, it's just an entry in a Hash, not an object, but nvm).

Describe Alternatives You've Considered

We tried discipline, but it fails frequently 🤣

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