Class: Uttk::Strategies::Iterate

Inherits:
Collection show all
Includes:
Concrete, Composite::Ordered
Defined in:
lib/uttk/strategies/Iterate.rb

Overview

Iterate is a generic iteration strategy which bring the full power of Ruby to your test description.

The common use case is somthing like that:

my test:

strategy: Iterate
over:     aStructureWichSupportTheMethodMyEach
with:     TheMethodMyEach # `uttk_each' by default
iter:     MyIterator
test:
   my sub test <<MyIterator:i>>:
       strategy: AnotherStrategy
       argument: <<MyIterator>>

In the real life you can use it like that:

my test suite:

strategy: Iterator
over: !filelist **/(*).yml
iter: [path, basename]
test:
   my sub test <<basename>>:
      strategy: Import
      input:    <<path>>

Instance Attribute Summary

Attributes inherited from Strategy

#status

Instance Method Summary collapse

Methods included from Composite::Ordered

included

Methods inherited from Collection

#attributes, #attributes=, #contents=, #create, #initialize, #method_missing, #strategyclass, #strategyclass=

Methods inherited from Composite

#<<, #contents, #create, #initialize, #initialize_copy, #initialize_test

Methods inherited from Strategy

#abort, #assign, #clean_instance_variables, #display_unexpected_exc, #display_unexpected_synflow_exc, #fail, #initialize, #initialize_flow_factory, #name=, #pass, #raise_error, #reject, #run, #running?, #skip, #skip_if_cached, #skip_wrt_rpath_and_rpath_exclude, #strategy, #strategy=, #symbols=, #symtbl, #symtbl=, #testify, #timeout=, to_form, #to_s, to_yaml_type, #wclass=

Constructor Details

This class inherits a constructor from Uttk::Strategies::Collection

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Uttk::Strategies::Collection

Instance Method Details

#iter=(iter) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/uttk/strategies/Iterate.rb', line 91

def iter= ( iter )
  @iter = iter
  iter = iter.to_s if iter.is_a? Symbol
  @iterators = case iter
    when Array      then iter.flatten
    when /^\[.*\]$/ then eval iter
    when /,/        then iter.split(/\s*,\s*/)
    else [iter]
  end
  unless iterators.all? { |it| it.is_a? String }
    raise ArgumentError, 'The iterator name or list of names ' +
                         "must be strings not (#{iterators.inspect})"
  end
end