D
D
Dmitry2017-03-03 07:07:48
Ruby on Rails
Dmitry, 2017-03-03 07:07:48

Why does the test pass when it shouldn't?

In general, there is a test

require 'test_helper'

class StaticPagesControllerTest < ActionDispatch::IntegrationTest
  test "should get home" do
    get static_pages_home_url
    assert_response :success
  end

  test "should get help" do
    get static_pages_help_url
    assert_response :success
  end

  test "should get about" do
    get static_pages_about_url
    assert_response :success
  end  

end

but in the static_pages_controller.rb file I commented out all the methods
class StaticPagesController < ApplicationController
  # def home
  # end

  # def help
  # end

  # def about
  # end
end

And for some reason this test passes without errors! Moreover, I can go to the help and about pages! The methods are commented out in the controller file... how can that be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-03-03
@r_o_r

cleared the browser cache, restarted the server rail... the same! What a pancake for a mystic ...
In general, I deleted all the methods from the controller file and I can still go to the pages and the test shows that everything is ok. I'm totally in shock.
rake routes gives

Prefix Verb URI Pattern                   Controller#Action
 static_pages_home GET  /static_pages/home(.:format)  static_pages#home
 static_pages_help GET  /static_pages/help(.:format)  static_pages#help
static_pages_about GET  /static_pages/about(.:format) static_pages#about
              root GET  /                             application#hello

Understood.... in the fifth rails it is enough to add a route and a view and there will be a working link. Even if the controller is not touched at all ....

A
alex maslakoff, 2017-03-03
@teke_teke

clear cache, restart rails.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question