Sha256: 7124932b19050506bad9503f7dc27836674a2dce504ae0a7798efc9d1b0175cf

Contents?: true

Size: 1.06 KB

Versions: 31

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Services do

  subject { Locomotive::Steam::Services.build_instance(nil) }

  describe 'configuration with a services hook' do

    before do
      Locomotive::Steam.configure do |config|
        config.services_hook = -> (services) {
          services.repositories = MyService.new
        }
      end
    end

    after { Locomotive::Steam.configure { |c| c.services_hook = nil } }

    it { expect(subject.repositories).to be_instance_of(MyService) }

    describe '#defer' do

      let(:status) { { initialized: false } }

      before do
        Locomotive::Steam.configure do |config|
          config.services_hook = -> (services) {
            services.defer(:repositories) { MyService.new(status) }
          }
        end
      end

      it { subject.repositories; expect(status[:initialized]).to eq false }
      it { subject.repositories.do; expect(status[:initialized]).to eq true }

    end

  end

  class MyService
    def initialize(status = {})
      status[:initialized] = true
    end
    def do; end
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
locomotivecms_steam-1.4.1 spec/unit/services_spec.rb
locomotivecms_steam-1.4.0 spec/unit/services_spec.rb
locomotivecms_steam-1.4.0.rc2 spec/unit/services_spec.rb
locomotivecms_steam-1.4.0.rc1 spec/unit/services_spec.rb
locomotivecms_steam-1.4.0.pre.rc.1 spec/unit/services_spec.rb
locomotivecms_steam-1.3.0 spec/unit/services_spec.rb
locomotivecms_steam-1.3.0.rc2 spec/unit/services_spec.rb
locomotivecms_steam-1.1.2 spec/unit/services_spec.rb
locomotivecms_steam-1.2.1 spec/unit/services_spec.rb
locomotivecms_steam-1.3.0.rc1 spec/unit/services_spec.rb
locomotivecms_steam-1.2.0 spec/unit/services_spec.rb
locomotivecms_steam-1.2.0.rc3 spec/unit/services_spec.rb
locomotivecms_steam-1.2.0.rc2 spec/unit/services_spec.rb
locomotivecms_steam-1.2.0.rc1 spec/unit/services_spec.rb
locomotivecms_steam-1.2.0.beta1 spec/unit/services_spec.rb
locomotivecms_steam-1.1.1 spec/unit/services_spec.rb
locomotivecms_steam-1.1.0 spec/unit/services_spec.rb
locomotivecms_steam-1.1.0.rc3 spec/unit/services_spec.rb
locomotivecms_steam-1.1.0.rc2 spec/unit/services_spec.rb
locomotivecms_steam-1.1.0.rc1 spec/unit/services_spec.rb