Forum: RSpec instance variables from outer before blocks don't persist?

Posted by Patrick Collins (patrick99e99)
on 2011-10-13 02:01
(Received via mailing list)
Hmmm..  I am used to doing this with Test::Unit & Shoulda..

setup do
  @foo = Bar.new
end

context "something"

  setup do
    @foo.blah = 123
  end

  should "make me say lol" do
    # ...etc
  end

end

...  But I just tried doing this in RSpec with before :each, and it 
seems that
my @foo ivar is non existant inside the inner context......  Is this the 
way
it's supposed to be?


Patrick J. Collins
http://collinatorstudios.com
Posted by Pat Maddox (Guest)
on 2011-10-13 04:17
(Received via mailing list)
On Oct 12, 2011, at 4:59 PM, Patrick J. Collins wrote:
> ...  But I just tried doing this in RSpec with before :each, and it seems that
> my @foo ivar is non existant inside the inner context......  Is this the way
> it's supposed to be?

post the whole example
Posted by Patrick Collins (patrick99e99)
on 2011-10-14 03:24
(Received via mailing list)
> > ...  But I just tried doing this in RSpec with before :each, and it seems that
> > my @foo ivar is non existant inside the inner context......  Is this the way
> > it's supposed to be?
>
> post the whole example

Nevermind..  I figured out what I was doing wrong.

Patrick J. Collins
http://collinatorstudios.com
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.