Permalink
Browse files

select from Ruby's ancestors instead of building up our own

  • Loading branch information...
1 parent 35e4a6b commit ff4df6b375948c4f0f85afdfb4770a26889b13b5 @dchelimsky dchelimsky committed Apr 24, 2010
Showing with 8 additions and 18 deletions.
  1. +7 −17 lib/rspec/core/example_group.rb
  2. +1 −1 lib/rspec/core/formatters/documentation_formatter.rb
View
24 lib/rspec/core/example_group.rb
@@ -118,27 +118,17 @@ def self.subclass(parent, args, &example_group_block)
subclass
end
- class << self
- alias_method :context, :describe
- end
-
- def self.ancestors(superclass_last=false)
- current_class = self
-
- classes = []
- while current_class < Rspec::Core::ExampleGroup
- superclass_last ? classes << current_class : classes.unshift(current_class)
- current_class = current_class.superclass
- end
- classes
- end
-
def self.before_ancestors
- @_before_ancestors ||= ancestors
+ @_before_ancestors ||= after_ancestors.reverse
end
def self.after_ancestors
- @_after_ancestors ||= ancestors(true)
+ @_after_ancestors ||= ancestors.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
View
2 lib/rspec/core/formatters/documentation_formatter.rb
@@ -68,7 +68,7 @@ def current_indentation
end
def described_example_group_chain
- example_group.ancestors
+ example_group.ancestor_example_groups
end
end

0 comments on commit ff4df6b

Please sign in to comment.