Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
425 views
in Technique[技术] by (71.8m points)

ruby on rails - RSpec is giving me a LoadError

I've recently been trying to run RSpec in a Rails application and I can't seem to get it to work. I've followed all the instructions and I still can't even get a simple test to run.

RSpec is in my Gemfile, and I've run rails generate rspec:install.

I have the spec folder set up with a simple model test. However, every time I try to run RSpec, I get the following error:

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

My user_spec.rb looks like this:

require 'rails_helper'

RSpec.describe User, type: :model do
  it "tests my rspec installation"
end

I'm new to Rails so I would really appreciate any help!

question from:https://stackoverflow.com/questions/65914634/rspec-is-giving-me-a-loaderror

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just add gem 'rexml' to your Gemfile and run bundle in terminal.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...