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

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object (protected)



67
68
69
# File 'lib/spec/runner/context.rb', line 67

def method_missing(*args)
  @context_eval_module.method_missing(*args)
end

Instance Method Details

#before_context_evalObject



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

def before_context_eval
end

#inherit_context_eval_module_from(klass) ⇒ Object

this is here for Spec::Rails



21
22
23
# File 'lib/spec/runner/context.rb', line 21

def inherit_context_eval_module_from(klass)
  @context_eval_module.inherit klass
end

#initialize(description, &context_block) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/spec/runner/context.rb', line 7

def initialize(description, &context_block)
  @description = description

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

#matches?(full_description) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
# File 'lib/spec/runner/context.rb', line 43

def matches?(full_description)
  matcher ||= SpecMatcher.new(@description)
  specifications.each do |spec|
    return true if spec.matches?(matcher, full_description)
  end
  return false
end

#methodsObject



59
60
61
62
63
# File 'lib/spec/runner/context.rb', line 59

def methods
  my_methods = super
  my_methods |= @context_eval_module.methods
  my_methods
end

#number_of_specsObject



39
40
41
# File 'lib/spec/runner/context.rb', line 39

def number_of_specs
  specifications.length
end

#run(reporter, dry_run = false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/spec/runner/context.rb', line 25

def run(reporter, dry_run=false)
  reporter.add_context(@description)
  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, []) unless context_setup_block.nil?
    specification.run(reporter, setup_block, teardown_block, dry_run, specification_execution_context)
  end unless errors.length > 0
  
  run_context_teardown(reporter, dry_run)
end

#run_single_spec(full_description) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/spec/runner/context.rb', line 51

def run_single_spec(full_description)
  return if @description == full_description
  matcher = SpecMatcher.new(@description)
  specifications.reject! do |spec|
    !spec.matches?(matcher, full_description)
  end
end