Sha256: a3b2344693731722216d92851db7b9896885f4389756bf3ab6a601a3a3a861c3

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

RSpec.describe Aldous::Respondable::Renderable::RenderAction do
  subject(:respondable) {described_class.new(template, status, controller, view_data)}

  let(:status) {:foo}
  let(:template) { {hello: 'world'} }
  let(:controller) {double 'controller', render: nil, flash: flash }
  let(:view_data) {"blah"}
  let(:response_status) {'world'}

  let(:flash) { double("flash", now: flash_now) }
  let(:flash_now) { double("flash_now") }
  let(:flash_object) { instance_double Aldous::Respondable::Shared::Flash, set_error: nil }

  describe "#execute" do
    before do
      allow(Aldous::Respondable::Shared::Flash).to receive(:new){ flash_object }
    end

    it "calls render on controller with the relevant options" do
      expect(controller).to receive(:render).with(template.merge(status: status))
      respondable.execute
    end

    it "tries to set flash" do
      expect(Aldous::Respondable::Shared::Flash).to receive(:new).with(view_data, flash_now)
      respondable.execute
    end

    it "calls set_error on flash object" do
      expect(flash_object).to receive(:set_error)
      respondable.execute
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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