Permalink
Browse files

generate HAML version of the views

  • Loading branch information...
1 parent 1e88bf7 commit b491dab9f7b0981645352cc11c544521cf501a71 @IdahoEv IdahoEv committed Feb 24, 2011
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
gem 'rails', '3.0.4'
gem 'logical_tabs', :path => '../../..'
-
+gem 'haml'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :test do
@@ -39,6 +39,7 @@ GEM
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
+ haml (3.0.25)
i18n (0.5.0)
linecache (0.43)
mail (2.2.15)
@@ -97,6 +98,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ haml
logical_tabs!
rails (= 3.0.4)
rspec (>= 2.5.0)
@@ -0,0 +1,5 @@
+class TestHamlController < ApplicationController
+ def index
+ end
+
+end
@@ -0,0 +1,2 @@
+module TestHamlHelper
+end
@@ -0,0 +1,19 @@
+%h1 Test Haml
+
+= create_tabbed_panel do |tabbed_panel|
+ - tabbed_panel.add_tab("Tab One") do
+ Content for Tab One
+
+ - tabbed_panel.add_tab("Tab Two") do
+ Content for Tab Two
+
+ - tabbed_panel.add_tab("Tab Three") do
+ %p Content for Tab Three
+
+ - tabbed_panel.add_tab("Tab Four", :content => "Content for Tab Four".html_safe)
+
+ - unsafe = "<script>unsafe!</script>"
+ - tabbed_panel.add_tab("Tab Foo", :content => unsafe)
+
+ - tabbed_panel.add_tab("Tab Bar") do
+ = unsafe
@@ -1,4 +1,5 @@
AppRoot::Application.routes.draw do
+ get "test_haml/index"
get "test_erb/index"
# The priority is based upon order of creation:
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class TestHamlControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ end
+
+end
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class TestHamlHelperTest < ActionView::TestCase
+end
@@ -0,0 +1,64 @@
+require File.join(File.dirname(__FILE__), '..', 'spec_helper')
+
+describe "test_haml/index", :type => :view do
+ before { render }
+
+ it "should render successfully" do
+ end
+
+ it "should contain a tabbed panel" do
+ rendered.should have_selector('div.tabbed_panel')
+ end
+
+ it "should number the tabbed panel" do
+ rendered.should have_selector('#tabbed_panel_0')
+ end
+
+ it "should contain a tabs UL with six tab LIs" do
+ rendered.should have_selector('#tabbed_panel_0') do |scope|
+ scope.should have_selector('ul.tabs') do |scope2|
+ scope2.should have_selector('li.tab')
+ end
+ end
+ end
+
+ it "should contain a panes DIV with six pane DIVs" do
+ rendered.should have_selector('#tabbed_panel_0') do |scope|
+ scope.should have_selector('div.panes') do |scope2|
+ scope2.should have_selector('div.pane')
+ end
+ end
+ end
+
+ it "should contain tabs with the proper text and IDs" do
+ rendered.should have_selector('#tabbed_panel_0') do |scope|
+ scope.should have_selector("li.tab[id='tabbed_panel_0_tp_tab_one_tab']") do |scope2|
+ scope2.should have_selector("a.tab_link"){ |s3| s3.should contain(/Tab One/)}
+ end
+ scope.should have_selector("li.tab[id='tabbed_panel_0_tp_tab_two_tab']") do |scope2|
+ scope2.should have_selector("a.tab_link"){ |s3| s3.should contain(/Tab Two/)}
+ end
+ scope.should have_selector("li.tab[id='tabbed_panel_0_tp_tab_foo_tab']") do |scope2|
+ scope2.should have_selector("a.tab_link"){ |s3| s3.should contain(/Tab Foo/)}
+ end
+ end
+ end
+
+ it "should contain panes with the proper content and IDs" do
+ rendered.should have_selector('#tabbed_panel_0') do |scope|
+ scope.should have_selector('div.pane#tabbed_panel_0_tp_tab_one_pane') do |s2|
+ s2.should contain("Content for Tab One")
+ end
+ scope.should have_selector('div.pane#tabbed_panel_0_tp_tab_two_pane') do |s2|
+ s2.should contain("Content for Tab Two")
+ end
+ scope.should have_selector('div.pane#tabbed_panel_0_tp_tab_foo_pane') do |s2|
+ s2.should contain("unsafe")
+ end
+ end
+ end
+
+ it "should not allow unsafe content through unescaped" do
+ rendered.should_not have_selector('script')
+ end
+end

0 comments on commit b491dab

Please sign in to comment.