All right, I am currently considering an alternate approach, in which someone can
Rspec.describe MyFancyStuff do ... # In any (nested or not) ExampleGroup: require 'prop_check/rspec' extend PropCheck::RSpec ... end to bring not only `forall` into scope, but also override `before/after/around` to handle one extra context, which I have tentatively called `:each_prop_check_iteration`. The thing I am currently struggling with however, is how to correctly keep track of the blocks that someone wants to add as hooks, and then to call them correctly from within an example context (Or, to be precise: From within a block within an `it "description" do ... end`) At first I attempted adding instance methods, which did not work because each example runs its own instance. Then I attempted working with class-methods on the ExampleGroup, which did not work because by default when an example runs it prevents methods that are not part of the `ExampleGroup` class itself from being run, raising a WrongScopeError (see e.g. https://github.com/rspec/rspec-core/blob/2a62a644b52536d44a7969b5c5b69077a35687ca/lib/rspec/core/example_group.rb#L730). Then I tried adding it to the `metadata`, but you do not have access to it from within a running example unless you have full control over the block that `it` is being called with (the only way to access the example's metadata is if you specify a parameter to the block you pass to `it`). -- What would be the way to accomplish this? On Saturday, June 29, 2019 at 3:23:08 PM UTC+2, Jon Rowe wrote: > > Yes it would be fairly involved. The most seamless way would be to create > and run example groups and examples yourself using that custom formatter, > then feeding back into the existing run cycle. You can see why this hasn’t > been tackled to satisfaction before! > > Jon Rowe > --------------------------- > [email protected] <javascript:> > jonrowe.co.uk > > On 29 June 2019 at 10:44, Wiebe-Marten Wijnja wrote: > > Thank you for your response. This seems like quite a big undertaking. > Also, would having a custom formatter mean that it would be impossible for > people to use their *own* custom formatter? > > I think for now I'll choose the easier (but slightly less satisfying) > approach of having the user specify lifecycle methods in the property > itself explicitly. (And maybe have a custom way to run the same > before/after actions for a whole group of property tests.) > > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/137c25ae-151c-4470-918c-611f62f421c6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
