Sha256: eb6a319fe97b001d97a48507d64214f16ae36c5bad084ce2edce5bf887fe8782

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper')

module StringHelper
  def pick; "plong"; end
end

class DrummerCell < Cell::Base
  helper StringHelper
          
  def assist
    render :inline => "<%= pick %>"
  end
end


class HelperTest < ActionController::TestCase
  context "a cell view" do
    should "have access to all helpers" do
      BassistCell.class_eval do
        def assist
          render :inline => "<%= submit_tag %>"
        end
      end
      
      assert_equal "<input name=\"commit\" type=\"submit\" value=\"Save changes\" />", render_cell(:bassist, :assist)
    end
    
    should "have access to methods declared with helper_method" do
      BassistCell.class_eval do
        def help; "Great!"; end
        helper_method :help
          
        def assist
          render :inline => "<%= help %>"
        end
      end
      
      assert_equal "Great!", render_cell(:bassist, :assist)
    end
    
    should "have access to methods provided by helper" do
      assert_equal "plong", render_cell(:drummer, :assist)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cells-3.4.0.beta3 test/helper_test.rb
cells-3.4.0.beta2 test/helper_test.rb
cells-3.4.0.beta1 test/helper_test.rb