0

I'm following an entry-level tutorial on rspec here, and I've created a very simple test at spec\lib\zombie_spec.rb:

require "spec_helper"
describe "A Zombie" do
  #Your 'examples' (tests) go here.
  it "is named Ash"
end

If I run this test from the gnome-terminal, everything works as expected:

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) A Zombie is named Ash
     # Not yet implemented
     # ./spec/lib/zombie_spec.rb:4


Finished in 0.00049 seconds (files took 0.09118 seconds to load)
1 example, 0 failures, 1 pending

However, if I try to run the same code from emacs' shell or ansi-term, I get this:

The program 'rspec' is currently not installed. You can install it by typing:
sudo apt install ruby-rspec-core

After installing ruby-rspec-core and trying to run the test again, I get this:

/home/adc/odin-project/web-development-101/20-code-school-rspec/zombie/spec/spec_helper.rb:48:in `block in <top (required)>': undefined method `shared_context_metadata_behavior=' for #<RSpec::Core::Configuration:0x00000000eed1d0> (NoMethodError)
    from /usr/lib/ruby/vendor_ruby/rspec/core.rb:97:in `configure'
    from /home/adc/odin-project/web-development-101/20-code-school-rspec/zombie/spec/spec_helper.rb:19:in `<top (required)>'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1295:in `block in requires='
    from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1295:in `each'
    from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1295:in `requires='
    from /usr/lib/ruby/vendor_ruby/rspec/core/configuration_options.rb:109:in `block in process_options_into'
    from /usr/lib/ruby/vendor_ruby/rspec/core/configuration_options.rb:108:in `each'
    from /usr/lib/ruby/vendor_ruby/rspec/core/configuration_options.rb:108:in `process_options_into'
    from /usr/lib/ruby/vendor_ruby/rspec/core/configuration_options.rb:21:in `configure'
    from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:105:in `setup'
    from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:92:in `run'
    from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:78:in `run'
    from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:45:in `invoke'
    from /usr/bin/rspec:4:in `<main>'

How can I fix this so that rspec runs successfully from within the emacs shell?

1 Answer 1

0

It turns out this was a problem with ruby gems as a whole, not just rspec. And there's an emacs package that fixes the problem: rvm, as outlined here.

So, a step by step solution:

M-x package-install
rvm
M-x rvm-use-default

You can also add (rvm-use-default) to your init file to enable the package from startup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.