Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when running a feature that has javascript and non javascript features #38

Open
cmavromoustakos opened this issue Dec 18, 2010 · 0 comments

Comments

@cmavromoustakos
Copy link

For some reason when running a feature file that has javascript scenarios and non javascript scenarios the cookies are not always being set. It seems to be completely random as to when it is happening. The only similarity I have seen in the tests that do this are that some are tagged with @akephalos and some are not.

�(::) failed steps (::)�

�undefined method `value' for nil:NilClass (NoMethodError) (DRb::DRbRemoteError)

Our cookie helper:

module CookiesHelpers
  def cookies
    case Capybara.current_driver
    when :rack_test, :envjs
      rack_test_cookies
    when :akephalos
      akephalos_cookies
    end
  end

  def akephalos_cookies
    Capybara.current_session.driver.cookies
  end

  def rack_test_cookies
    Capybara.
      current_session.
      driver.
      current_session.
      instance_variable_get("@rack_mock_session").
      cookie_jar
  end
end

World(CookiesHelpers)

And our session help which gets the cookies:

module SessionHelpers
  def current_user
    remember_token = if cookies['remember_token'].respond_to?(:value)
                      cookies['remember_token'].value
                    else
                      cookies['remember_token']
                    end

    User.where(:remember_token => remember_token).first
  end
end

World(SessionHelpers)

World(SessionHelpers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant