> 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

-- 
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/CAAk5Ok8nStwFG68kafzHgDM68qzYO2y3fFeTyiemSW3RAxF_1w%40mail.gmail.com.

Reply via email to