Skip to content

Commit 457b219

Browse files
committed
Don't handle server errors in Sinatra and remove prod testing
1 parent 2edd0bc commit 457b219

4 files changed

Lines changed: 5 additions & 50 deletions

File tree

app.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ class Rubies < Sinatra::Base
1313
set :protection, except: [:json_csrf]
1414
end
1515

16-
configure :production do
17-
set :raise_errors, false
18-
set :show_exceptions, false
19-
20-
set :static_cache_control, [:public, :must_revalidate, { max_age: 30672000 }]
21-
end
22-
2316
set :app_file, __FILE__
2417
set :root, File.dirname(settings.app_file)
2518
set :public_folder, File.join(settings.root, 'public')
@@ -57,11 +50,4 @@ class Rubies < Sinatra::Base
5750
@title = 'Rubies | 404'
5851
erb :not_found
5952
end
60-
61-
error do
62-
halt if request.path_info =~ %r{^/api/}
63-
64-
@title = 'Rubies | Error'
65-
erb :error
66-
end
6753
end

spec/app_spec.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@
3636
expect(html).to include("The page you're looking for doesn't exist")
3737
end
3838
end
39-
40-
describe 'server error' do
41-
let(:endpoint) { '/' }
42-
43-
it 'returns an error page' do
44-
allow(REDIS).to receive(:lrange).and_raise(StandardError)
45-
46-
get endpoint
47-
48-
expect(last_response.status).to eq(500)
49-
expect(html).to include('Something went wrong on our end.')
50-
end
51-
end
5239
end
5340

5441
context 'JSON API' do
@@ -141,17 +128,5 @@
141128
expect(last_response.status).to eq(404)
142129
end
143130
end
144-
145-
describe 'server error' do
146-
let(:endpoint) { '/api/normal' }
147-
148-
it 'returns status 500' do
149-
allow(REDIS).to receive(:exists?).and_raise(StandardError)
150-
151-
get endpoint
152-
153-
expect(last_response.status).to eq(500)
154-
end
155-
end
156131
end
157132
end

spec/spec_helper.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
require 'bundler/setup'
44

5-
# Set RACK_ENV to production to test error handling in production mode
6-
ENV['RACK_ENV'] = 'production'
5+
ENV['RACK_ENV'] ||= 'test'
76

8-
require 'simplecov'
9-
SimpleCov.start
10-
11-
require 'mock_redis'
127
require 'rack/test'
8+
require 'mock_redis'
139
require 'webmock/rspec'
10+
require 'simplecov'
11+
12+
SimpleCov.start
1413

1514
MOCKREDIS = MockRedis.new
1615

views/error.erb

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)