Say I have a test design like below, for sample code, how should I structure it to get it working correctly within rspec? I'm still a relative novice to rspec and ruby. I know the way I've written the example code, the it test block is not valid and needs to be put in correct scope. But I'm not aware what's the best approach to restructure based on the intent of the test. As regular Ruby code, that should work fine, just not as an rspec test.
require 'rspec'
describe "actual case scenario using concurrency in test process", :simple do
def produce_stuff
# the code, note that this code itself is not Ruby specific
# but rather Ruby library code or even like system shell calls
# to call some infrastructure stuff that produces streaming data
end
def consume_and_validate_the_stuff
# test validation code within this block
it "description here" do
#consume/fetch the produced streaming live data, etc.
#then assert/validate the actual data/state against expected
expect(false).to eql(true)
end
end
=begin
Test a scenario that requires performing some actions
and concurrently validating the actions in tandem.
Assume not possible to validate after the action as the data
is processed live and not queued for test access after the fact,
e.g. live streaming data in test environment with multiple consumers
(besides the current test). And fetching that data as old archived data
via offsets is problematic to get it right in sync (e.g. using the right
offsets, etc.)
=end
pt=Thread.new{produce_stuff()}
ct=Thread.new{consume_and_validate_the_stuff()}
pt.join
ct.join
end