Sha256: d9873538611da2dfd998e9c66ebfdc6e7044262ecf1c7ddbcc2d77d31b0d256d

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Landable::PageRenderResponder do

  let(:page) { build :page }
  let(:responder) { Landable::PageRenderResponder.new double(request: double, formats: []), [page] }

  describe '#to_html' do
    context 'okay' do
      it 'should render a 200' do
        content = double
        content_type = double
        Landable::RenderService.should_receive(:call) { content }
        page.should_receive(:content_type) { content_type }

        responder.should_receive(:render).with(text: content, content_type: content_type, layout: false)

        responder.to_html
      end
    end

    context 'redirect' do
      let(:page) { build :page, :redirect }

      it 'should render a redirect' do
        responder.should_receive(:redirect_to).with(page.redirect_url, status: page.status_code)
        responder.should_not_receive(:render)

        responder.to_html
      end
    end

    context 'missing' do
      let(:page) { build :page, :gone }

      it 'should render a 410' do
        expect { responder.to_html }.to raise_error(Landable::Page::GoneError)
        responder.should_not_receive(:render)
      end
    end
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 spec/responders/page_render_responder_spec.rb
landable-1.12.3 spec/responders/page_render_responder_spec.rb
landable-1.12.2 spec/responders/page_render_responder_spec.rb
landable-1.12.1 spec/responders/page_render_responder_spec.rb
landable-1.11.1 spec/responders/page_render_responder_spec.rb
landable-1.11.0 spec/responders/page_render_responder_spec.rb
landable-1.10.0.rc2 spec/responders/page_render_responder_spec.rb
landable-1.10.0.rc1 spec/responders/page_render_responder_spec.rb
landable-1.9.2 spec/responders/page_render_responder_spec.rb
landable-1.9.1 spec/responders/page_render_responder_spec.rb
landable-1.9.0 spec/responders/page_render_responder_spec.rb
landable-1.9.0.rc2 spec/responders/page_render_responder_spec.rb
landable-1.9.0.rc1 spec/responders/page_render_responder_spec.rb
landable-1.8.0 spec/responders/page_render_responder_spec.rb
landable-1.7.1.rc1 spec/responders/page_render_responder_spec.rb
landable-1.7.0 spec/responders/page_render_responder_spec.rb