[rspec-users] before(:each) <- need some clarification

Matthew Van Horn
2011-04-28T17:36:32Z

On Apr 27, 2011, at 3:55 PM, Sergio Ruiz wrote:

> i am setting up a few objects that are interrelated for use in an rspec
> test..
>
> something like:
>
> describe Dimension do
>
> before(:each) do
> text = "string here"
> end
>
> it "should puts string" do
> puts text
> end
>
> end
>
> when i run this, i get an error: undefined local variable or method
> `text''
>
> am doing something wrong?
>
> thanks!

You just need to make it an instance variable instead of a local variable.
Try @text instead of text.