Skip to content

Allow :no_op to be specified as an input value #4

Description

@acant

The idea being that for some scenarios we do not all the variables to be used. (e.g., a method which has several guard clauses which each check one or more inputs).

Given a method like this:

def method_under_set(input1, input2, input3)
  return unless is_valid(input1)
  return unless is_valid(input2)
  return unless is_valid(input3)

  input1 + input2 + input3
end

I might have a tabular spec like this:

inputs :input1, :input2, :input3
it_with :value1, nil, nil, nil
it_with :value1, :value2, nil, nil
it_with :value1, :value2, :value3, :result

But this does not clearly communicate that the inputs should not actually be used in the first 2 examples. It makes it hard to see which examples expect an actual nil.

So I would like to have:

inputs :input1, :input2, :input3
it_with :value1, :no_op, :no_op, nil
it_with :value1, :value2, :no_op, nil
it_with :value1, :value2, :value3, :result

The variable with the :no_op value could make use of the memoizing/let blocks in order to raise an assertion if the variable is called during the scenario. But that might be unnecessarily complex.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions