Module: Spec::Runner::Context::InstanceMethods

Included in:
Spec::Runner::Context
Defined in:
lib/spekmachine/runner/context.rb

Instance Method Summary collapse

Instance Method Details

#context_idObject



16
17
18
# File 'lib/spekmachine/runner/context.rb', line 16

def context_id
  @context_id
end

#goto(name, &block) ⇒ Object



20
21
22
# File 'lib/spekmachine/runner/context.rb', line 20

def goto(name, &block)
  @context_eval_module.goto(name, &block)
end

#goto_partsObject



28
29
30
# File 'lib/spekmachine/runner/context.rb', line 28

def goto_parts
  @context_eval_module.goto_parts
end

#initialize(name, desc, &context_block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/spekmachine/runner/context.rb', line 5

def initialize(name, desc, &context_block)
  @context_id = name
  @name = desc

  @context_eval_module = Module.new
  @context_eval_module.extend ContextEval::ModuleMethods
  @context_eval_module.include ContextEval::InstanceMethods
  before_context_eval
  @context_eval_module.class_eval(&context_block)
end

#jump_to(name) ⇒ Object



24
25
26
# File 'lib/spekmachine/runner/context.rb', line 24

def jump_to(name)
  goto_parts[name].call
end

#run(reporter, dry_run = false) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/spekmachine/runner/context.rb', line 32

def run(reporter, dry_run=false)
  reporter.add_context(@name)
  prepare_execution_context_class
  errors = run_context_setup(reporter, dry_run)

  specifications.each do |specification|
    specification_execution_context = execution_context(specification)
    specification_execution_context.copy_instance_variables_from(@once_only_execution_context_instance, [:@spec]) unless context_setup_block.nil?
    # only modification: setup_block & teardown_block are nil
    specification.run(reporter, nil, nil, dry_run, specification_execution_context)
  end unless errors.length > 0
  
  run_context_teardown(reporter, dry_run)
end