Permalink
Browse files

Ensure endpoints aren't loaded multiple times unnecessarily.

  • Loading branch information...
1 parent 89ae56d commit 9e837aa3ea1a952c82ab511a9ea56708e57badbd @myronmarston myronmarston committed Apr 29, 2013
Showing with 15 additions and 0 deletions.
  1. +5 −0 lib/interpol/configuration.rb
  2. +10 −0 spec/unit/interpol/configuration_spec.rb
@@ -180,6 +180,11 @@ def self.default
end
def customized_duplicate(&block)
+ # ensure our endpoints our loaded; if they are not, they could be loaded
+ # a separate time by each interpol tool (when it uses this method) and
+ # that would be slow.
+ endpoints
+
block ||= lambda { |c| }
dup.tap(&block)
end
@@ -172,6 +172,16 @@ def find_with_status_code(status_code, options)
}.not_to raise_error
end
+ it 'is not prone to being reloaded when the configuration is customized' do
+ Endpoint.should_receive(:new).once.and_call_original
+
+ write_file "#{dir}/e1.yml", endpoint_definition_yml
+ config.endpoint_definition_files = Dir["#{dir}/*.yml"]
+
+ config.customized_duplicate { |c| c.endpoints }
+ config.customized_duplicate { |c| c.endpoints }
+ end
+
context "when YAML merge keys are used" do
let_without_indentation(:types) do <<-EOF
---

0 comments on commit 9e837aa

Please sign in to comment.