RSpec 给我一个 LoadError
RSpec is giving me a LoadError
我最近一直在尝试 运行 RSpec 在 Rails 应用程序中,但我似乎无法让它工作。我已经按照所有说明进行操作,但我仍然无法对 运行.
进行简单测试
RSpec 在我的 Gemfile 中,我有 运行 rails generate rspec:install
.
我在 spec 文件夹中设置了一个简单的模型测试。但是,每次我尝试 运行 RSpec 时,我都会收到以下错误:
An error occurred while loading ./spec/models/user_spec.rb. - Did you mean?
rspec ./spec/spec_helper.rb
Failure/Error: require File.expand_path('../config/environment', __dir__)
LoadError:
cannot load such file -- rexml/document
我的 user_spec.rb 看起来像这样:
require 'rails_helper'
RSpec.describe User, type: :model do
it "tests my rspec installation"
end
我是 Rails 的新手,非常感谢任何帮助!
只需将 gem 'rexml'
添加到您的 Gemfile 并在终端中添加 运行 bundle
。
我最近一直在尝试 运行 RSpec 在 Rails 应用程序中,但我似乎无法让它工作。我已经按照所有说明进行操作,但我仍然无法对 运行.
进行简单测试RSpec 在我的 Gemfile 中,我有 运行 rails generate rspec:install
.
我在 spec 文件夹中设置了一个简单的模型测试。但是,每次我尝试 运行 RSpec 时,我都会收到以下错误:
An error occurred while loading ./spec/models/user_spec.rb. - Did you mean?
rspec ./spec/spec_helper.rb
Failure/Error: require File.expand_path('../config/environment', __dir__)
LoadError:
cannot load such file -- rexml/document
我的 user_spec.rb 看起来像这样:
require 'rails_helper'
RSpec.describe User, type: :model do
it "tests my rspec installation"
end
我是 Rails 的新手,非常感谢任何帮助!
只需将 gem 'rexml'
添加到您的 Gemfile 并在终端中添加 运行 bundle
。