RSpec is giving me a LoadError

Viewed 972

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!

1 Answers

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

Related