Sha256: 43fb1763968fac7302895dab797972779959dca5ef6091926c191bae547c9979

Contents?: true

Size: 1.64 KB

Versions: 15

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher do
  include ActionController::TemplateAssertions

  context 'a controller that renders with a layout' do
    it 'accepts rendering with any layout' do
      controller_with_wide_layout.should render_with_layout
    end

    it 'accepts rendering with that layout' do
      controller_with_wide_layout.should render_with_layout(:wide)
    end

    it 'rejects rendering with another layout' do
      controller_with_wide_layout.should_not render_with_layout(:other)
    end

    def controller_with_wide_layout
      create_view('layouts/wide.html.erb', 'some content, <%= yield %>')
      build_response { render :layout => 'wide' }
    end
  end

  context 'a controller that renders without a layout' do

    it 'rejects rendering with a layout' do
      controller_without_layout = build_response { render :layout => false }

      controller_without_layout.should_not render_with_layout
    end
  end

  context 'a controller that renders a partial' do
    it 'rejects rendering with a layout' do
      controller_with_partial = build_response { render :partial => 'partial' }

      controller_with_partial.should_not render_with_layout
    end
  end

  context 'given a context with layouts' do
    it 'accepts that layout in that context' do
      set_in_context_layout('happy')

      controller_without_layout.should render_with_layout('happy').in_context(self)
    end

    def set_in_context_layout(layout)
      @layouts = Hash.new(0)
      @layouts[layout] = 1
    end

    def controller_without_layout
      build_response { render :layout => false }
    end
  end
end

Version data entries

15 entries across 14 versions & 2 rubygems

Version Path
shoulda-matchers-2.3.0 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
challah-1.0.0 vendor/bundle/gems/shoulda-matchers-2.2.0/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-2.2.0 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-2.1.0/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-2.1.0 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
challah-1.0.0.beta2 vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.5.6/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-2.0.0 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-1.5.6 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-1.5.5 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-1.5.4 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-1.5.2 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-1.5.1 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
shoulda-matchers-1.5.0 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb