Hi Jon, I don’t think the original code looks like your example. It has the method definition **inside** the “thing do” block.
> On Jun 25, 2020, at 7:30 AM, Jon Rowe <[email protected]> wrote: > > Hi Evan > > What I mean by standing ruby scoping are the rules surrounding how and when a > variable is accessible. > > When a block is defined that takes variables, those variable names are > considered to be local to the block (the same as a normal local variable) so > are only available within that "scope” e.g. > > thing do |local_variable| > > # local variable is fine here > > method_name do > # local variable is fine here too, but not in the method definition > end > end > > # but local_variable does not exist here > > def method_name > # nor does local_variable exist here > end > > Hope that helps! > Cheers > Jon Rowe > --------------------------- > [email protected] > jonrowe.co.uk > > On 25 June 2020 at 02:56, Evan Brodie wrote: >> I admit that I don't fully understand the example you provided. I'm not sure >> how it translates into RSpec code, nor what the connection is to "standard >> Ruby scoping". >> >> Anyhow, what I got out of this thread is that "accessing shared example >> block variables in a defined method is not possible". I'll use strategies >> such as exposing the variable in a let variable or passing the values as >> method parameters. Thank you all for the help. >> >> On Wednesday, June 24, 2020 at 7:16:37 AM UTC-4, Jon Rowe wrote: > > -- > 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] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rspec/dejalu-217-93435473-ca39-406a-9ba5-8eb3ad02a4bb%40jonrowe.co.uk > > <https://groups.google.com/d/msgid/rspec/dejalu-217-93435473-ca39-406a-9ba5-8eb3ad02a4bb%40jonrowe.co.uk?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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/B6D9DFD0-BCD5-496E-ADAF-CF7BFE46BE77%40pobox.com.
