
functional testing witih rails 2.3.2 doesn't work like the documentation says
Reported by jmoses | June 11th, 2009 @ 01:50 PM
Here's the top of my test_helper.rb:
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require "authlogic/test_case" # include at the top of test_helper.rb
require 'test_help'
class ActiveSupport::TestCase
include Authlogic::TestCase
setup :activate_authlogic # run before tests are executed
...
end
And an exemplar test that's failing:
require 'test_helper'
class CheckoutControllerTest < ActionController::TestCase
setup :set_cart
test "index redirects to gather info" do
get :index
assert_redirected_to checkout_info_path
end
protected
def set_cart
session[:cart_id] = carts(:checkout).id
end
end
And I get:
6) Error:
test_submit_on_review_page_submits_order(CheckoutControllerTest):
NoMethodError: undefined method `controller_path' for Authlogic::TestCase::MockController:Class
/test/functional/checkout_controller_test.rb:53:in `test_submit_on_review_page_submits_order'
With a fuller backtrace being:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.initialize_current_url
/Users/jmoses/Dev/git-reso/reso-shop-2/vendor/gems/authlogic-2.0.13/lib/authlogic/controller_adapters/abstract_adapter.rb:64:in `send'
/Users/jmoses/Dev/git-reso/reso-shop-2/vendor/gems/authlogic-2.0.13/lib/authlogic/controller_adapters/abstract_adapter.rb:64:in `method_missing'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/test_case.rb:195:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/test_case.rb:195:in `setup_controller_request_and_response'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:276:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/testing/setup_and_teardown.rb:60:in `run'
I feel like I'm doing something wrong, but as far as I can tell I match the documentation.
Any suggestions are welcome.
Comments and changes to this ticket
-
jmoses June 11th, 2009 @ 01:51 PM
And it's really from line #63 of the authlogic file.
/Users/jmoses/Dev/git-reso/reso-shop-2/vendor/gems/authlogic-2.0.13/lib/authlogic/controller_adapters/abstract_adapter.rb:64:in `send'
63, not 64. I added a debugging line.
-
jmoses June 15th, 2009 @ 08:08 AM
Well, apparently if you really read the documentation, it works just fine.
You do not need or want to do:
setup :activate_authlogic
in your functional tests. This produces terrible brokeness.
-
Ben Johnson August 7th, 2009 @ 06:20 PM
- State changed from new to moved_to_github
[state:"moved_to_github" bulk edit command]
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.