railsware / Sleipnir

BDD-style framework for Swift
http://railsware.com/blog/2014/07/04/bdd-style-testing-in-swift-with-sleipnir
MIT License
844 stars 48 forks source link

beNil matcher and Optional #4

Closed kostiakoval closed 10 years ago

kostiakoval commented 10 years ago

I want to check that object is or not nil. expect does not support optional values.

let object:Int?
it("shold work") {
expect(object).toNot(beNil())
let object:Int?
it("shold work") {
expect(object).to(equal(object))

I was trying to implement that matcher but did't manage to do that. :(

atermenji commented 10 years ago

I plan to add it soon. beNil matcher along with some other useful matchers are on our nearest roadmap, you can check TODO section in README

atermenji commented 10 years ago

I've just pushed the implementation. Now you can write:

let object: Int?
it("should work")  {
  expect(object).to(beNil())
}

let value: Int? = 3
it("should work")  {
  expect(value).toNot(beNil())
}

See the corresponding BeNilSpec for example