MiniTest Error: "NameError: uninitialized constant"

I follow Michael Hartle's “Ruby on Rails Tutorial: Learning Web Development” and create tests that check the username and email address for expiration dates (name no more than 50 characters, email - 255 characters). The contents of test/helpers/application_helper_test.rb :

 require 'test_helper' class ApplicationHelperTest < ActionView::TestCase test "full_title_helper" do assert_equal full_title, FILL_IN assert_equal full_title("Help"), FILL_IN end end 

When running bundle exec rake test all tests pass, but I see the following message, marked as an error at the end:

 ERROR["test_full_title_helper", ApplicationHelperTest, 1.820016791] test_full_title_helper#ApplicationHelperTest (1.82s) NameError: NameError: uninitialized constant ApplicationHelperTest::FILL_IN test/helpers/application_helper_test.rb:5:in `block in <class:ApplicationHelperTest>' test/helpers/application_helper_test.rb:5:in `block in <class:ApplicationHelperTest>' 

Any ideas how to fix this?

+5
source share
2 answers

It turns out that the problem is that FILL_IN is not a literal title (obviously), so you need to replace it with the "Help | Ruby on Rails Tutorial Sample App" and "Example Ruby on Rails Tutorial Sample App" respectively. -Thanks Nick Weiss and p11y for this answer.

+7
source

FILL_IN constants can be replaced by: name ,: email

 class User < ActiveRecord::Base #... has_many :microposts validates :name, presence: true validates :email, presence: true #... 
0
source

Source: https://habr.com/ru/post/1206136/


All Articles