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

Add the ability to set up variables on the describe block #44

Closed
Risto-Stevcev opened this issue Apr 1, 2017 · 6 comments · Fixed by #83
Closed

Add the ability to set up variables on the describe block #44

Risto-Stevcev opened this issue Apr 1, 2017 · 6 comments · Fixed by #83

Comments

@Risto-Stevcev
Copy link
Contributor

If you have some state you want to test in multiple it blocks, instead of having to instantiate it multiple times, it would be nice to be able to do it once in the describe block for those specs. Ie:

describe "some state" do
  someRef <- readSTRef myRef
  someArray <- freeze mySTArray

  it "should have this property" do
    ...

  it "should have that property" do
    ...
@owickstrom
Copy link
Collaborator

Could this be a variant of #43, if we separate beforeEach/before, and afterEach/after?

@Risto-Stevcev
Copy link
Contributor Author

I guess it depends on how it's implemented. If before and after look similar to it, then the variables wouldn't be in scope to use it in this way

@owickstrom
Copy link
Collaborator

owickstrom commented Apr 2, 2017

Yes. I'd like for before and after to make it blocks be functions instead. For every before/each you nest, the it blocks get a new argument:

describe "some state" $ before readRef $ before readArray $ do

  it "should have this property" $ \ref array -> do
    ...

  it "should have that property" $ \ref array -> do
    ...

Not sure the current design makes that very simple to implement, but I think it would be very nice to have. :)

@felixSchl
Copy link
Collaborator

To me, hspec's hooks API looks like a good idea to mirror to achieve this: https://hackage.haskell.org/package/hspec-2.4.3/docs/Test-Hspec.html#t:ActionWith.

I don't think it would be terribly hard to make this happen. I wish I had the time to tinker with this, looks like a fun task

@owickstrom
Copy link
Collaborator

@felixSchl Thanks, will have a look at it.

I hope I can find some time, too. It does not look very bright in the coming week. :/

@owickstrom
Copy link
Collaborator

Still, I have no time to work on this. Anyone who wants to give it a shot?

@felixSchl felixSchl mentioned this issue May 25, 2017
6 tasks
@safareli safareli mentioned this issue Jan 10, 2019
2 tasks
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

Successfully merging a pull request may close this issue.

3 participants