Sha256: dfd23485aca740478ecb2d33a98df4208ad042ab9aac899bfeeda65c4d43ab90

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

# typed: false
# frozen_string_literal: true

require './spec/spec_setup'
require 'parallel'
require 'frontman/config'
require 'frontman/iterator'

describe Frontman::Iterator do
  before(:each) do
    Frontman::Config.all.keys.each do |key|
      Frontman::Config.delete(key)
    end
  end

  it 'should run in parallel by default' do
    expect(Parallel).to receive(:map)

    Frontman::Iterator.map []
  end

  it 'should not run in parallel if config says so' do
    expect(Parallel).to_not receive(:map)
    Frontman::Config.set :parallel, false

    Frontman::Iterator.map []
  end

  context 'processor count' do
    it 'should take the config value if not running in parallel' do
      Frontman::Config.set :parallel, false
      Frontman::Config.set :processor_count, 2

      expect(Frontman::Iterator.processor_count).to eq 2
    end

    it 'should use Parallels method if running in parallel' do
      expect(Frontman::Iterator.processor_count).to eq Parallel.processor_count
    end

    it 'should default to 1 if not running in parallel and no config is provided' do
      Frontman::Config.set :parallel, false

      expect(Frontman::Iterator.processor_count).to eq 1
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
frontman-ssg-0.1.1 spec/frontman/iterator_spec.rb
frontman-ssg-0.1.0 spec/frontman/iterator_spec.rb
frontman-ssg-0.0.4 spec/frontman/iterator_spec.rb
frontman-ssg-0.0.3 spec/frontman/iterator_spec.rb
frontman-ssg-0.0.2 spec/frontman/iterator_spec.rb