Sha256: 1506483ff11f9acb0353f02c4599a26e9b5d1cce9eb2ec1dff34eccdd6ff6d26

Contents?: true

Size: 1.74 KB

Versions: 7

Compression:

Stored size: 1.74 KB

Contents

require 'test_helper'
require 'app/cells/club_security'
require 'app/cells/club_security/guard_cell'
require 'app/cells/club_security/medic_cell'

module StringHelper
  def pick; "plong"; end
end

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


class HelperTest < ActionController::TestCase
  include Cell::TestCase::TestMethods
  
  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
    
    should "mix in required helpers, only" do
      assert_equal "false true", render_cell(:"club_security/medic", :help)
      assert_equal "true false", render_cell(:"club_security/guard", :help)
    end
    
    should "include helpers only once" do
      assert_equal "false true", render_cell(:"club_security/medic", :help)
      assert_equal "true false", render_cell(:"club_security/guard", :help)
      assert_equal "false true", render_cell(:"club_security/medic", :help)
      assert_equal "true false", render_cell(:"club_security/guard", :help)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cells-3.8.6 test/helper_test.rb
cells-3.8.5 test/helper_test.rb
cells-3.8.4 test/helper_test.rb
cells-3.8.3 test/helper_test.rb
cells-3.8.2 test/helper_test.rb
cells-3.8.1 test/helper_test.rb
cells-3.8.0 test/helper_test.rb