Browse files

restore clarity of spy setup

  • Loading branch information...
1 parent 671a13e commit 799210ca65006686cf79a9c2b30a160bfd158a58 @rcarver committed Aug 8, 2012
Showing with 16 additions and 4 deletions.
  1. +1 −3 lib/config/project.rb
  2. +14 −0 lib/config/spy/configuration.rb
  3. +1 −1 test/config/project_test.rb
View
4 lib/config/project.rb
@@ -165,9 +165,7 @@ def merged_configuration(cluster = nil, node = nil)
def merged_spy_configuration
levels = configuration_levels
- parent = Config::Configuration.merge(*levels)
- spy = Config::Spy::Configuration.new("Spy Cluster", parent)
- Config::Configuration.merge(*(levels + [spy]))
+ Config::Spy::Configuration.merge_and_spy("Spy Cluster", *levels)
end
end
end
View
14 lib/config/spy/configuration.rb
@@ -9,6 +9,20 @@ module Spy
class Configuration
include Config::Configuration::MethodMissing
+ # A subclass of normal merge so that it's identifiable.
+ class SpyMerged < Config::Configuration::Merged
+ def initialize(spy, *levels)
+ super levels + [spy]
+ end
+ end
+
+ # Initialize a spy configuration as part of a merged configuration.
+ def self.merge_and_spy(level_name, *levels)
+ parent = Config::Configuration.merge(*levels)
+ spy = Config::Spy::Configuration.new(level_name, parent)
+ SpyMerged.new(spy, *levels)
+ end
+
def initialize(level_name, parent = nil)
@level_name = level_name
@parent = parent || Config::Configuration.merge
View
2 test/config/project_test.rb
@@ -80,7 +80,7 @@
describe "without a cluster" do
- let(:assigned_configuration_class) { Config::Configuration::Merged }
+ let(:assigned_configuration_class) { Config::Spy::Configuration::SpyMerged }
let(:assigned_cluster_context_class) { Config::Spy::ClusterContext }
it "executes the blueprint in noop mode, with a spy cluster" do

0 comments on commit 799210c

Please sign in to comment.