Skip to content

Add a with_no_args option for mocks #56

@robkinyon

Description

@robkinyon

Let's say I have a script that invokes a command twice as part of its execution, once with arguments and once without. Example:

#!/bin/bash

foo=$(my-script)
bar=$(my-script A)
echo "'$foo' '$bar'"

with a test of

let!(mocker) {
    stubbed_env.mock('my-script')
      .with_args('A').outputs('1')
      .with_no_args().outputs('2')
}
stdout,stderr,exitstatus = stubbed_env.execute(thing_under_test)
expect(stdout).to eql("'2' '1'")

Right now, there is no way to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions