#106 new
bahuvrihi

add class-level prompt inputs to SubsetMethods

Reported by bahuvrihi | September 13th, 2008 @ 09:04 AM | in Tap-1.0.0

This is a sketch of the required code (ie old cruft lying around):


# Passes conditions to subclass
def inherited(subclass) # :nodoc:
  super
  subclass_conditions = conditions.inject({}) do |memo, (key, value)|
    memo.update(key => (value.dup rescue value))
  end
  subclass.instance_variable_set(:@conditions, subclass_conditions)
  subclass.instance_variable_set(:@run_test_suite, nil)
  subclass.instance_variable_set(:@skip_messages, [])
  subclass_inputs = prompt_inputs.inject({}) do |memo, (key, value)|
    memo.update(key => (value.dup rescue value))
  end
  subclass.instance_variable_set("@prompt_inputs", subclass_inputs)
end

# Experimental -- The idea is to provide a way to prompt once for inputs
# that get used multiple times in a test.  Perhaps create accessors
# automatically?

def prompt_inputs
  @prompt_inputs ||= {}
end

def require_inputs(*keys, &block)
  if run_subset?("PROMPT")
    puts "\n#{name} requires inputs -- Enter values or 'skip'."

    argv = ARGV.dup
    begin
      ARGV.clear
      keys.collect do |key|
        print "#{key}: "
        value = gets.strip
        if value =~ /skip/i
          skip_test "missing inputs"
          break
        end
        prompt_inputs[key] = value
      end
    ensure
      ARGV.clear
      ARGV.concat(argv)
    end
  else
    skip_test "prompt test"
  end
end

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

A framework for making configurable, file-based tasks and workflows.

People watching this ticket

Tags

Pages