> Consider the following snippet:
>
> before(:each) do
> #How can I see the fruits and veggies being operated on here?
> end
You can use the following trick:
['apples','pears', 'banananas'].each do |fruit|
context "do not omit this context, otherwise `let` would be called
in iterator, and the last would win' do
let(:fruit) { fruit } # This look a bit weird
it "Can add #{fruit} to the fruit basket" do
#fruit basket tests here
end
end
end
With the above, `fruit` will be available in `before`.
This snippet has two things that are not too obvious. Consider
approaching the same spec differently, e.g. with shared examples,
`all` matcher, etc. Or just not doing iteration and leaving spec
verbose , but readable (versus DRY).
- Phil