Module: Thoreau::DSL::Context::Clan

Included in:
Thoreau::DSL, TestCases
Defined in:
lib/thoreau/dsl/context/clan.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.def_family_methods_for(sym) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/thoreau/dsl/context/clan.rb', line 38

def self.def_family_methods_for(sym)
  define_method sym do |*args|
    desc = args.shift if args.size > 1 && args.first.is_a?(String)
    raise "Too many arguments to #{sym}!" if args.size > 1

    spec = args.first&.stringify_keys || {}
    spec.keys
        .reject { |k| ALL_PROPS.include? k }
        .each do |k|
      suggestions = PROPS_SPELL_CHECKER.correct(k)
      logger.error "Ignoring unrecognized property '#{k}'."
      logger.info "    Did you mean #{suggestions.to_sentence}?" if suggestions.size > 0
      logger.info "    Available properties: #{ALL_PROPS.to_sentence}"
    end

    params = HashUtil.normalize_props(spec.symbolize_keys, PROPS).tap { |props|
      # These two props are easier to deal with downstream as empty arrays
      props[:input_specs] = [props[:input_specs]].flatten.compact
      props[:setups]      = [props[:setups]].flatten.compact
    }.merge kind: sym,
            desc: desc

    family = Model::TestFamily.new **params

    yield family if block_given?

    logger.debug "   * Created new family #{params.inspect}"
    @test_clan_model.add_test_family family
  end

  define_method "#{sym}!" do |*args|
    family       = self.send(sym, *args)
    family.focus = true
    family
  end
end

Instance Method Details

#action(&block) ⇒ Object Also known as: act, testing, subject

Note: requires ‘@test_clan_model`.



29
30
31
32
# File 'lib/thoreau/dsl/context/clan.rb', line 29

def action(&block)
  logger.debug "   + Adding subject block"
  @test_clan_model.action_block = block
end

#expanded(a) ⇒ Object



90
91
92
# File 'lib/thoreau/dsl/context/clan.rb', line 90

def expanded(a)
  Thoreau::DSL::Expanded.new(a)
end