fnando/minitest-utils

Retorna o nome errado do teste quando dá erro na view

Closed this issue · 6 comments

$ rake 
......E.

   1) test should get index
      ActionView::Template::Error: 795: unexpected token at '{'1':'aaa'}'
          app/views/endpoints/index.html.haml:20:in `block in _app_views_endpoints_index_html_haml__1748992618101548792_72657940'
     (...)
      # test/controllers/endpoints_controller_test.rb:9:in `block in <class:EndpointsControllerTest>'

Finished in 0.235216s, 34.0112 runs/s, 51.0169 assertions/s.
8 runs, 12 assertions, no failures, 1 error, no skips

Failed Tests:

rake TEST=app/views/endpoints/index.html.haml TESTOPTS="--name=test_should_get_index"

Teste:

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:endpoints)
  end

Controller (scaffold cru)

class EndpointsController < ApplicationController
  before_action :set_endpoint, only: [:show, :edit, :update, :destroy]

  def index
    @endpoints = Endpoint.all
  end
#...
end

Como assim nome errado? Nome do teste?

Yeap

rake TEST=app/views/endpoints/index.html.haml TESTOPTS="--name=test_should_get_index"

E como você acha que deveria ser?

rake TEST=test/controllers/endpoints_controller_test.rb TESTOPTS="--name=test_should_get_index" ?

pois app/views/endpoints/index.html.haml é a view.. não o teste :)

Então não é o nome errado, mas arquivo errado. Ótimo! Vou tentar corrigir aqui. :)

Acabei de liberar v0.1.2. Obrigado por abrir o ticket.