# Doubts in Integration testing

**URL:** <https://www.ruby-forum.com/t/doubts-in-integration-testing/71619>\
**Category:** Rails\
**Created:** [October 10, 2006, 10:22am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619 "2006-10-10T10:22:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 10:22am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/1 "2006-10-10T10:22:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 10:29am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/2 "2006-10-10T10:29:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 10:36am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/3 "2006-10-10T10:36:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 10:48am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/4 "2006-10-10T10:48:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 11:03am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/5 "2006-10-10T11:03:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 11:16am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/6 "2006-10-10T11:16:47Z")

</div>

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 🙂  
> Without seeing what’s in your controller, it’s impossible to give very  
> specific advice beyond just guessing.
> 
> David
> 
> –  
> David A. Black | removed\_email\_address@domain.invalid  
> Author of “Ruby for Rails” [1] | Ruby/Rails training & consultancy [3]  
> DABlog (DAB’s Weblog) [2] | Co-director, Ruby Central, Inc. [4]  
> [1] [Ruby for Rails](http://www.manning.com/black) | [3] [http://www.rubypowerandlight.com](http://www.rubypowerandlight.com)  
> [2] [http://dablog.rubypal.com](http://dablog.rubypal.com) | [4] [http://www.rubycentral.org](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

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 11:08am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/7 "2006-10-10T11:08:09Z")

</div>

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 🙂  
Without seeing what’s in your controller, it’s impossible to give very  
specific advice beyond just guessing.

David

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

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 10, 2006, 11:24am UTC](https://www.ruby-forum.com/t/doubts-in-integration-testing/71619/8 "2006-10-10T11:24:24Z")

</div>

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
