I can't figure out why my RSPEC isn't working. I reinstalled RSPEC with sudo gem install rspec and then tried again to install with a specific version number (sudo gem install rspec -v 2.11.0)
I continue to get the following error message and I cannot figure out what it means. I believe that I may or may not have version 1 also installed, not sure.
Castillo$ rspec document_spec.rb
/Users/Castillo/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require': no such file to load -- document (LoadError) from
/Users/Castillo/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require' from /Users/Castillo/Desktop/document_spec.rb:1:in <top
(required)>' from
/Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:inload' from
/Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in block in load_spec_files' from
/Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:inmap' from
/Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in load_spec_files' from
/Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:inrun' from
/Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in
run' from
/Users/Castillo/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in
block in autorun'
Add full path to your document.rb file into spec file
or use
require_relative
or
require File.expand_path('../document.rb', __FILE__)
Related
I get the following error when trying to do anything with Ruby, specifically ruby gems:
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `require': incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so (LoadError)
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:16:in `rescue in <top (required)>'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:13:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems.rb:729:in `load_yaml'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:349:in `load_file'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:202:in `initialize'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `new'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `do_configuration'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:44:in `run'
from /usr/local/rvm/rubies/ruby-2.4.5/bin/gem:21:in `<main>'
I believe the line of note is this one:
LoadError: incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so
I get this from gem install puppet, gem update, etc. I tried uninstalling and reinstalling libyaml, and same with Ruby. The error happened after I did bundle uninstall puppet to get it to stop pointing to the 6.3.0 gem and point to the 4.10.2 executable. I need Ruby to be able to use Rspec to test the modules. Does anyone know how I can fix this?
Without steps to reproduce the broken system it is hard to say what happened, but I can say in general how you can set this up correctly to use a specific version of Puppet.
Does this help? In the worst case, you can probably uninstall RVM and reinstall it.
Before I continue, let me note that Puppet 4.10.2 and 4.10.3 have both been removed from Rubygems. (Although I was able to install it with PDK.)
For the remainder I assume 4.10.4 instead (just to distinguish it from latest 4.10).
The recommended approach is to use Puppet Development Kit (pdk). If you download and install PDK, you probably just need to do these steps:
pdk convert
rm Gemfile.lock
PUPPET_GEM_VERSION=4.10.4 bundle update # If that version isn't already in PDK.
pdk test unit --puppet-version 4.10.4
If you don't want to go down the PDK path, you can try these alternatives:
Hardcode the version of Puppet you want in Gemfile.
gem 'puppet', '4.10.4'
Or:
gem 'puppet', '~> 4.10' # latest 4.10
Then update your bundle:
rm -f Gemfile.lock
bundle update
Or, you can implement the PUPPET_GEM_VERSION feature by adding this code (this is what I do, for what it's worth):
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion
else
gem 'puppet'
end
And then:
rm -f Gemfile.lock
PUPPET_GEM_VERSION='~> 4.10' bundle update
Now you can run your unit tests against a specific version of Puppet per normal:
bundle exec rake spec
Or however you set it up.
I'm trying to play around with serverspec, however it seems I have some weird gem error that I cannot pinpoint.
$ rake spec
/usr/bin/ruby -I/usr/lib/ruby/gems/1.8/gems/rspec-support-3.0.2/lib:/usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib -S /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/exe/rspec spec/localhost/httpd_spec.rb
/home/mikolajewskim/puppet-master/spec/spec_helper.rb:1:in `require': no such file to load -- serverspec (LoadError)
from /home/mikolajewskim/puppet-master/spec/spec_helper.rb:1
from /home/mikolajewskim/puppet-master/spec/localhost/httpd_spec.rb:1:in `require'
from /home/mikolajewskim/puppet-master/spec/localhost/httpd_spec.rb:1
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load_spec_files'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `each'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load_spec_files'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:97:in `setup'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:85:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:in `invoke'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/exe/rspec:4
/usr/bin/ruby -I/usr/lib/ruby/gems/1.8/gems/rspec-support-3.0.2/lib:/usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib -S /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/exe/rspec spec/localhost/httpd_spec.rb failed
Still, when I look at the list of gems, serverspec is there (1.9.0). I've also checked it's existance in gems directory. I'm running a system version of ruby 1.8.7 and I do not have multiple ruby installations.
I'm not really sure where to go from here. Thanks in advance for any help.
What helped was:
1) Upgrading ruby package on the system (still 1.8.7).
2) Upgrading rubygems.
3) Removing all gems.
4) Installing serverspec and rake again.
I have installed DLTK plugin to my Eclipse, so that I can program Ruby in Eclipse. Then I have installed RSpec. When I try to Run As Ruby Test, I always get the following errors:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- spec (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/apple/Downloads/eclipse4ruby/configuration/org.eclipse.osgi/bundles/300/1/.cp/testing/dltk-rspec-runner.rb:12:in `rescue in <main>'
from /Users/apple/Downloads/eclipse4ruby/configuration/org.eclipse.osgi/bundles/300/1/.cp/testing/dltk-rspec-runner.rb:3:in `<main>'
Dose any additional setup/configuration need on Eclipse to support RSpec?
The error message says that the spec gem cannot be found.
Try:
sudo gem install spec
I'm a noob, working through a tutorial which many here may know (testfirst.org). I'm getting the error below in terminal.app, when I try running 'rake':
fname-lnames-macbook-pro:00_hello macbookowner$ rake
(in /Users/macbookowner/Desktop/learn_ruby-master)
/Users/macbookowner/.rvm/gems/ruby-1.9.3-p448#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /Users in PATH, mode 040777
/Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb:116:in `require': cannot load such file -- hello (LoadError)
from /Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb:116:in `<top (required)>'
from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load'
from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `each'
from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:22:in `run'
from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:80:in `run'
from /Users/macbookowner/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:17:in `block in autorun'
/Users/macbookowner/.rvm/rubies/ruby-1.9.3-p448/bin/ruby -S rspec /Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb -I/Users/macbookowner/Desktop/learn_ruby-master/00_hello -I/Users/macbookowner/Desktop/learn_ruby-master/00_hello/solution -f documentation -r ./rspec_config failed
fname-lnames-macbook-pro:00_hello macbookowner$
My questions: What is going wrong? And how can I fix it?
Info:
I got the same/similar error running rvm 1.9.3 and rvm 2.0.0
I installed 'gem install rspec' on both rvm versions
My best guess is that the hello.rb file [which I created in Sublime Text 2, and saved on macbookowner ->Desktop] is not being found by rake. When I run ls on Desktop, it does show hello.rb.
Thanks in advance!
If you look at the error,
/Users/macbookowner/Desktop/learn_ruby-master/00_hello/hello_spec.rb:116:in 'require': cannot load such file -- hello (LoadError)
it shows that in hello_spec.rb, on line 116, there is a require 'hello' statement which is failing. Likely the file does not exist at the path specified.
I'm working on some cucumber tests from The Cucumber Book. I've got the code that tries to use a transaction processor and there is a file with the following code:
require 'service_manager'
ServiceManager.start
This is on Mac OS X 10.6.8 using Ruby 1.9.2. When this file executes, I get the following:
no such file to load -- service_manager (LoadError)
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/gpollice/MyCucumber/ATMBookExample/features/support/services.rb:6:in `<top (required)>'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
The service_manager gem is installed in /opt/local/lib/ruby1.9/gems/1.9.1/gems as are other gems that the application uses. Until I added the code for this iteration, there were no problems. I've looked for reasons why the gem is not found and just can't figure out why. Any help would be appreciated.
It appears to be a load path issue.
Is require "rubygems" invoked prior to this require statement?
Also, if you're using bundler, you have to add this gem to your Gemfile, as bundler attempts to sandbox your dependencies. If you're using bundler, try the following after adding the gem to the Gemfile:
bundle exec rake cucumber