require File.expand_path('../helper', __FILE__) class TestSlim < ActionDispatch::IntegrationTest test "normal view" do get "slim/normal" assert_response :success assert_template ["slim/normal", "layouts/application"] assert_html "

Hello Slim!

" end test "normal erb view" do get "slim/erb" assert_html "

Hello Erb!

" end test "view without a layout" do get "slim/no_layout" assert_template "slim/no_layout" assert_html "

Hello Slim without a layout!

", :skip_layout => true end test "view with variables" do get "slim/variables" assert_html "

Hello Slim with variables!

" end test "partial view" do get "slim/partial" assert_html "

Hello Slim!

With a partial!

" end if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1 && Object.const_defined?(:Fiber) puts 'Streaming test enabled' test "streaming" do get "slim/streaming" output = "2f\r\nDummy\r\nd\r\n\r\n17\r\nHeading set from a view\r\n15\r\n
\r\n53\r\n

Page content

Hello Streaming!

Hello Streaming!

\r\n14\r\n
\r\n0\r\n\r\n" assert_equal output, @response.body end else puts 'Streaming test disabled' end test "render integers" do get "slim/integers" assert_html "

1337

" end test "render nil" do get "slim/nil" assert_html "

" end test "content_for" do get "slim/content_for" assert_html "

Page content

Hello Slim!

Hello Slim!

", :heading => 'Heading set from a view' end test "nested_attributes_form" do post "parents", 'parent[name]' => "p1", 'parent[children_attributes][0][name]' => "c1" get "parents/1/edit" assert_match(%r{

Parent

Children

}, @response.body) end protected def assert_html(expected, options = {}) expected = "Dummy#{options[:heading]}
#{expected}
" unless options[:skip_layout] assert_equal expected, @response.body end end