Skip to content

Commit

Permalink
Add failing spec for #200.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Sep 26, 2013
1 parent ab6fc9a commit 3824018
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/acceptance/threading_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ def recorded_content_for(name)
expect(recorded_content_for("search") +
recorded_content_for("foo")).to include("query: thread", "FOO!")
end

def make_multiple_threaded_requests(num_threads)
VCR.use_cassette("threaded") do
num_threads.times.map do |i|
Thread.new do
Thread.current.abort_on_exception = true
Excon.get("http://localhost:#{VCR::SinatraApp.port}/search?q=#{i}").body
end
end.map(&:value)
end
end

it 'can safely use one cassette across multiple threads' do
num_threads = 50
recorded = make_multiple_threaded_requests(num_threads)
expect(recorded).to eq(num_threads.times.map { |i| "query: #{i}" })

played_back = make_multiple_threaded_requests(num_threads)
expect(played_back).to eq(recorded)
end
end
end

0 comments on commit 3824018

Please sign in to comment.