【问题标题】:RSpec is giving me a LoadErrorRSpec 给了我一个 LoadError
【发布时间】:2021-01-27 07:30:17
【问题描述】:

我最近一直在尝试在 Rails 应用程序中运行 RSpec,但我似乎无法让它工作。我已按照所有说明进行操作,但我什至无法运行一个简单的测试。

RSpec 在我的 Gemfile 中,我运行了 rails generate rspec:install

我有一个简单的模型测试设置的规范文件夹。但是,每次我尝试运行 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 新手,所以我非常感谢任何帮助!

【问题讨论】:

    标签: ruby-on-rails rspec


    【解决方案1】:

    只需将 gem 'rexml' 添加到您的 Gemfile 并在终端中运行 bundle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多