spec/integration/error_handling_spec.rb in sitehub-0.5.0.alpha8 vs spec/integration/error_handling_spec.rb in sitehub-0.5.0.alpha10

- old
+ new

@@ -1,13 +1,9 @@ require 'stringio' describe 'error handling' do context 'using config server' do - CONFIG_SERVER_URL = 'http://the.config.server'.freeze - DOWNSTREAM_URL = 'http://downstream.url'.freeze - ERROR_LOGGER = StringIO.new - ACCESS_LOGGER = StringIO.new - + include_context :integration include_context :sitehub_json let(:config) do { proxies: [ { @@ -21,14 +17,12 @@ before do stub_request(:get, DOWNSTREAM_URL).and_return(body: downstream_response) end let(:app) do - sitehub = SiteHub.build do - config_server(CONFIG_SERVER_URL, caching_options: { force: true }) - error_logger ERROR_LOGGER - access_logger ACCESS_LOGGER + sitehub = sitehub do + config_server(CONFIG_SERVER_URL, caching_options: { expires_in: 1 }) end Async::Middleware.new(sitehub) end it 'reads the config for routing' do @@ -61,10 +55,12 @@ stub_request(:get, CONFIG_SERVER_URL).and_return(status: bad_status) end it 'uses the old config' do + Timecop.travel(1) get('/') + expect(app.last_response.body).to eq([downstream_response]) end it 'logs the failure to read config' do get('/')