Sha256: 263fa937af7e634b81a9c9e7124c696c6fe49dc7bf764de8d5141f779cca8443

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

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

class ProducerCell < Cell::Base
  helper ::Cells::Helpers::CaptureHelper
  
  def logger(*args); puts args.inspect; end
end

class RailsCaptureTest < ActionController::TestCase
  context "A Rails controller rendering cells" do
    setup do
      @routes = ActionDispatch::Routing::RouteSet.new
      @routes.draw do
        |map| match ':action', :to => MusicianController
      end
      @controller = MusicianController.new
    end
    
    should "see content from global_capture" do
      @controller.class_eval do
        def featured
          render :inline => '<h3><%= @recorded %></h3>' << render_cell(:producer, :capture)
        end
      end
      
      ProducerCell.class_eval do
        def capture; render; end
      end
      
      get 'featured'
      assert_equal '<h3>DummDoo</h3> DummDoo', @response.body
    end
    
    
    should "see yieldable content from global_content_for" do
      @controller.class_eval do
        def featured
          render_cell(:producer, :content_for)
          render :inline => '<pre><%= yield :recorded %></pre>'
        end
      end
      
      ProducerCell.class_eval do
        def content_for; render; end
      end
       
      get 'featured'
      assert_equal "\n<pre>DummDooDiiDoo</pre>", @response.body
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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