Rustspec-assertions build status

This is an attempt to port a syntax similar to rspec or chai to rust.

I find the errors rust's built-in assert! gives pretty limited, and I personally like this sort of syntax better so I decided to start this as learning exercise.

Usage

You'll need to use rust's nightly builds, as the beta/stable builds don't support the syntax extensions yet.

Add this as a dependency to your Cargo.toml and run cargo build:

[dependencies.rustspec_assertions] git = "https://github.com/uorbe001/rustspec-assertions.git"

Now you should be able to use these assertions in your tests by 'using' them:

```

[phase(plugin, link)] extern crate rustspec_assertions;

use self::rustspecassertions::{expect, bele, eq, belt, begt, bege, contain, betrue, befalse, besome, be_none};

[test]

fn beleinttest() { expect(1i).to(bele!(2i)); }

[test]

fn eqf64test() { expect(1.1f64).to(eq!(1.1f64)); } ```

The crate relies on macros to be able to report better errors, so you'll need to add this to your test.rs, lib.rs or main.rs file:

```

![feature(phase)]

```

Matchers

Here are some of the matchers already implemented:

expect(2i).to(eq!(2i)); expect(2i).not_to(eq!(3i)); // not_to works with all the matchers expect(3i).to(be_gt!(2i)); expect(3i).to(be_ge!(3i)); expect(2i).to(be_lt!(3i)); expect(2i).to(be_le!(2i)); expect(vec![1i, 2i]).to(contain!(2i)); expect(true).to(be_true!()); expect(false).to(be_false!()); expect(Some(1i)).to(be_some!()); expect(None::<int>).to(be_none!());

For a complete list of matchers and more examples, please check the tests.

Rustspec Note

This is designed to work with rustspec so I might end up making decisions further down the line to improve error reporting which might not be ideal for other options.