Module: RSpec::Determinator::DSL

Defined in:
lib/rspec/determinator.rb

Instance Method Summary collapse

Instance Method Details

#forced_determination(name, outcome, only_for: {}) ⇒ Object

Ensure that for the duration of the example all determinations made for the given experiment or feature flag will have the given outcome (but only if the constraints specified are met exactly).

If outcome or only_for are Symbols then the example-scoped variable of that name will be referenced (ie. those variables created by let declarations)



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rspec/determinator.rb', line 24

def forced_determination(name, outcome, only_for: {})
  before do
    outcome = send(outcome) if outcome.is_a?(Symbol)
    only_for = send(only_for) if only_for.is_a?(Symbol)

    fake_determinator.mock_result(
      name,
      outcome,
      only_for: only_for
    )
  end
end