# Test::Unit advice - blocking method

**URL:** <https://www.ruby-forum.com/t/test-unit-advice-blocking-method/172110>\
**Category:** Ruby\
**Created:** [July 15, 2009, 12:46am UTC](https://www.ruby-forum.com/t/test-unit-advice-blocking-method/172110 "2009-07-15T00:46:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [July 15, 2009, 12:46am UTC](https://www.ruby-forum.com/t/test-unit-advice-blocking-method/172110/1 "2009-07-15T00:46:03Z")

</div>

Hi all,

I’ve got a method in the win32-clipboard library,  
Clipboard.notify\_change,  
that blocks until something changes in the clipboard. But I’m not sure  
how  
to test it.

Basically, here’s what I’m trying to accomplish:

def test\_notify\_change  
assert\_nothing\_raised{ Clipboard.notify\_change } # This will block  
until something happens  
assert\_nothing\_raised{ Clipboard.set\_data(‘test’) } # This should  
trigger  
the notify\_change method  
end

I tried using a thread within the test itself but it didn’t work right.  
I  
was probably doing something wrong.

Any suggestions?

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [July 15, 2009, 9:38pm UTC](https://www.ruby-forum.com/t/test-unit-advice-blocking-method/172110/2 "2009-07-15T21:38:38Z")

</div>

> I tried using a thread within the test itself but it didn’t work right.  
> I  
> was probably doing something wrong.
> 
> Any suggestions?

maybe use 1.9 with thread\_blocking\_region’s? Maybe use two processes?  
Just thinking out loud.  
=r
