Sha256: 088333407f91828685c05eab50ebd49111deb8bd8af403dea1a3902717da0f0e

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

RSpec.describe Aldous::Respondable::Renderable do
  class Aldous::Respondable::Renderable::Dummy < described_class
    def template_data
      {
        locals: {hello: 1}
      }
    end

    def default_template_locals
      {
        hello: 2
      }
    end
  end

  subject(:renderable) {Aldous::Respondable::Renderable::Dummy.new(status, view_data, view_context)}

  let(:status) {:foo}
  let(:view_data) {double("view_data")}
  let(:view_context) {double("view context")}

  describe "#action" do
    let(:controller) {double("controller")}

    it "returns a render response action object" do
      expect(renderable.action(controller)).to be_kind_of Aldous::Respondable::Renderable::RenderAction
    end

    it 'creates a redirect response action with the relevant parameters' do
      expect(Aldous::Respondable::Renderable::RenderAction).to receive(:new).with(renderable.template, status, controller, view_data)
      renderable.action(controller)
    end
  end

  describe "#template" do
    subject(:renderable) {Aldous::Respondable::Renderable::Dummy.new(status, view_data, view_context)}

    it "overrides the default locals with the template locals" do
      expect(renderable.template).to eq({locals: {hello: 1}})
    end

    it "overrides the template locals with the provided locals" do
      expect(renderable.template(hello: 3)).to eq({locals: {hello: 3}})
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aldous-1.1.3 spec/aldous/respondable/renderable_spec.rb
aldous-1.1.2 spec/aldous/respondable/renderable_spec.rb
aldous-1.0.1 spec/aldous/respondable/renderable_spec.rb
aldous-1.0.0 spec/aldous/respondable/renderable_spec.rb