Module: Spec::Runner::Context::InstanceMethods
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
76
77
78
|
# File 'lib/spec/runner/context.rb', line 76
def method_missing(*args)
@context_eval_module.method_missing(*args)
end
|
Instance Method Details
#before_context_eval ⇒ Object
15
16
|
# File 'lib/spec/runner/context.rb', line 15
def before_context_eval
end
|
#include(mod) ⇒ Object
22
23
24
|
# File 'lib/spec/runner/context.rb', line 22
def include(mod)
@context_eval_module.include mod
end
|
#inherit(klass) ⇒ Object
18
19
20
|
# File 'lib/spec/runner/context.rb', line 18
def inherit(klass)
@context_eval_module.inherit klass
end
|
#initialize(name, &context_block) ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'lib/spec/runner/context.rb', line 5
def initialize(name, &context_block)
@name = name
@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
|
#matches?(name, matcher = nil) ⇒ Boolean
52
53
54
55
56
57
58
|
# File 'lib/spec/runner/context.rb', line 52
def matches? name, matcher=nil
matcher ||= SpecMatcher.new name, @name
specifications.each do |spec|
return true if spec.matches_matcher? matcher
end
return false
end
|
68
69
70
71
72
|
# File 'lib/spec/runner/context.rb', line 68
def methods
my_methods = super
my_methods |= @context_eval_module.methods
my_methods
end
|
#number_of_specs ⇒ Object
48
49
50
|
# File 'lib/spec/runner/context.rb', line 48
def number_of_specs
specifications.length
end
|
#run(reporter, dry_run = false) ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/spec/runner/context.rb', line 38
def run(reporter, dry_run=false)
reporter.add_context(@name)
prepare_execution_context_class
specifications.each do |specification|
execution_context = execution_context_class.new(specification)
specification.run(reporter, setup_block, teardown_block, dry_run, execution_context)
end
end
|
#run_single_spec(name) ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/spec/runner/context.rb', line 60
def run_single_spec name
return if @name == name
matcher = SpecMatcher.new name, @name
specifications.reject! do |spec|
!spec.matches_matcher? matcher
end
end
|
#setup(&block) ⇒ Object
26
27
28
|
# File 'lib/spec/runner/context.rb', line 26
def setup(&block)
@context_eval_module.setup(&block)
end
|
#specify(spec_name, &block) ⇒ Object
34
35
36
|
# File 'lib/spec/runner/context.rb', line 34
def specify(spec_name, &block)
@context_eval_module.specify(spec_name, &block)
end
|
#teardown(&block) ⇒ Object
30
31
32
|
# File 'lib/spec/runner/context.rb', line 30
def teardown(&block)
@context_eval_module.teardown(&block)
end
|