-
Notifications
You must be signed in to change notification settings - Fork 723
Expand file tree
/
Copy pathrescue_development_errors_spec.rb
More file actions
28 lines (25 loc) · 1.13 KB
/
Copy pathrescue_development_errors_spec.rb
File metadata and controls
28 lines (25 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/errors/rescue_development_errors"
describe Errors::RescueDevelopmentErrors, type: :controller do
describe 'when ActionView::Template::Error is raised' do
controller(ApplicationController) do
def index
error_message = 'No such file or directory @ rb_sysopen - ' \
'/home/me/WikiEduDashboard/public/assets/stylesheets/rev-manifest.json'
# First we raise a standard error to set the original error, which
# is needed by ActionView::Template::Error
raise StandardError, error_message
rescue StandardError
# Then we raise the actual template error, which takes a template path
# as its argument and pulls the original error object from $!
raise ActionView::Template::Error, 'app/views/layouts/application.html.haml'
end
end
it 'renders an explanation with helpful advice' do
# In development environment, this renders the page.
# In test environment, it raises an error with the explanation
expect { get :index }.to raise_error(/yarn/)
end
end
end