Sha256: 6568e1abf321cb08041c161da341dabca6c5355a6c5f8c594b92382820283a71

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe "Execution" do

  Given(:stack) { Modware::Stack.new(env: [:result]) }

  context "when start with no implementation" do

    When(:env) { stack.start result: [] }

    Then { expect(env).to have_failed(Modware::StackError, /implementation/) }
  end

  context "when start with base implementation" do

    When(:env) { stack.start(result: []) { |env| env.result << :base } }

    Then { expect(env.result).to eq [:base] }

    context "if add middleware1" do

      Given { stack.add Factory.middleware(1, around: nil) }

      Then { expect(env.result).to eq [:before1, :implement1, :after1 ] }

      context "if add middleware2" do

        Given { stack.add Factory.middleware(2, implement: nil) }

        Then { expect(env.result).to eq [:before1, :before2, :around_pre2, :implement1, :around_post2, :after1, :after2 ] }

        context "if add middleware3" do

          Given { stack.add Factory.middleware(3, around: nil, implement: nil) }

          Then { expect(env.result).to eq [:before1, :before2, :before3, :around_pre2, :implement1, :around_post2, :after1, :after2, :after3 ] }
        end
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
modware-1.0.2 spec/execution_spec.rb
modware-1.0.1 spec/execution_spec.rb
modware-1.0.0 spec/execution_spec.rb