Created
July 20, 2015 19:10
-
-
Save hobodave/68b96890a8f0b36c60ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
class Bar | |
def self.bar(num) | |
puts "#{num}: Called!" | |
end | |
end | |
class Foo | |
def self.foo(num = 100) | |
threads = [] | |
(1..num).each do |i| | |
threads << Thread.new do | |
Bar.bar(i) | |
end | |
end | |
threads.map(&:join) | |
end | |
end | |
describe Foo do | |
context 'many' do | |
100.times do | |
it 'works' do | |
num = 2 | |
#allow(Thread).to receive(:new).and_yield.and_return(Thread.new {}) | |
expect(Bar).to receive(:bar).exactly(num).times.and_call_original | |
Foo.foo(num) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment