Module: RSpec::Core::MemoizedHelpers::ClassMethods

Defined in:
lib/junklet.rb

Instance Method Summary collapse

Instance Method Details

#junklet(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/junklet.rb', line 7

def junklet(*args)
  # TODO: figure out how to use this to wrap junk in junklet,
  # so that junklet can basically have all the same options as
  # junk does. E.g. junklet :ddid, :pcn, :group, type: :int,
  # min: 100000, max: 999999, etc, and you'd get back 3
  # junklets of 6-digit numbers.
  opts = args.size > 1 && !args.last.is_a?(Symbol) && args.pop || {}

  names = args.map(&:to_s)

  if opts.key?(:separator)
    names = names.map {|name| name.gsub(/_/, opts[:separator])}
  end

  args.zip(names).each do |arg, name|
    let(arg) { "#{name}-#{junk}" }
  end
end