Method: Tap::Test::TapTest#with_config

Defined in:
lib/tap/test/tap_test.rb

#with_config(config = {}, app = self.app, &block) ⇒ Object

Reconfigures app with the input configurations for the duration of the block.

app = Tap::App.new(:quiet => true, :debug => false)
with_config({:quiet => false}, app) do 
  app.quiet                    # => false
  app.debug                    # => false
end

app.quiet                      # => true
app.debug                      # => false


89
90
91
92
93
94
95
96
97
98
99
# File 'lib/tap/test/tap_test.rb', line 89

def with_config(config={}, app=self.app, &block)
  begin
    hold = app.config.to_hash
    
    app.reconfigure(config)
    
    yield block if block_given?
  ensure
    app.send(:initialize_config, hold)
  end
end