Sha256: 974329a26e16925e0963d6490e8f5b4c41cdeeb468116e54f9a5d1a09d519532

Contents?: true

Size: 1.62 KB

Versions: 24

Compression:

Stored size: 1.62 KB

Contents

require File.dirname(__FILE__) + "/../../spec_helper"
require 'ostruct'

describe Admin::RegionsHelper do
  before :each do
    @controller_name = 'page'
    @controller.stub!(:controller_name).and_return(@controller_name)
    @controller.stub!(:template_name).and_return('edit')
    assigns[:controller_name] = @controller_name
    @admin = Radiant::AdminUI.instance
    helper.stub!(:admin).and_return(@admin)
    @region_set_mock = Radiant::AdminUI::RegionSet.new
    @admin.stub!(:page).and_return(OpenStruct.new(:edit => @region_set_mock))
  end
  
  it "should initialize relevant region variables" do
    helper.lazy_initialize_region_set
    @controller_name == 'page'
    @template_name == 'edit'
    @region_set === @region_set_mock
  end

  describe "rendering a region" do
    before :each do
      @region_set_mock.add :main, "test"
      helper.stub!(:capture).and_return("foo")
      helper.lazy_initialize_region_set
    end
    
    it "should render a region with no default partials" do
      helper.should_receive(:render).with(:partial => "test").and_return("foo")
      helper.render_region(:main).should == "foo"
    end
    
    it "should capture the passed block, yielding the RegionPartials object and concatenating" do
      helper.should_receive(:render).and_raise(::ActionView::MissingTemplate.new(Rails.configuration.view_paths, '.'))
      helper.should_receive(:concat).with("foo")
      helper.should_receive(:capture).and_return("foo")
      helper.render_region(:main)  do |main|
        main.should be_kind_of(Radiant::AdminUI::RegionPartials)
        main.test do
          "foo"
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
radiant-1.0.0.rc3 spec/helpers/admin/regions_helper_spec.rb
radiant-1.0.0.rc2 spec/helpers/admin/regions_helper_spec.rb
radiant-1.0.0.rc1 spec/helpers/admin/regions_helper_spec.rb
radiant-rails3-0.1 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.2.4 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.2.2 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.2.1 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.2 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.9 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.8 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.7 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.6 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.5 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.4 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.3 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.2 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1.1 spec/helpers/admin/regions_helper_spec.rb
radiantcms-couchrest_model-0.1 spec/helpers/admin/regions_helper_spec.rb
radiant-0.9.1 spec/helpers/admin/regions_helper_spec.rb
radiant-0.8.2 spec/helpers/admin/regions_helper_spec.rb