RSpec-Rails not tearing down the session?

I noticed that a session that I am setting up in one exa,ple is still
available in another. Is RSpec-Rails supposed to tear down the session
or should I be doing this myself?

On Oct 27, 2009, at 9:39 PM, Brian C. [email protected]
wrote:

I noticed that a session that I am setting up in one exa,ple is still
available in another. Is RSpec-Rails supposed to tear down the session
or should I be doing this myself?

Unless you’ve got a before(:all) block, you should be getting a fresh
session in each example, in which case you’ve probably uncovered a bug.

I’ve isolated the code pretty well. The session is being set with
Authlogic, not certain if that makes a difference.

The session hash is empty on the test side but populated in the
controller when it shouldn’t be.

So the problem I was having was because I had a before_filter that was
disabling the magic states for a specific action. I resolved the
problem by changing this to an around filter:

before:

def disable_magic_states
UserSession.disable_magic_states = true
end

after:

def temporarily_disable_magic_states
UserSession.disable_magic_states = true
yield
UserSession.disable_magic_states = false
end

That fixed it. Kind of a unique problem but if it hopefully it will
save somebody else some time.

  • Brian

So I think that this is an Authlogic issue, not a RSpec-Rails issue.
I’ll keep digging and if I find a fix I’ll update

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs