Skip to content

Commit

Permalink
added test::unit to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuddy committed Dec 5, 2009
1 parent ce6e4b7 commit d2a8b49
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Simple BDD API for testing asynchronous Ruby/EventMachine code
(c) 2008 Aman Gupta (tmm1)

em-spec can be used with either bacon or rspec.
em-spec can be used with either bacon, test unit or rspec.

=Rspec
There are two ways to use the Rspec extension. To use it as a helper, include EM::SpecHelper in your describe block. You then use the em method to wrap your evented test code. Inside the em block, you must call #done after your expectations. Everything works normally otherwise.
Expand Down Expand Up @@ -76,6 +76,36 @@ The API is identical to Bacon, except that you must explicitly call 'done' after

end

=Test::Unit
There are two ways to use the Test::Unit extension. To use it as a helper, include EM::TestHelper in your test unit class. You then use the em method to wrap your evented test code. Inside the em block, you must call #done after your expectations. Everything works normally otherwise.

class EmSpecHelperTest < Test::Unit::TestCase

include EventMachine::TestHelper

def test_trivial
em do
assert_equal 1, 1
done
end
end
end

The other option is to include EM::Test in your test class. This will patch Test::Unit so that all of your examples run inside an em block automatically:

class EmSpecTest < Test::Unit::TestCase

include EventMachine::Test

def test_timer
start = Time.now

EM.add_timer(0.5){
assert_in_delta 0.5, Time.now-start, 0.1
done
}
end
end

Resources:

Expand Down

0 comments on commit d2a8b49

Please sign in to comment.