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.

To complicate matters more, the concurrency solution should be compatible 
with an rspec test of this kind of data driven design (unless you can 
provide an alternate data driven design approach to the linked 
example): 
http://stackoverflow.com/questions/31375083/structuring-a-csv-data-driven-test-with-rspec-the-basic-simple-way

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

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/9ea305ef-7601-48c8-a691-dcf4ecc4e751%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to