Class: Spec::Example::ExampleGroupHierarchy

Inherits:
Array show all
Defined in:
lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb

Instance Method Summary collapse

Methods included from Resourceful::Serialize::Array

#serialize, #to_serializable

Constructor Details

#initialize(example_group_class) ⇒ ExampleGroupHierarchy

Returns a new instance of ExampleGroupHierarchy.



4
5
6
7
8
9
10
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 4

def initialize(example_group_class)
  push example_group_class
  if example_group_class.respond_to?(:superclass) && example_group_class.superclass.respond_to?(:example_group_hierarchy)
    unshift example_group_class.superclass.example_group_hierarchy
    flatten!
  end
end

Instance Method Details

#after_all_partsObject



40
41
42
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 40

def after_all_parts
  @after_all_parts ||= reverse.collect {|klass| klass.after_all_parts}.flatten
end

#after_each_partsObject



36
37
38
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 36

def after_each_parts
  @after_each_parts ||= reverse.collect {|klass| klass.after_each_parts}.flatten
end

#before_all_partsObject



28
29
30
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 28

def before_all_parts
  @before_all_parts ||= collect {|klass| klass.before_all_parts}.flatten
end

#before_each_partsObject



32
33
34
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 32

def before_each_parts
  @before_each_parts ||= collect {|klass| klass.before_each_parts}.flatten
end

#nested_description_from(example_group) ⇒ Object



48
49
50
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 48

def nested_description_from(example_group)
  example_group.description_args.join
end

#nested_descriptionsObject



44
45
46
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 44

def nested_descriptions
  @nested_descriptions ||= collect {|eg| nested_description_from(eg) == "" ? nil : nested_description_from(eg) }.compact
end

#run_after_all(example) ⇒ Object



24
25
26
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 24

def run_after_all(example)
  example.eval_each_fail_slow(after_all_parts)
end

#run_after_each(example) ⇒ Object



20
21
22
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 20

def run_after_each(example)
  example.eval_each_fail_slow(after_each_parts)
end

#run_before_all(example) ⇒ Object



12
13
14
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 12

def run_before_all(example)
  example.eval_each_fail_fast(before_all_parts)
end

#run_before_each(example) ⇒ Object



16
17
18
# File 'lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb', line 16

def run_before_each(example)
  example.eval_each_fail_fast(before_each_parts)
end