examples/primes/spec/primes_spec.rb in royw-drbman-0.0.1 vs examples/primes/spec/primes_spec.rb in royw-drbman-0.0.2

- old
+ new

@@ -1,8 +1,10 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require 'primes' +# Note, these assume you have an ssh public key set up for +# this box (i.e: it does an "ssh localhost"). describe('SieveOfEratosthenes') do before(:each) do @choices = {} @logger = Log4r::Logger.new('primes_spec') @@ -12,13 +14,22 @@ it 'should find [2,3,5,7,11,13,17,19] for n=20' do @choices[:max_integer] = 20 sieve = Primes.new(@logger, @choices) sieve.execute.should == [2,3,5,7,11,13,17,19] end - it 'should take a while' do - sieve = SieveOfEratosthenes.new(10000000, @choices, @logger) - primes = sieve.execute - puts "#{primes.length} primes found" - primes.length.should == 664579 + + it 'should find 303 primes below 2000 with single host' do + @choices[:max_integer] = 2000 + @choices[:hosts] = ['localhost'] + sieve = Primes.new(@logger, @choices) + sieve.execute.length.should == 303 end + + it 'should find 303 primes below 2000 with two hosts' do + @choices[:max_integer] = 2000 + @choices[:hosts] = ['localhost', 'localhost'] + sieve = Primes.new(@logger, @choices) + sieve.execute.length.should == 303 + end + end