Controller (functional) tests are being deprecated in rails

Bráulio Bhavamitra braulio at eita.org.br
Thu Mar 26 13:17:16 BRT 2015


Hello all,

For future tests, we should avoid them and prefer cucumber/capybara instead.

See below. Source:
https://intercityup.com/blog/upcoming-changes-in-rails-5-0.html?utm_source=rubyweekly&utm_medium=email

cheers,
bráulio


Status: Merged https://github.com/rails/rails/pull/19169
Deprecation of assigns() and assert_template in controller tests

In Rails 5.0 the test helpers assigns() and assert_template will be
deprecated. This does not mean you can't use them anymore. But you have to
keep in mind that they will probably be removed in a later version of rails.

The reasoning about this deprecation is that testing for instance variables
and what template is being called in a controller is a bad idea, those are
internals of that controller and the controller tests should not care about
what ivars are being set. The controller test should be concerned about
what cookies are being set, what the HTTP code was and maybe what mutations
have happened in the database.

But now you might be thinking: How can I test if the correct values are
being set? Well, probably your app will return a status code 500 when
certain important ivars are not set. So when you test for correct HTTP
status code, you're covered!

DHH even speaks about the possibility to remove controller test altogether
and use Integration tests instead. source
<https://github.com/rails/rails/issues/18950#issuecomment-77924771>
- See more at:
https://intercityup.com/blog/upcoming-changes-in-rails-5-0.html?utm_source=rubyweekly&utm_medium=email#sthash.IU1GRWia.dpuf


-- 
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar

EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br

"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é meu
lar e todos nós somos cidadãos deste cosmo. Este universo é a imaginação da
Mente Macrocósmica, e todas as entidades estão sendo criadas, preservadas e
destruídas nas fases de extroversão e introversão do fluxo imaginativo
cósmico. No âmbito pessoal, quando uma pessoa imagina algo em sua mente,
naquele momento, essa pessoa é a única proprietária daquilo que ela
imagina, e ninguém mais. Quando um ser humano criado mentalmente caminha
por um milharal também imaginado, a pessoa imaginada não é a propriedade
desse milharal, pois ele pertence ao indivíduo que o está imaginando. Este
universo foi criado na imaginação de Brahma, a Entidade Suprema, por isso
a propriedade deste universo é de Brahma, e não dos microcosmos que também
foram criados pela imaginação de Brahma. Nenhuma propriedade deste mundo,
mutável ou imutável, pertence a um indivíduo em particular; tudo é o
patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150326/f5853941/attachment.html>


More information about the Noosfero-dev mailing list