Help with integration tests

nuno
2006-10-10T13:14:51Z

Hello, I''m trying to set up an integration test because functionnal
testing with cookies gave me headaches...

Now, I can''t have those integration tests working :

The ApplicationController is

class ApplicationController < ActionController::Base

  helper_method :types_biens
  helper_method :lire_critere
  helper_method :ecrire_critere

  @@types_biens = {'''' => ''Tous'',
''ma'' => ''maison'', ''app''
=>
''appartements''}

  def types_biens
    return @@types_biens
  end

  def lire_critere(nom)
    return cookies["criteres_#{nom}"].to_s
  end

  def ecrire_critere(nom, valeur)
    cookies["criteres_#{nom}"] = valeur.to_s
  end

end

The controller is

class CriteresController < ApplicationController

  def change
    if request.post?

ecrire_critere(''type_bien'',params[:criteres][:type_bien])

ecrire_critere(''localisation'',params[:criteres][:localisation])

ecrire_critere(''superficie_mini'',params[:criteres][:superficie_mini])
      redirect_to :controller => ''menu_general''
    end
  end

end

The test file is

require "#{File.dirname(__FILE__)}/../test_helper"
class CriteresCookies < ActionController::IntegrationTest

def test_change_critere
    pp cookies
    post :change, :criteres => {:type_bien => ''ma'',
:localisation =>
''xxx'', :superficie_mini => 70}
    assert_equal ''ma'',
@controller.lire_critere("type_bien")
    assert_equal ''xxx'',
@controller.lire_critere("localisation")
    assert_equal ''70'',
@controller.lire_critere("superficie_mini")
  end

end

But unfortunately, the @lire_critere method defined in
CriteresController is not visible...
And pp cookies return an empty hash and pp @cookies return nil

So, where are the cookies ? Why the lire_critere method is not available
?

Note : when tried with a browser the controller and the cookie methods
works as excepted - the problem occurs when I try to create some tests
for them

Thanks

--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---