I have a test method (below).
def test_save_failed
post( :edit, :record => StatusChanger.invalid_data_hash)
assert_response :success
assert_template ‘edit’
assert assigns(:record)
assert_equal false, assigns(:record).valid?
end
This particular method is part of a larger set of functional tests. If
I run,
$ ruby controller_test.rb -n ‘test_save_failed’
it validates fine. If I run,
$ ruby controller_test.rb
I receive the following:
“Expected response to be a <:success>, but was <302>”
I’m utterly confused. Any ideas?
On Aug 3, 2006, at 8:16 PM, Jeremy Friesen wrote:
This particular method is part of a larger set of functional
“Expected response to be a <:success>, but was <302>”
I’m utterly confused. Any ideas?
Just a wild guess…
Oftentimes when a test works as expected when run individually but
fails as part of a larger sequence, it is due to there being some
artifact left behind in the environment. Take a look at your session
to see if it is the culprit. Also, if you are using MySQL, make sure
you are using InnoDB tables so that transactions are properly rolled
back between tests.
Chuck R. wrote:
On Aug 3, 2006, at 8:16 PM, Jeremy Friesen wrote:
This particular method is part of a larger set of functional
“Expected response to be a <:success>, but was <302>”
I’m utterly confused. Any ideas?
Just a wild guess…
Oftentimes when a test works as expected when run individually but
fails as part of a larger sequence, it is due to there being some
artifact left behind in the environment. Take a look at your session
to see if it is the culprit. Also, if you are using MySQL, make sure
you are using InnoDB tables so that transactions are properly rolled
back between tests.
"i m using sqlite3 "
and i get the same error…what should i do??
Sijo k g wrote:
Hi Sanjana D.
Please paste your relevant code
Sijo
hi this is my code
def test_should_show_article
get :show, :id => articles(:one) # I need to pass this as the id…
assert_response :success
assert_template ‘show’
assert_select ‘h1’, ‘a’
assert_equal articles(:one), assigns(:articles)
end
Hi Sanjana D.
Please paste your relevant code
Sijo
Sanjana D. wrote:
Sijo k g wrote:
Hi Sanjana D.
Please paste your relevant code
Sijo
hi this is my code
def test_should_show_article
get :show, :id => articles(:one) # I need to pass this as the id…
assert_response :success
assert_template ‘show’
assert_select ‘h1’, ‘a’
assert_equal articles(:one), assigns(:articles)
end
def test_article
get :index, {}, { :name => admins(:sanj).id }
assert_response :sucess
assert_template :index
end
for both the test cases i m getting the error
Expected response to be a <:sucess>, but was <302>
Hi Sanjana D.
can i see the controller code? Is any redirect happens there?
get :index, {}, { :name => admins(:sanj).id }
What are you trying with this :name => admins(:sanj).id
Sijo