Permalink
Browse files

Ensure that defaults are inherited from parent class

  • Loading branch information...
1 parent 96c1f0d commit 67f5351fb4eed617e39cbd91b4718f6926b6fb4e @lsegal committed Jun 9, 2012
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/yard/options.rb
  2. +11 −0 spec/options_spec.rb
View
@@ -188,7 +188,7 @@ def reset_defaults
names_set = {}
self.class.ancestors.each do |klass| # look at all ancestors
defaults = klass.instance_variable_get("@defaults")
- return unless defaults
+ next unless defaults
defaults.each do |key, value|
next if names_set[key]
names_set[key] = true
View
@@ -36,6 +36,17 @@ class ResetDefaultOptions1 < YARD::Options
o.reset_defaults
o.foo.should == 'FOO'
end
+
+ it "should use defaults from superclass as well" do
+ class ResetDefaultOptions2 < YARD::Options
+ default_attr :foo, 'FOO'
+ end
+ class ResetDefaultOptions3 < ResetDefaultOptions2
+ end
+ o = ResetDefaultOptions3.new
+ o.reset_defaults
+ o.foo.should == 'FOO'
+ end
end
describe '#delete' do

0 comments on commit 67f5351

Please sign in to comment.