summaryrefslogtreecommitdiff
path: root/test/app_test.rb
diff options
context:
space:
mode:
authorDavid Underwood <davefp@gmail.com>2013-06-21 08:13:02 -0700
committerDavid Underwood <davefp@gmail.com>2013-06-21 08:13:02 -0700
commita0f4d31775fde6ceac7017e592ba72f85706b831 (patch)
tree73bce54289278050439001d845853e2ce7a626a4 /test/app_test.rb
parent2e1c714cc6cb957bbd23b248dd0945ce21757f4f (diff)
parenta6eea61f2a7cfbf67175583dd7dcb49a4c09da75 (diff)
Merge pull request #123 from apeckham/haml
Use any Tilt-supported view language: Haml, Slim, ERB, Liquid, etc.
Diffstat (limited to 'test/app_test.rb')
-rw-r--r--test/app_test.rb39
1 files changed, 37 insertions, 2 deletions
diff --git a/test/app_test.rb b/test/app_test.rb
index f6fa537..97aad3a 100644
--- a/test/app_test.rb
+++ b/test/app_test.rb
@@ -58,14 +58,49 @@ class AppTest < Dashing::Test
end
end
+ def test_redirect_to_first_dashboard_without_erb
+ with_generated_project do |dir|
+ FileUtils.touch(File.join(dir, "dashboards/htmltest.html"))
+ get '/'
+ assert_equal 302, last_response.status
+ assert_equal 'http://example.org/htmltest', last_response.location
+ end
+ end
+
def test_get_dashboard
with_generated_project do
get '/sampletv'
assert_equal 200, last_response.status
assert_include last_response.body, 'class="gridster"'
+ assert_include last_response.body, "DOCTYPE"
end
end
-
+
+ begin
+ require 'haml'
+
+ def test_get_haml_dashboard
+ with_generated_project do |dir|
+ File.write(File.join(dir, 'dashboards/hamltest.haml'), '.gridster')
+ get '/hamltest'
+ assert_equal 200, last_response.status
+ assert_include last_response.body, "class='gridster'"
+ end
+ end
+
+ def test_get_haml_widget
+ with_generated_project do |dir|
+ File.write(File.join(dir, 'widgets/clock/clock.haml'), '%h1 haml')
+ File.unlink(File.join(dir, 'widgets/clock/clock.html'))
+ get '/views/clock.html'
+ assert_equal 200, last_response.status
+ assert_include last_response.body, '<h1>haml</h1>'
+ end
+ end
+ rescue LoadError
+ puts "[skipping haml tests because haml isn't installed]"
+ end
+
def test_get_nonexistent_dashboard
with_generated_project do
get '/nodashboard'
@@ -88,7 +123,7 @@ class AppTest < Dashing::Test
Sinatra::Application.settings.views = File.join(dir, 'new_project/dashboards')
Sinatra::Application.settings.root = File.join(dir, 'new_project')
- yield
+ yield Sinatra::Application.settings.root
end
end