reformgemのチュートリアルに取り組んでいますが、エラーが発生します。
ソース: http://culttt.com/2016/02/10/using-form-objects-in-ruby-on-rails-with-reform/
エラー:
NameError: 初期化されていない定数 ArticleFormTest::Article test/forms/article_form_test.rb:8:`setup' 内
私の理解では、これ@model = Article.newは以下の結果によるものです。
require 'test_helper'
class ArticleFormTest < ActiveSupport::TestCase
def setup
@model = Article.new
@form = ArticleForm.new(@model)
end
test "should require title" do
@form.validate({})
assert_includes(@form.errors[:title], "can\'t be blank")
end
end
をセットアップしましarticle_form.rbた(下記参照)。だから、なぜこれが起こっているのか分かりません。
require "reform/form/validation/unique_validator.rb"
class ArticleForm < Reform::Form
property :title, presence: true, unique: true
property :markdown, presence: true
property :published_at, presence: true
property :user, presence: true
end
誰かが私が間違っているかもしれないことをアドバイスできますか?
アップデート
以下、リクエストごとに追加。
test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end