Sha256: 3cd0128a17c69460fe5596773bc704705f31b5c543b3176da64f93f3ca116e5b

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

RSpec.describe Aldous::Controller::Action::ResultExecutionService do
  let(:result_execution_service) {described_class.new(controller, respondable, default_view_data)}

  let(:controller) {double "controller", view_context: view_context}

  let(:view_context) {double "view_context"}

  let(:respondable) do
    double "respondable", {
      action: action
    }
  end

  let(:default_view_data) { {hello: 'world'} }

  let(:action) {double 'action', execute: nil}

  describe "::perform" do
    subject(:perform) {described_class.perform(controller, respondable, default_view_data)}

    let(:result_execution_service) {double "result_execution_service", perform: nil}

    before do
      allow(described_class).to receive(:new).and_return(result_execution_service)
    end

    it "instantiates the result execution service" do
      expect(described_class).to receive(:new).with(controller, respondable, default_view_data)
      perform
    end

    it "performs the result execution service" do
      expect(result_execution_service).to receive(:perform)
      perform
    end
  end

  describe "#perform" do
    subject(:perform) {result_execution_service.perform}

    it "fetches the action from the complete respondable" do
      expect(respondable).to receive(:action).with(controller)
      perform
    end

    it "executes the complete respondable action" do
      expect(action).to receive(:execute)
      perform
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aldous-1.1.3 spec/aldous/controller/action/result_execution_service_spec.rb
aldous-1.1.2 spec/aldous/controller/action/result_execution_service_spec.rb