hi,
I have created a functional test, which when run using the command
ruby .rb
fails
the .rb includes a file name test_helper.rb. The
contents of the test_helper.rb file are
ENV[“RAILS_ENV”] = “test”
require File.expand_path(File.dirname(FILE) +
“/…/config/environment”)
require ‘test_help’
class Test::Unit::TestCase
self.use_instantiated_fixtures = false
Add more helper methods to be used by all tests here…
def assert_close(v1,v2)
assert((v1-v2).abs < 0.0001,"#{v1} is not within 0.0001 of #{v2}")
end
def assert_close_percent(v1,v2)
assert(((v1-v2)/v1).abs < 0.0001,"#{v1} is not within 0.0001% of
#{v2}")
end
def login(name=’<>’,password=’<>’)
controller = @controller
@controller = LoginController.new
post :login,:user=>{:name=>name,:password=>password}
assert_redirected_to :controller=>‘login’,:action=>‘home_page’
#assert_redirected_to @controller.url_for( :action => ‘login’ )
assert_not_nil(session[:user_id])
assert_kind_of Person, Person.find(session[:user_id])
@controller = controller
end
end
The error it gives me is:
FFFFFFFF
Finished in 0.344 seconds.
-
Failure:
test_create(OfficesControllerTest)
[functional/offices_controller_test.rb:56]:
response is not a redirection to all of the options supplied
(redirection is <{:action=>“login”, :controller=>“login”}>)
, difference: <{:action=>“list”, :controller=>“login”}> -
Failure:
test_destroy(OfficesControllerTest)
[functional/offices_controller_test.rb:82]:
response is not a redirection to all of the options supplied
(redirection is <{:action=>“login”, :controller=>“login”}>)
, difference: <{:action=>“list”, :controller=>“login”}> -
Failure:
test_edit(OfficesControllerTest)
[functional/offices_controller_test.rb:64]:
Expected response to be a <:success>, but was <302> -
Failure:
test_index(OfficesControllerTest)
[functional/offices_controller_test.rb:18]:
Expected response to be a <:success>, but was <302> -
Failure:
test_list(OfficesControllerTest)
[functional/offices_controller_test.rb:25]:
Expected response to be a <:success>, but was <302> -
Failure:
test_new(OfficesControllerTest)
[functional/offices_controller_test.rb:44]:
Expected response to be a <:success>, but was <302> -
Failure:
test_show(OfficesControllerTest)
[functional/offices_controller_test.rb:34]:
Expected response to be a <:success>, but was <302> -
Failure:
test_update(OfficesControllerTest)
[functional/offices_controller_test.rb:74]:
response is not a redirection to all of the options supplied
(redirection is <{:action=>“login”, :controller=>“login”}>)
, difference: <{:action=>“show”, :controller=>“login”, :id=>1}>
8 tests, 15 assertions, 8 failures, 0 errors
Please help me understand the error
Thanks in advance
Tushar