Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix for issue #11 - ZenTest conflict with .name property of Settingslogic class #19

Merged
1 commit merged into from

1 participant

@goosetav

I ran into the same problem with ZenTest autotester throwing stacks to stdout when it tries to call Settingslogic.name during its traversal of ObjectSpace. It annoyingly pollutes my console window...

Allowing name as a setting value is a very useful feature, so I enhanced the conditional to prevent calling instance when name is called directly on Settingslogic.

Tests are updated to include a test for the existing .name behavior and the desired behavior when calling the superclass.

@ghost ghost merged commit 794a03b into binarylogic:master
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 2, 2011
  1. @goosetav

    fixes settingslogic #11

    goosetav authored
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 1 deletion.
  1. +1 −1  lib/settingslogic.rb
  2. +17 −0 spec/settingslogic_spec.rb
View
2  lib/settingslogic.rb
@@ -7,7 +7,7 @@ class MissingSetting < StandardError; end
class << self
def name # :nodoc:
- instance.key?("name") ? instance.name : super
+ self.superclass != Hash && instance.key?("name") ? instance.name : super
end
# Enables Settings.get('nested.key.name') for dynamic access
View
17 spec/settingslogic_spec.rb
@@ -133,9 +133,26 @@ class NoSource < Settingslogic; end
Settings.get('setting1.deep.child.value').should == 2
end
+ # If .name is not a property, delegate to superclass
+ it "should respond with Module.name" do
+ Settings2.name.should == "Settings2"
+ end
+
+ # If .name is called on Settingslogic itself, handle appropriately
+ # by delegating to Hash
+ it "should have the parent class always respond with Module.name" do
+ Settingslogic.name.should == 'Settingslogic'
+ end
+
+ # If .name is a property, respond with that instead of delegating to superclass
+ it "should allow a name setting to be overriden" do
+ Settings.name.should == 'test'
+ end
+
# Put this test last or else call to .instance will load @instance,
# masking bugs.
it "should be a hash" do
Settings.send(:instance).should be_is_a(Hash)
end
+
end
Something went wrong with that request. Please try again.