Reputation: 8119
I am attempting to build a Ruby Gem following this tutorial, however I am unable to configure the rspec as it is unable to find my gem.
$ gem list | grep gemname
gemname (0.0.1.alpha)
$ rake spec
/Users/rudolph9/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -S rspec ./spec/gemname_spec.rb
/Users/rudolph9/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- gemname (LoadError)
from /Users/rudolph9/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/rudolph9/Developer/gemname/spec/spec_helper.rb:2:in `<top (required)>'
from /Users/rudolph9/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/rudolph9/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/rudolph9/Developer/gemname/spec/gemname_spec.rb:1:in `<top (required)>'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from /Users/rudolph9/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
/Users/rudolph9/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -S rspec ./spec/gemname_spec.rb failed
Tasks: TOP => default => spec
(See full trace by running task with --trace)
I this this may have something to do with using rvm or perhaps the way the rake file is being configured on the tutorial previously mentioned but I am not sure.
What is causing the issue?
Upvotes: 0
Views: 448
Reputation: 53158
When you build a gem and want to require it by it's name you need to provide:
lib/gemname.rb
It's less important what's in this file, just what you want like requiring other stuff from it:
require 'gemname/nothing'
where also this file exists:
lib/gemname/nothing.rb
Upvotes: 0
Reputation: 6590
It looks like this is bubbling up from the require
in your spec_helper.rb
file. Is your main gem class the same as your gem's name? You should be requiring the main class and not the gem's name. Try varying the require statement to one of the following and see if you get a different result.
require 'gemname'
# Or
require 'gemname.rb'
# Or
require './path/to/gemname.rb'
I would also try to require the class from IRB and see what circumstances it will work in.
Upvotes: 1