Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #19 from goosetav/master

fix for issue #11 - ZenTest conflict with .name property of Settingslogic class
  • Loading branch information...
commit 794a03be91f732fef7519894dd5866853cc91189 2 parents e9ba798 + 975252e
Ben Johnson authored
Showing with 18 additions and 1 deletion.
  1. +1 −1  lib/settingslogic.rb
  2. +17 −0 spec/settingslogic_spec.rb
2  lib/settingslogic.rb
View
@@ -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
17 spec/settingslogic_spec.rb
View
@@ -137,9 +137,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
Please sign in to comment.
Something went wrong with that request. Please try again.