Module: RSpec::Variants::ExampleGroupMethods

Included in:
Core::ExampleGroup
Defined in:
lib/rspec/variants.rb

Defined Under Namespace

Classes: Condition

Instance Method Summary collapse

Instance Method Details

#data_condition(*args, &block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/rspec/variants.rb', line 19

def data_condition(*args, &block)
  if args.size == 1 && args[0].instance_of?(Hash)
    params = args[0]
    first, *remaining = params.values

    set_conditions(params.keys) { first.product(*remaining) }
  else
    set_conditions(args, &block)
  end
end

#test_condition(*args, &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rspec/variants.rb', line 30

def test_condition(*args, &block)
  opts = args.last.is_a?(Hash) ? args.pop : {}
  opts[:caller] = caller unless opts[:caller]
  args.push(opts)

  if @condition.nil?
    @conditions_pending_cases ||= []
    @conditions_pending_cases << [args, block]
  else
    define_cases(@condition, *args, &block)
  end
end