Permalink
Browse files

just use ancestors and ancestors.reverse

  • Loading branch information...
1 parent 89f8417 commit cbfae9b3e79a48df5dc8379773cc8f10d368f7cb @dchelimsky dchelimsky committed Apr 27, 2010
Showing with 10 additions and 15 deletions.
  1. +6 −11 lib/rspec/core/example_group.rb
  2. +4 −4 lib/rspec/core/formatters/documentation_formatter.rb
@@ -119,17 +119,12 @@ def self.subclass(parent, args, &example_group_block)
subclass
end
- def self.before_ancestors
- @_before_ancestors ||= after_ancestors.reverse
- end
-
- def self.after_ancestors
- @_after_ancestors ||= ancestors.select {|a| a < Rspec::Core::ExampleGroup}
+ def self.ancestors
+ @_ancestors ||= super().select {|a| a < Rspec::Core::ExampleGroup}
end
class << self
alias_method :context, :describe
- alias_method :ancestor_example_groups, :before_ancestors
end
def self.before_all_ivars
@@ -142,7 +137,7 @@ def self.eval_before_alls(running_example)
end
configuration.find_hook(:before, :all, self).each { |blk| running_example.instance_eval(&blk) }
- before_ancestors.each do |ancestor|
+ ancestors.reverse.each do |ancestor|
until ancestor.before_alls.empty?
running_example.instance_eval &ancestor.before_alls.shift
end
@@ -152,16 +147,16 @@ def self.eval_before_alls(running_example)
def self.eval_before_eachs(running_example)
configuration.find_hook(:before, :each, self).each { |blk| running_example.instance_eval(&blk) }
- before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_example.instance_eval(&blk) } }
+ ancestors.reverse.each { |ancestor| ancestor.before_eachs.each { |blk| running_example.instance_eval(&blk) } }
end
def self.eval_after_eachs(running_example)
- after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example.instance_eval(&blk) } }
+ ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example.instance_eval(&blk) } }
configuration.find_hook(:after, :each, self).each { |blk| running_example.instance_eval(&blk) }
end
def self.eval_after_alls(running_example)
- after_ancestors.each do |ancestor|
+ ancestors.each do |ancestor|
after_alls = ancestor.after_alls.dup
until after_alls.empty?
running_example.instance_eval &after_alls.shift
@@ -14,14 +14,14 @@ def initialize
def add_example_group(example_group)
super
- described_example_group_chain.each_with_index do |nested_example_group, i|
+ example_group_chain.each_with_index do |nested_example_group, i|
unless nested_example_group == @previous_nested_example_groups[i]
output.puts if i == 0
output.puts "#{' ' * i}#{nested_example_group.description}"
end
end
- @previous_nested_example_groups = described_example_group_chain
+ @previous_nested_example_groups = example_group_chain
end
def output_for(example)
@@ -67,8 +67,8 @@ def current_indentation
' ' * @previous_nested_example_groups.size
end
- def described_example_group_chain
- example_group.ancestor_example_groups
+ def example_group_chain
+ example_group.ancestors.reverse
end
end

1 comment on commit cbfae9b

rking commented on cbfae9b Feb 22, 2013

Perplexing.

Please sign in to comment.