Hello, Here''s a test I wrote for cookies: it "should change language when params[:id] is present" do cookies[:thothle_language] = ''e'' get ''index'', :id => ''f'' response.cookies["thothle_language"].should equal(''f'') end The error I get is the following: ...expected "f", got ["f"] (using .equal?) Any help would be appreciated. Thank you Olivier Dupuis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071128/63f7e63b/attachment.html
On Nov 28, 2007 12:52 PM, Olivier Dupuis <odupuis at uottawa.ca> wrote:> > > > > Hello, > > > > Here''s a test I wrote for cookies: > > > > it "should change language when params[:id] is present" do > > cookies[:thothle_language] = ''e'' > > get ''index'', :id => ''f'' > > response.cookies["thothle_language"].should equal(''f'')Two things here: 1 - equal is object identity, so you probably want == instead 2 - cookies[key] is returning an Array Try this: response.cookies["thothle_language"].should == ["f"] Cheers, David> > end > > > > The error I get is the following: > > > > ?expected "f", got ["f"] (using .equal?) > > > > Any help would be appreciated. > > > > Thank you > > > > Olivier Dupuis > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
That works! Thanks! Olivier Dupuis -----Message d''origine----- De?: rspec-users-bounces at rubyforge.org [mailto:rspec-users-bounces at rubyforge.org] De la part de David Chelimsky Envoy??: Wednesday, November 28, 2007 4:34 PM ??: rspec-users Objet?: Re: [rspec-users] Testing cookies On Nov 28, 2007 12:52 PM, Olivier Dupuis <odupuis at uottawa.ca> wrote:> > > > > Hello, > > > > Here''s a test I wrote for cookies: > > > > it "should change language when params[:id] is present" do > > cookies[:thothle_language] = ''e'' > > get ''index'', :id => ''f'' > > response.cookies["thothle_language"].should equal(''f'')Two things here: 1 - equal is object identity, so you probably want == instead 2 - cookies[key] is returning an Array Try this: response.cookies["thothle_language"].should == ["f"] Cheers, David> > end > > > > The error I get is the following: > > > > ...expected "f", got ["f"] (using .equal?) > > > > Any help would be appreciated. > > > > Thank you > > > > Olivier Dupuis > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >_______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users