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

before :all / after :all / around :all support #7

Closed
jeremyevans opened this issue May 10, 2015 · 11 comments
Closed

before :all / after :all / around :all support #7

jeremyevans opened this issue May 10, 2015 · 11 comments

Comments

@jeremyevans
Copy link

This is mentioned in the TODO in the README. You may want to look into integrating minitest-hooks (https://github.com/jeremyevans/minitest-hooks) instead of minitest-around, as minitest-hooks has support for before :all / after :all / around :all hooks, as well as around hooks, and doesn't implement around via Fiber hacks.

@splattael
Copy link

minitest-hooks looks really nice! :)

Does it support the spec version of around? On https://github.com/jeremyevans/minitest-hooks/blob/master/spec/minitest_hooks_spec.rb#L25 def around is used which is not very spec-like, isn't?

@jeremyevans
Copy link
Author

I can add support for the spec version of around/around(:all) to minitest-hooks. It can get a little tricky to use though, because you need to use define_method, and super/yield semantics are different inside define_method methods compared to normally defined methods.

But this will give people the option to use the DSL version and avoid defining the method manually.

@grosser
Copy link
Owner

grosser commented May 11, 2015

This around/all problem is pretty nasty, so I have my doubts that minitest-hooks passes all the tests of minitest-around and all the tests in my try on implementing before/after-all hooks #5

If you get minitest-around test-suite to run with minitest-hooks I'm all in favor of switching it though :)

@jeremyevans
Copy link
Author

I've pushed out a 1.1.0 release of minitest-hooks that adds support for block-based around/around(:all) hooks:

  around(:all) do |&block|
    DB.transaction(:rollback=>:always){super(&block)}
  end

  around do |&block|
    DB.transaction(:rollback=>:always, :savepoint=>true, :auto_savepoint=>true){super(&block)}
  end

@grosser Have you looked at the minitest-hooks implementation and specs? I checked and it does pass the before/after all specs from #5 (I removed the order_dependent! call as that isn't in standard minitest), here's the test output:

BEFORE ALL A -- from let
BEFORE A -- true
AFTER A
.BEFORE A -- true
AFTER A
.AFTER ALL A -- from let
BEFORE ALL A -- from let
BEFORE ALL B -- from let
BEFORE A -- true
BEFORE B -- true
AFTER B
AFTER A
.BEFORE A -- true
BEFORE B -- true
AFTER B
AFTER A
.AFTER ALL B -- from let
AFTER ALL A -- from let

minitest-hooks has a different API than minitest-around, since minitest-around passes an argument that you have to call, while minitest-hooks just defines a method that allows you to call super. So I couldn't test directly with minitest-around specs. But if you come across something that doesn't work, please open an issue in minitest-hooks.

@splattael
Copy link

@jeremyevans Great work! Let me see if I can run RSpec based fixtures from minttest-around.
If they pass I happily switch to minutest-hooks and abandon mine :)

@grosser
Copy link
Owner

grosser commented May 12, 2015

the around seems to be working with some minor ordering issues

jeremyevans/minitest-hooks#1

@grosser
Copy link
Owner

grosser commented Jun 1, 2015

please check out: #8

  • no Fibers
  • minitest-around / rspec syntax
  • multiple around/before/after per class
  • no before/after :all since they are redone before and after each subclass which is misleading ... use let_all for reliable global state
  • around is run before everything, does not maintain order of before and afters ... that puts us back to exactly where minitest-around was before the refactor to fibers, right ? refactor splattael/minitest-around#11

@grosser
Copy link
Owner

grosser commented Jun 5, 2015

and another one ... this time replacing around with hooks + making it play nice with multiple blocks and not needing to include it by hand

#9

@grosser
Copy link
Owner

grosser commented Aug 30, 2021

reopening since this would still be nice to have

@grosser
Copy link
Owner

grosser commented Jun 18, 2023

adding before :all since that was easy
blocking after :all / around :all since they are traps from minitest atm

#53

@grosser
Copy link
Owner

grosser commented Jun 24, 2023

created new issue for after :all and around :all
#54

@grosser grosser closed this as completed Jun 24, 2023
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

3 participants