Doubts in Integration testing

Hi Friendz,

I just started to work in Integration Test. but my test was failured.
i just pasted my code below.

Failure message was: Expected response to be <:success> , but was <302>

Can u guys Plz give me a solution for this problem.

CODE:
def test_year_template
get ‘/calendar’
assert_response :success
assert_template “/calendar/year”
end

Advance Thx,

regards,
Karthick.

There’s no way we can tell just from this. Some where in your Calendar
controller’s index method (or one of the filters etc…) you are calling
redirect.

Fred

Frederick C. wrote:

There’s no way we can tell just from this. Some where in your Calendar
controller’s index method (or one of the filters etc…) you are calling
redirect.

Fred

hi friendz,
Thx,
yes am using filter(before filter in my calendar controller)
and also am using redirect in my index method.
Plz tell me how to tackle this

Advance Thx,

regards,
Karthick.

Well if your index does a redirect (and is supposed to) then your test
shouldn’t contain assert_response :success, which (in effect) asserts
that you didn’t redirect

Fred

Frederick C. wrote:

Well if your index does a redirect (and is supposed to) then your test
shouldn’t contain assert_response :success, which (in effect) asserts
that you didn’t redirect

Fred

hi Fred,
thx,
i had removed assert_response. but now it produces the following error

expecting <“calendar/year”> but rendering with

could u plz give me a solution for that.

Advance Thx,

regards,
Karthick

unknown wrote:

Hi –

On Tue, 10 Oct 2006, Narayana K. wrote:

i had removed assert_response. but now it produces the following error

expecting <“calendar/year”> but rendering with

could u plz give me a solution for that.

The general solution for tests that fail is to fix your code :slight_smile:
Without seeing what’s in your controller, it’s impossible to give very
specific advice beyond just guessing.

David


David A. Black | [email protected]
Author of “Ruby for Rails” [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB’s Weblog) [2] | Co-director, Ruby Central, Inc. [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com | [4] http://www.rubycentral.org

Hi david,

Nice to see u response to my question. first of all thx.
I just pasted my code below, plz go through it & give me a solution for
my problem.

class CalendarController < ApplicationController
before_filter :set_date

def year #display current year calendar
end

def index
redirect_to :action => ‘list’
end

private
def set_date
@date = Date.parse((params[:date] || Date.today).to_s)
end
end

Advance Thx,

regards,
Karthick

Hi –

On Tue, 10 Oct 2006, Narayana K. wrote:

i had removed assert_response. but now it produces the following error

expecting <“calendar/year”> but rendering with

could u plz give me a solution for that.

The general solution for tests that fail is to fix your code :slight_smile:
Without seeing what’s in your controller, it’s impossible to give very
specific advice beyond just guessing.

David


David A. Black | [email protected]
Author of “Ruby for Rails” [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB’s Weblog) [2] | Co-director, Ruby Central, Inc. [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com | [4] http://www.rubycentral.org

You either need to fix your controller (assuming the integration test
demonstrates the correct behaviour) or change your test, assuming your
controller is doing the right thing.
I’m guessing you actually want to do get ‘/calendar/year’ in your test,
since you appear to be trying to test that bit of functionality.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs