Sha256: b61274cad9f181ae6112e95afad3f298b2c215b9bd2041b8ef83075c5c9b353a

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe S3Website::Parallelism do
  context 'user has disabled parallelism' do
    before(:all) {
      @original_disable_state = ENV['disable_parallel_processing']
      ENV['disable_parallel_processing'] = 'true'
    }

    after(:all) {
      ENV['disable_parallel_processing'] = @original_disable_state
    }

    it 'runs things sequentially' do
      ints = (0..100).to_a
      after_processing = []
      S3Website::Parallelism.each_in_parallel_or_sequentially(ints) { |int|
        after_processing << int
      }
      ints.should eq(after_processing)
    end
  end

  context 'user has not disabled parallelism' do
    before(:all) {
      @original_disable_state = ENV['disable_parallel_processing']
      ENV.delete 'disable_parallel_processing'
    }

    after(:all) {
      ENV['disable_parallel_processing'] = @original_disable_state if @original_disable_state
    }

    it 'runs things in parallel' do
      ints = (0..100).to_a
      after_processing = []
      S3Website::Parallelism.each_in_parallel_or_sequentially(ints) { |int|
        after_processing << int
      }
      ints.should_not eq(after_processing) # Parallel processing introduces non-determinism
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
s3_website-1.0.0 spec/lib/parallelism_spec.rb
s3_website-0.4.0 spec/lib/parallelism_spec.rb
s3_website-0.3.0 spec/lib/parallelism_spec.rb
s3_website-0.2.1 spec/lib/parallelism_spec.rb
s3_website-0.2.0 spec/lib/parallelism_spec.rb
s3_website-0.1.0 spec/lib/parallelism_spec.rb