Я вспахиваю учебник Майкла Хартла Ruby on Rails() прямо сейчас и нашел проблему, которую я не могу исправить Google.Hartl's railstutorial.org Глава 5, упражнение 2
При создании этого файла: test/helpers/application_helper_test.rb
и запуск:
'rails test'
Я получаю эту ошибку:
AIL["test_full_title_helper", ApplicationHelperTest, 0.7209667120041559]
test_full_title_helper#ApplicationHelperTest (0.72s)
--- expected
+++ actual
@@ -1 +1 @@
-"Help | Ruby on Rails Tutorial Sample App"
+"Ruby on Rails Tutorial Sample App"
test/helpers/application_helper_test.rb:6:in `block in <class:ApplicationHelperTest>'
Имея просмотрены подобные вопросы, хотя вопросы более года (и используя старые Rails), я не мудрее, как исправить этот провал.
Я ясно Noobie рубин, поэтому, пожалуйста, быть нежным :) любая помощь будет принята с благодарностью
static_pages_controller_test.rb:
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get root_path
assert_response :success
assert_select "title", "Ruby on Rails Tutorial Sample App"
end
test "should get help" do
get help_path
assert_response :success
assert_select "title", "Help | Ruby on Rails Tutorial Sample App"
end
test "should get about" do
get about_path
assert_response :success
assert_select "title", "About | Ruby on Rails Tutorial Sample App"
end
test "should get contact" do
get contact_path
assert_response :success
assert_select "title", "Contact | Ruby on Rails Tutorial Sample App"
end
end
и файл обижая:
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test "full title helper" do
assert_equal full_title, "Ruby on Rails Tutorial Sample App"
assert_equal full_title("Help"), "Help | Ruby on Rails Tutorial Sample App"
end
end
и site_layout_test.rb
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
test "layout links" do
get root_path
assert_template 'static_pages/home'
assert_select "a[href=?]", root_path, count: 2
assert_select "a[href=?]", help_path
assert_select "a[href=?]", about_path
assert_select "a[href=?]", contact_path
get contact_path
assert_select "title", full_title("Contact")
end
end
и код application_helper:
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
page_title + " | " + base_title
end
end
end
help.html.erb static_page:
<% provide(:title, "Help") %>
<h1>Help</h1>
<p>
Get help on the Ruby on Rails Tutorial at the
<a href="http://www.railstutorial.org/help">Rails Tutorial help section</a>.
To get help on this sample app, see the
<a href="http://www.railstutorial.org/book"><em>Ruby on Rails Tutorial</em>
book</a>.
</p>
вы можете разместить 'full_title' метод? трудно понять, что не так, если мы просто видим тесты. – davidhu2000
Я имею в виду показать нам метод 'full_title', который вы написали в' ApplicationHelper' – davidhu2000
. Также было бы полезно показать одну из статических страниц (страница справки, о или на странице) – davidhu2000