Class: Crew::Tester
- Inherits:
-
Object
- Object
- Crew::Tester
- Includes:
- Util
- Defined in:
- lib/crew/tester.rb,
lib/crew/tester/dsl.rb,
lib/crew/tester/preparer.rb,
lib/crew/tester/preparer/dsl.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#hints ⇒ Object
Returns the value of attribute hints.
Instance Method Summary collapse
- #add_preparer(name, &blk) ⇒ Object
- #context(name, &blk) ⇒ Object
-
#initialize(home, name, &blk) ⇒ Tester
constructor
A new instance of Tester.
- #run(opts) ⇒ Object
Methods included from Util
#assert, #escape, #logger, #poll, #retryable
Constructor Details
Instance Attribute Details
#hints ⇒ Object
Returns the value of attribute hints.
5 6 7 |
# File 'lib/crew/tester.rb', line 5 def hints @hints end |
Instance Method Details
#add_preparer(name, &blk) ⇒ Object
48 49 50 51 |
# File 'lib/crew/tester.rb', line 48 def add_preparer(name, &blk) @preparers[name] = Preparer.new(name) @preparers[name].load(&blk) end |
#context(name, &blk) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/crew/tester.rb', line 15 def context(name, &blk) if name @context_name = name else @home.add_context @context_name, &blk end end |
#run(opts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/crew/tester.rb', line 23 def run(opts) return if opts[:context_name] && @name != opts[:context_name] prepare(opts[:force_prepare]) task_count = 0 test_results = {} @home.each_task do |task| next unless opts[:test_name].nil? or opts[:test_name] == task.name preparer = @preparers.values.find {|p| p.match?(task.name)} raise "couldn't find preparer for task `#{task.name}'" unless preparer @home.in_context(@context_name) do @home.setup_mode = true @home.context.snapshot_name = preparer.name task.context = @home.context task.test!(self, opts) do |result| display_result result end end end end |