Error for Friendly Forwarding tests

  • Question
  • Updated 4 years ago
Hi,

I followed the examples in Ruby on Rails 3 Tutorial, chap 10.2.3 Friendly Forwarding. When I ran the tests for Listing 10.16, the following error appeared:

D:\rails_projects\sample_app>bundle exec rspec spec/
No DRb server is running. Running in local process instead ...
You must 'gem install win32console' to use colour on Windows
.....................................................................F............

Failures:
1) FriendlyForwardings should forward to the requested page after signin
Failure/Error: response.should render_template('users/edit')
Expected block to return true value.
# (eval):2:in `assert_block'
# ./spec/requests/friendly_forwardings_spec.rb:11:in `block (2 levels) in '

Finished in 8.63 seconds
82 examples, 1 failure

-----------------------------------------------------------------------------
I veriftied every line but still couldn't figure what went wrong. Any help would be greatly appreciated. Thanks

Michael
Photo of Michael Wong

Michael Wong

  • 1 Post
  • 0 Likes

Posted 4 years ago

  • 2
Photo of Karl Danninger

Karl Danninger

  • 1 Post
  • 0 Likes
I was getting the exact same error.

1. Check your sessions_helper.rb
2. Make sure deny_access and redirect_back_or are above 'private'
3. Make sure store_location and clear_return_to are under 'private

.
.
.
def deny_access
store_location
redirect_to signin_path, :notice => "Please sign in to access this page."
end

def redirect_back_or(default)
redirect_to(session[:return_to] || default)
clear_return_to
end

private

def user_from_remember_token
User.authenticate_with_salt(*remember_token)

end

def remember_token
cookies.signed[:remember_token] || [nil, nil]

end

def store_location
session[:return_to] = request.fullpath
end

def clear_return_to
session[:return_to] = nil
end

end
Photo of Josh

Josh

  • 2 Posts
  • 0 Likes
Good day Karl,
I followed up your instructions, however after autotest, this failure is still existed.

The unique work around which I amended this syntax:


response.should render_template('users/edit')
#to
response.should render_template('users/show')


It did worked without any failure, any idea?

Here the completed failure message from autotest is:



FriendlyForwardings
should forward to the requested page after signin (FAILED - 1)

Failures:

1) FriendlyForwardings should forward to the requested page after signin
Failure/Error: response.should render_template('users/edit')
Expected block to return true value.
# ./spec/requests/friendly_forwardings_spec.rb:11:in `block (2 levels) in <top (required)>'

Finished in 2.3 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/requests/friendly_forwardings_spec.rb:5 # FriendlyForwardings should forward to the requested page after signin