And after Then should not rerun setup
I use jasmine-given at work (and have even worked with Justin Searls on writing some parts of it), and one of the fundamental goals is to only run setup (Given, When) once per Then. I've noticed in my tests using mocha-given that
Then -> testSomething()
And -> testSomethingElse()
will run all Givens and Whens twice. Which kind of defeats the purpose. Now, to only run setup once, instead of getting the nice formatting of cascading Ands, I have to put everything in one giant Then block. If you check out https://github.com/searls/jasmine-given/blob/master/app/js/jasmine-given.coffee#L50 and https://github.com/searls/jasmine-given/blob/master/app/js/jasmine-given.coffee#L82, the subsequentThen mechanism tacks And functions on so that they're executed as part of the same it statement.
In other words I want to do something like:
Given -> @foo = 'bar'
When -> @subject.test()
Then -> expect(@foo).to.equal 'not bar'
And -> expect(@subject.aSpiedOnMethod).to.have.been.called
And -> expect(@someOtherStuff).to.have.happened()
and have the Given and When run once instead of three times.
I'm willing to work on this (or work on this with you) if you want.
This sounds good. I'd like to keep mocha-given as close to jasmine-given as possible to to make it exchangeable at any point.
To get it right, this means, two Thens will execute the Given and When twice, but a Then and And will execute the Given and When only once?
If you feel like working on this with me, I'd be more than happy.
Yeah, that's how jasmine-given works. Let me know how you want to proceed.
I added you as a collaborator. I'd suppose we start on a feature branch to implement this.
I created a feature branch with some code cleanup: https://github.com/rendro/mocha-given/tree/feature/subsequent-then
I am looking forward to see some contributions!
Cool. I had started to look at it at one point but didn't make much progress and have been busy lately. Hopefully I can come back to it soon (since I use this in all my node projects now).
+1
Hey guys. May I tentatively and politely enquire as to if there has been any progress on this? :)
Hey @digitalsadhu, I did some work on it a while back, but it proved to be slightly more complicated than I thought. It's still on my radar . . . not sure if @rendro has looked at it at all. But thanks for the reminder, I do want to see this get finished.
Hey, I looked at it as well, but I moved abroad recently and had a bit of a busy time. I will put this issue back on my todo list!
k. Thanks for the replies guys.
:+1: -- I am using mocha-given for the first time and this is exciting to see my project ported!
However I just hit a bit of a wall due to this issue. D'oh. I wonder why it affects mocha-given and not jasmine-given?