From 1315cac7c303429bdfc56ef061d98b158bf67b4d Mon Sep 17 00:00:00 2001 From: Jeremy Attali Date: Sat, 25 Jan 2014 23:57:37 +0100 Subject: [PATCH] add error string when widget not rendered This prevents the cryptic ruby raw string being printed if no rendering template were found. Closes: #307 --- lib/dashing/app.rb | 1 + test/app_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/dashing/app.rb b/lib/dashing/app.rb index 033849c..933ef5b 100644 --- a/lib/dashing/app.rb +++ b/lib/dashing/app.rb @@ -117,6 +117,7 @@ def protected! file = File.join(settings.root, "widgets", params[:widget], "#{params[:widget]}.#{suffix}") return engines.first.new(file).render if File.exist? file end + "Drats! Unable to find a widget file named: #{params[:widget]} to render." end def send_event(id, body, target=nil) diff --git a/test/app_test.rb b/test/app_test.rb index 4101e91..da889ff 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -137,6 +137,14 @@ def test_get_widget end end + def test_get_nonexistent_widget + with_generated_project do + get '/views/nowidget.html' + assert_equal 200, last_response.status + assert_equal last_response.body, 'Drats! Unable to find a widget file named: nowidget to render.' + end + end + def with_generated_project source_path = File.expand_path('../../templates', __FILE__)