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

Jon Homan
2011-04-27T20:51:31Z

Sergio,

I believe you need to make text an instance variable:

    @text = "string here"

Or you could use a let block:

    let(:text) do
      "string "here"
    end

Then you could continue to reference the text variable as you do now.

Jon Homan


On Wed, Apr 27, 2011 at 2:55 PM, Sergio Ruiz <lists at ruby-forum.com>
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!
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20110427/87ad8433/attachment.html>