noonat/pecs

Given, When, Then syntax

Opened this issue · 0 comments

I am pretty interested in using a similar DSL to rspec given and jasmine given but in php.
I was wondering about trying to write some sort of plugin for pecs to do this but not sure how doable such a thing would be.

Ideally tests would look like:

describe('assigning stuff to this', function () {
  given(function () { $this->number = 24; })
  given(function () { $this->number++; })
  when(function () { $this->number *= 2; })
  then(function () { expect($this->number).to_equal(50); })
})

Perhaps it would be possible to do some introspection and dependency injection of return values from previous given, when or then functions into following ones?

Any ideas?

Refs: