hi there
require File.join(File.dirname(__FILE__), 'rails', 'spec_helper') if RUNNING_RAILS class NonSpecificTestController < ActionController::Base VIEW_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'rails', 'views')) around_filter :catch_exceptions attr_reader :last_exception def catch_exceptions yield rescue Exception => @last_exception raise @last_exception end end if Markaby::Rails.deprecated_rails_version? class ActionController::TestCase < Test::Unit::TestCase; end class TestController < NonSpecificTestController self.template_root = VIEW_PATH end else class TestController < NonSpecificTestController append_view_path(VIEW_PATH) end end class MarkabyController < TestController def renders_nothing render :text => "" end def renders_erb_with_explicit_template render :template => "markaby/renders_erb" end def render_inline_content mab_content = mab do ul do li "Scott" end end render :inline => mab_content end def render_explicit_but_empty_markaby_layout render :template => "markaby/render_explicit_but_empty_markaby_layout.mab" end def no_values_passed render :template => "markaby/no_values_passed" end def correct_template_values render :template => "markaby/correct_template_values" end def render_erb_without_explicit_render_call end def render_mab_without_explicit_render_call end def render_with_ivar @user = "smtlaissezfaire" render :template => "markaby/render_with_ivar" end def access_to_helpers render :template => "markaby/access_to_helpers" end def renders_partial render :template => "markaby/partial_parent" end def renders_partial_with_locals render :template => "markaby/partial_parent_with_locals" end def render_which_raises_error render :template => "markaby/broken" end def renders_form_for @obj = Object.new render :template => "markaby/form_for" end def render_form_for_with_fields @obj = Object.new def @obj.foo "bar" end render :template => "markaby/form_for_with_fields" end def render_form_for_with_multiple_fields @obj = Object.new def @obj.foo "bar" end def @obj.baz "quxx" end render :template => "markaby/form_for_with_multiple_fields" end def routes end def commented_out_template end def render_with_yielding render :layout => "layout.mab", :template => "markaby/yielding" end def render_with_yielding_where_template_has_two_elements render :layout => "layout.mab", :template => "markaby/yielding_two" end def render_with_yielding_content_for_block render :layout => "layout.mab", :template => "markaby/yielding_with_content_for" end def render_content_for_with_block_helper @obj = Object.new def @obj.foo "bar" end render :layout => "layout.mab", :template => "markaby/yielding_content_for_with_block_helper" end def renders_content_for_with_form_for_without_double_render @obj = Object.new def @obj.foo "bar" end render :layout => "layout.mab", :template => "markaby/double_output" end end class MarkabyOnRailsTest < ActionController::TestCase def setup Markaby::Builder.restore_defaults! @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @controller = MarkabyController.new end def test_renders_nothing get :renders_nothing assert_response :success end def test_renders_erb_with_explicit_template get :renders_erb_with_explicit_template assert_response :success # TODO: - fix this test environment issue so that assert_template works # correctly in these tests # assert_template "renders_erb.erb" end def test_renders_explicit_but_empty_markaby_layout get :render_explicit_but_empty_markaby_layout assert_response :success assert_equal "", @response.body # TODO: # assert_template "markaby/render_explicit_but_empty_markaby_layout" end def test_renders_inline_markaby_content get :render_inline_content assert_response :success assert_equal "
hi there
hi there
hi again
in foo content_for