K, ScratchPad clear: MSpec doesn''t provide any contracts. It is up to
the user to clear his own state. This also allows for a test to use ScratchPad
across multiple examples. ScratchPad is only meant to be a formalized global
variable.
Channel is actually a part of Rubinius''s standard library (IIRC).
Ideally, the tests don''t rely on anything more than basic language
features, so we should try to keep usage of Standard Library to a minimum. I
only use stdlib''s that are required for MSpec''s runner, such
as FileUtils.
JD
From: Shri Borde
Sent: Wednesday, January 07, 2009 12:32 AM
To: Jim Deville
Cc: ironruby-core at rubyforge.org
Subject: ScratchPad versus Channel in RubySpec
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/47ed9900/attachment.html>