Testing with Therie
Therie is a small and simple behavioral-style testing suite that comes with Atomy.
> use("therie") #<Atomy::Module 'therie.ay'>
Structure
Run tests
and keep track of how many passed and how many failed,
printing the stats at the end and returning them.
Example:
> theorize: describe("foo"): it("does x"): true should-be(true) - foo ✓ does x total of 1 tests (1 passed, 0 failed) #<therie.ay::Stats:0x5c680> > theorize: describe("foo"): it("does x"): true should-be(false) - foo ✗ does x ` RuntimeError: expected false, got true /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/dynamic.ay:48:in `send_message' /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/therie.ay:92:in `' wrapper+22:in `should_be' therie:1:in `__module_init__' /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/therie.ay:59:in `' total of 1 tests (0 passed, 1 failed) #<therie.ay::Stats:0x5cc0c>
describe(what) &body => nil
Logically group together a set of behavior.
Prints out what
, with each test in body
indented afterward.
Example:
> describe("foo"): it("does x"): true should-be(false) - foo ✗ does x ` RuntimeError: expected false, got true /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/dynamic.ay:48:in `send_message' /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/therie.ay:92:in `' wrapper+22:in `should_be' therie:1:in `__module_init__' /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/therie.ay:59:in `' nil > describe("foo"): it("does x"): true should-be(true) - foo ✓ does x nil
it(description) &tests => nil
Describe some behavior that body
will demonstrate.
Example:
> it("adds correctly"): (2 + 2) should-be(4) ✓ adds correctly nil > it("adds correctly"): (1 + 2) should-be(4) ✗ adds correctly ` RuntimeError: expected 4, got 3 /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/dynamic.ay:48:in `send_message' /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/therie.ay:92:in `' wrapper+22:in `should_be' therie:1:in `__module_init__' /Users/Alex/.rbenv/versions/rbX-1.9/gemsets/atomy/gems/atomy-0.3/kernel/therie.ay:59:in `' nil
Tests
~x should: ~*check
Test that check
is satisified by x
by evaluating it with
x
as self
.
x should-be(y) => nil
Test for x == y
.
x should-raise(y) => nil | x respond-to(.call)? | y is-a(Class)?
Test that executing x
will raise an exception of class y
.
Example:
> { abc } should-raise(NoMethodError) nil > { .ok } should-raise(NoMethodError) RuntimeError: #should-raise - no exception raised
x should-error(y) => nil | x respond-to(.call)? | y is-a(Class)?
Test that executing x
will signal an error of class y
.
Example:
> { error(.foo) } should-error(SimpleError) nil > { .ok } should-error(SimpleError) RuntimeError: #should-error - no error signaled