Module: Rutema::Elements::Minimal
- Included in:
- Parsers::XML
- Defined in:
- lib/rutema/elements/minimal.rb
Overview
Module offering an example of a minimal set of elements for use as steps in test specifications
Instance Method Summary collapse
-
#element_command(step) ⇒ Object
command executes a shell command <command cmd="useful_command.exe with parameters", working_directory="some/directory"/>.
-
#element_echo(step) ⇒ Object
echo prints a message on the screen:
A meaningful message . -
#element_prompt(step) ⇒ Object
prompt asks the user a yes/no question.
Instance Method Details
#element_command(step) ⇒ Object
command executes a shell command <command cmd="useful_command.exe with parameters", working_directory="some/directory"/>
45 46 47 48 49 50 51 52 |
# File 'lib/rutema/elements/minimal.rb', line 45 def element_command(step) raise ParserError, "missing required attribute cmd in #{step}" unless step.has_cmd? wd = Dir.pwd wd = step.working_directory if step.has_working_directory? step.cmd = Patir::ShellCommand.new(:cmd => step.cmd, :working_directory => File.(wd)) return step end |
#element_echo(step) ⇒ Object
echo prints a message on the screen:
17 18 19 20 21 22 23 24 25 |
# File 'lib/rutema/elements/minimal.rb', line 17 def element_echo(step) step.cmd = Patir::RubyCommand.new("echo") do |cmd| cmd.error = "" cmd.output = step.text.to_s $stdout.puts(cmd.output) :success end return step end |
#element_prompt(step) ⇒ Object
prompt asks the user a yes/no question. Answering yes means the step is successful.
A prompt element automatically makes a specification "attended"
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rutema/elements/minimal.rb', line 31 def element_prompt(step) step.attended = true step.cmd = Patir::RubyCommand.new("prompt") do |cmd| cmd.output = "" cmd.error = "" raise "n" unless HighLine.new.agree(step.text.to_s) step.output = "y" end return step end |