Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

And after Then should not rerun setup #2

Open
tandrewnichols opened this issue May 21, 2014 · 11 comments
Open

And after Then should not rerun setup #2

tandrewnichols opened this issue May 21, 2014 · 11 comments

Comments

@tandrewnichols
Copy link
Collaborator

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.

@rendro
Copy link
Owner

rendro commented May 21, 2014

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.

@tandrewnichols
Copy link
Collaborator Author

Yeah, that's how jasmine-given works. Let me know how you want to proceed.

@rendro
Copy link
Owner

rendro commented May 21, 2014

I added you as a collaborator. I'd suppose we start on a feature branch to implement this.

@rendro
Copy link
Owner

rendro commented Jul 14, 2014

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!

@tandrewnichols
Copy link
Collaborator Author

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).

@digitalsadhu
Copy link

+1

@digitalsadhu
Copy link

Hey guys. May I tentatively and politely enquire as to if there has been any progress on this? :)

@tandrewnichols
Copy link
Collaborator Author

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.

@rendro
Copy link
Owner

rendro commented Oct 15, 2014

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!

@digitalsadhu
Copy link

k. Thanks for the replies guys.

@searls
Copy link

searls commented Dec 9, 2014

👍 -- 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?

searls added a commit to cabbagejs/cabbage that referenced this issue Dec 9, 2014
It was held up a bit by this issue (requiring a Given -> before)

rendro/mocha-given#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants