Hiya

Shared examples automatically wrap their examples in a context which includes 
contextual information, but I don’t think shared_context can do that, they’re 
basically more of an “include” of spec parts, you also can’t modify the 
description of the existing context so I think you’d need to change the 
strategy here, or look into modifying shared_context to have some sort of 
metadata the reporter uses.

Cheers
Jon

On Tue, 29 Aug 2023, at 10:00 PM, 'Jason Karns' via rspec wrote:
> We have a shared context that is included automatically by the presence of 
> particular metadata.
> 
> I'm wondering if it's possible for the shared context to append or otherwise 
> mutate the example's description with additional text. (Basically we want 
> presence of the included context to be explicit in the example description 
> itself, as well as to include pieces of the metadata itself.)
> 
> RSpec.describe Something, auth: :customer do
>   it "does thing"
> end
> 
> shared_context "authenticated" do
>   let(:current_user) { logs_in_as self.class.metadata[:auth] }
>   # hoping for a before or around hook that can insert contextual description 
> at this scope of the example
> end
> 
> config.include_context "authenticated", :auth
> 
> Desired result: "Something authenticated as a customer does thing"
> 
> Have others done something similar or have alternatives?
> 
> Thanks,
> Jason Karns
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rspec+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rspec/22e833a2-8cca-45de-8a03-4bd2984eb5ean%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rspec/22e833a2-8cca-45de-8a03-4bd2984eb5ean%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rspec+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/c3de427d-43ac-47d4-b45a-cfddd17f0f64%40app.fastmail.com.

Reply via email to