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

Dynamic injection in metadata object #19

Open
mickaeltavares opened this issue Sep 27, 2023 · 4 comments
Open

Dynamic injection in metadata object #19

mickaeltavares opened this issue Sep 27, 2023 · 4 comments

Comments

@mickaeltavares
Copy link

Hi !

I am trying to add some runtime data (like how much time does my test setup takes?) inside the metadata object. After some investigation, I figured I could access the metadata object inside each test, but I cannot find a way to write in it.

it 'logs metadata object' do
  puts metadata # {}
end

Using tags works fine, but they are not dynamic:

it 'logs metadata object with tags', hello: 'you' do
  puts metadata # {:hello=>"you"}
end

Adding to metadata won't work:

it 'add to metadata object does not work', hello: 'you' do
  metadata[:testing_something] = 'This will not appear'
  metadata[:setup_timer] = @setup_timer # computed between before_setup and after_setup hooks
  puts metadata # {:hello=>"you"}
end

Is there a way to inject such data in metadata?
Thanks!

@ordinaryzelig
Copy link
Owner

I'll take a look when I get a chance.

@mickaeltavares
Copy link
Author

Hi !
Thank you for your response!

I've tried to play around the limitation described above today, and I found that calling metadata was using MinispecMetadata::It#metadata, which seems immutable.
I tried uninstalling the gem to run the same test: calling metadata is using Minitest::Runnable#metadata which is mutable as expected.

Thus, I believe something in MinispecMetadata is making metadata immutable or frozen somehow. It really feels like a bug.

Hope this helps 😉

@mickaeltavares
Copy link
Author

Hi @ordinaryzelig, any news on that subject 😇?

@ordinaryzelig
Copy link
Owner

I'm sorry, I haven't had any time to look into this.

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

2 participants