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?
text is a local variable, not an instance variable, and is not exposed outside
the scope of the block in which it is defined. It works with an instance
variable:
describe Dimension do
before(:each) do
@text = "string here"
end
it "should puts string" do
puts @text
end
end
Make sense?
Cheers,
David
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users