[Ironruby-core] ScratchPad versus Channel in RubySpec

Shri Borde Shri.Borde at microsoft.com
Wed Jan 7 03:32:14 EST 2009


Many tests use Channel to collect data that needs to be tested. For example, the following in inspect_spec.rb.

  compliant_on(:ruby) do
    it "reports aborting on a killed thread" do
      c = Channel.new
      t = Thread.new { c << Thread.current.inspect; Thread.stop }
      c.receive.should include('run')
      t.inspect.should include('sleep')
      Thread.critical = true
      t.kill
      t.inspect.should include('aborting')
      Thread.critical = false
    end
  end

However, there is also ScratchPad which serves the same purpose. Why are there two ways of doing this, and which is the preferred one?

Also, (as we were discussing before), why does every test have to call ScratchPad.clear before using it. Shouldn't MSpec be doing this automatically?

Thanks,
Shri

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090107/241e5c5f/attachment.html>


More information about the Ironruby-core mailing list