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.
--
Posted via http://www.ruby-forum.com/.
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". -- Posted via http://www.ruby-forum.com/.
Michal Burak 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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.