# Integrations tests questions

**URL:** <https://www.ruby-forum.com/t/integrations-tests-questions/178691>\
**Category:** Rails\
**Created:** [November 9, 2009, 6:10pm UTC](https://www.ruby-forum.com/t/integrations-tests-questions/178691 "2009-11-09T18:10:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@benol](https://www.ruby-forum.com/u/benol)\
**Post date:** [November 9, 2009, 6:10pm UTC](https://www.ruby-forum.com/t/integrations-tests-questions/178691/1 "2009-11-09T18:10:07Z")

</div>

Hi,

— ROUTING —  
I have roting defined as RESTful but for the below testes MyModels  
controller I have a standard

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’

---- SAMPLE TEST ------

class MyIntegrationTest \< ActionController::IntegrationTest  
fixtures :all

test “sample test” do  
login\_as\_quentin

```
get '/my_models/new' #how do I avoid hard-coded paths?
assert_response 200

assert_difference('MyModel.count') do
  post '/my_models/create', :my_model => my_models(:one).attributes

```

#how do I avoid hard-coded paths?  
assert\_redirected\_to ‘/my\_models/edit\_photos/’ #how do i specify  
ID in here?  
end  
end  
end

The questions are in the comments for the test.

Thanks in advance.

M.

---

<div class="post-metadata">

**Author:** ![benol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@benol](https://www.ruby-forum.com/u/benol)\
**Post date:** [November 9, 2009, 6:41pm UTC](https://www.ruby-forum.com/t/integrations-tests-questions/178691/2 "2009-11-09T18:41:00Z")

</div>

Ok, I have the answer figured out for the quesion “how to specify ID”:

assert\_redirected\_to ‘/my\_models/edit\_photos/’ +  
assigns(:my\_model).id.to\_s

But I still dont know how to avoid hardcoded paths.

I want to replace:

get ‘/foo/bar’

with something like:

get :controller =\> :foo, :action =\> :bar

so that the integrations tests are “not routes.rb dependant”.

---

<div class="post-metadata">

**Author:** ![benol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@benol](https://www.ruby-forum.com/u/benol)\
**Post date:** [November 9, 2009, 8:04pm UTC](https://www.ruby-forum.com/t/integrations-tests-questions/178691/3 "2009-11-09T20:04:05Z")

</div>

Michal B. wrote:  
[…]

> The questions are in the comments for the test.

In my opinion, integration tests are a bit clumsy. Cucumber features  
will be easier to work with, and will also address the issues you were  
asking about.

> Thanks in advance.
> 
> M.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![benol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@benol](https://www.ruby-forum.com/u/benol)\
**Post date:** [November 9, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/integrations-tests-questions/178691/4 "2009-11-09T21:30:34Z")

</div>

Marnen Laibow-Koser wrote:

> In my opinion, integration tests are a bit clumsy. Cucumber features  
> will be easier to work with, and will also address the issues you were  
> asking about.
> 
> > Thanks in advance.
> > 
> > M.

Looks nice, I’ll check it deeper. Thanks.

My fiend found another simpler solution:  
[http://programmers-blog.com/2009/11/09/rails-integration-tests-hardcoded-routes-problem](http://programmers-blog.com/2009/11/09/rails-integration-tests-hardcoded-routes-problem)
