Итак, вот странная проблема: когда я запускаю свое локальное приложение rails и перехожу к http://localhost:3000/static_pages/help Я вижу там страницу, которую я создал. Однако тест, который я написал, говорит об обратном.
static_pages_controller_test.rb
require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
test "should get home" do
get :home
assert_response :success
end
test "should get help" do
puts static_pages_help_url
puts static_pages_help_path
get static_pages_help_url
assert_response :success
end
end
Это не удается с этой ошибкой, вывод теста $ bin / rake:
Running:
..http://test.host/static_pages/help
/static_pages/help
E
Finished in 0.466745s, 8.5700 runs/s, 4.2850 assertions/s.
1) Error.
StaticPagesControllerTest#test_should_get_help:
ActionController::UrlGenerationError: No route matches {:action=>"http://test.host/static_pages/help", :controller=>"static_pages"}
test/controllers/static_pages_controller_test.rb:12:in `block in <class:StaticPagesControllerTest>'
Вот routes.rb
Rails.application.routes.draw do
get 'static_pages/home'
get "static_pages/help"
end
а вот static_pages_controller.rb
class StaticPagesController < ApplicationController
def home
end
def help
end
end
и эти два файла
app/views/static_pages/home.html.erb
app/views/static_pages/help.html.erb
существуют, так как я также могу видеть их при переходе к /static_pages/help в моем браузере. Я искал в Интернете часами, без понятия.
$ rails --version
Rails 4.2.7.1
$ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Я должен что-то упустить. Пожалуйста помоги.