
internal server error when using 'visit' with rails 2.2 and test::unit
Reported by Jeroen van Dijk | December 10th, 2008 @ 11:44 AM
I'm not sure if whether I found a bug or I'm misunderstanding how webrat should be instantiated.
I'm having the following code in a test unit file
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require "webrat/rails"
class WebratTest < ActionController::IntegrationTest
def test_webrat
visit "/"
assert false
end
end
When using autotest I'm getting the error output below. It seems to hang on line 294 (/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:294):
# Inject status back in for backwords compatibility with CGI
@headers['Status'] = @status
Did i forget something or is this a bug in webrat caused by 2.2?
Regards, Jeroen
1) Error: test_webrat(CandidateLoginTest): NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[]= /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:294:in `process' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:185:in `get' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:134:in `send' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:134:in `request_via_redirect' /Library/Ruby/Gems/1.8/gems/webrat-0.3.2/lib/webrat/rails.rb:47:in `do_request' /Library/Ruby/Gems/1.8/gems/webrat-0.3.2/lib/webrat/rails.rb:20:in `get' /Library/Ruby/Gems/1.8/gems/webrat-0.3.2/lib/webrat/core/session.rb:82:in `send' /Library/Ruby/Gems/1.8/gems/webrat-0.3.2/lib/webrat/core/session.rb:82:in `request_page' /Library/Ruby/Gems/1.8/gems/webrat-0.3.2/lib/webrat/core/session.rb:148:in `visit' /Library/Ruby/Gems/1.8/gems/webrat-0.3.2/lib/webrat/rails.rb:88:in `send' /Library/Ruby/Gems/1.8/gems/webrat-0.3.2/lib/webrat/rails.rb:88:in `method_missing' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:498:in `__send__' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:498:in `method_missing' test/functional/candidate_login_test.rb:12:in `test_webrat' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:94:in `__send__' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:94:in `run' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/integration.rb:597:in `run' 1 tests, 0 assertions, 0 failures, 1 errors Loaded suite test/unit/candidate_test
Comments and changes to this ticket
-
-
Jeroen van Dijk December 11th, 2008 @ 04:47 AM
- Title changed from internal server when using visit with rails 2.2 and test::unit to internal server error when using 'visit' with rails 2.2 and test::unit
-
gaffo January 6th, 2009 @ 02:41 AM
Which version of webrat did you use? Github, gem?
With the newest webrat from github on master you would now do:
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' require "webrat" Webrat.configure do |config| config.mode = :rails end class WebratTest < ActionController::IntegrationTest def test_webrat visit "/" end end
Please try that out with the new webrat and let us know how it went.
-
John Small February 3rd, 2009 @ 01:37 PM
I had that problem with after upgrading to 0.4.1 on Rails 2.2.2. The configure & etc did the trick.
-
Bryan Helmkamp February 9th, 2009 @ 12:19 AM
- State changed from new to invalid
I'm going to mark this as invalid, as it appears using the configuration directive solved it.
Jeroen -- If you're still seeing issues, please add a comment and we'll reopen and get them taken care of.
Cheers,
-Bryan
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 ยป
Ruby Acceptance Testing for Web applications.