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

replace around with hooks #9

Closed
wants to merge 1 commit into from
Closed

replace around with hooks #9

wants to merge 1 commit into from

Conversation

grosser
Copy link
Owner

@grosser grosser commented Jun 5, 2015

No description provided.

@grosser
Copy link
Owner Author

grosser commented Jun 6, 2015

@splattael what do you think of putting this into minitest-around so an alternative is out there as gem ?

@Nakilon
Copy link

Nakilon commented Jun 18, 2023

So it's not implemented?
Wanted to use maxitest in a long integration test and discovered it seems to be incompatible with -hooks:

require "maxitest/autorun"
require "minitest/hooks"

describe "" do
  before :all do
    p :all
  end
  it "1" do p 1 end
  it "2" do p 2 end
end
:all
1
.:all
2
.

UPD: Oh wait, I guess I'm doing something wrong. It is the same with plain minitest either. Am I misusing the dsl?

@grosser
Copy link
Owner Author

grosser commented Jun 18, 2023

do you need to use minitest/hooks ?

@grosser
Copy link
Owner Author

grosser commented Jun 18, 2023

ah same without :/

@grosser
Copy link
Owner Author

grosser commented Jun 18, 2023

ah yeah that never worked ... I think the argument is just ignored, would be nice to raise argumenterror
... let_all can help ... just call it in before to get the same behavior

@grosser
Copy link
Owner Author

grosser commented Jun 18, 2023

and a PR to make before/after raise or even support :each + :all would be nice ... could reuse let_all under the hood ...

@Nakilon
Copy link

Nakilon commented Jun 18, 2023

  let_all :_ do
    p :all
  end
  before do
    _
  end

works! Thank you for a quick response.

@Nakilon
Copy link

Nakilon commented Jun 18, 2023

This hack is weird though in the way that if there was an exception in let_all it gets reevaluated for every example.

@grosser
Copy link
Owner Author

grosser commented Jun 18, 2023

maybe don't call it _ to avoid 👁️ ♋ :D

@grosser
Copy link
Owner Author

grosser commented Jun 18, 2023

yeah, but caching exceptions is also super weird :)

@Nakilon
Copy link

Nakilon commented Jun 18, 2023

Some workaround to not reevaluate if failed:

describe "" do

  let_all :before_all do
    p :all
    fail
    true
  rescue
  end
  before{ before_all or fail }

  it "1" do p 1 end
  it "2" do p 2 end
end
:all
EE

@Nakilon
Copy link

Nakilon commented Jun 18, 2023

Or even

  let_all :before_all do
    p :all
    fail "all"
    false
  rescue
    $!
  end
  before{ before_all and fail before_all }

to reraise the caught error.

@grosser
Copy link
Owner Author

grosser commented Jun 18, 2023

#53 to block these broken cases and add before :all looks good ?

@grosser grosser closed this Jun 24, 2023
@grosser
Copy link
Owner Author

grosser commented Jun 24, 2023

afaik this is not doable atm without making the ordering un-intuitive
created new issue for continued discussion #54

@grosser grosser deleted the grosser/hooks branch June 24, 2023 16:12
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 this pull request may close these issues.

2 participants