Error on custom_require.rb when rspec executed

Hello all,

I’m bekkou68.
I have a error on custom_require.rb, which occurred when I execute
rspec.

I executed the following command.
$ script/spec spec/models/

Then, I got the following result.

/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in

`gem_original_require’: no such file to load – application
(MissingSourceFile)

from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:

31:in `require’

from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/

active_support/dependencies.rb:158:in `require’

from /home/project/vendor/plugins/rspec_on_rails/lib/spec/

rails.rb:3

from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:

31:in `gem_original_require’

from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:

31:in `require’

from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/

active_support/dependencies.rb:158:in `require’

from /home/project/spec/models/…/spec_helper.rb:6

from /home/project/spec/models/eng_word_spec.rb:1:in `require’

from /home/project/spec/models/eng_word_spec.rb:1

from /home/project/vendor/plugins/rspec/lib/spec/runner/

example_group_runner.rb:14:in `load’

from /home/project/vendor/plugins/rspec/lib/spec/runner/

example_group_runner.rb:14:in `load_files’

from /home/project/vendor/plugins/rspec/lib/spec/runner/

example_group_runner.rb:13:in `each’

from /home/project/vendor/plugins/rspec/lib/spec/runner/

example_group_runner.rb:13:in `load_files’

from /home/project/vendor/plugins/rspec/lib/spec/runner/

options.rb:85:in `run_examples’

from /home/project/vendor/plugins/rspec/lib/spec/runner/

command_line.rb:19:in `run’

from script/spec:4

Here is the contents of custom_require.rb.

============================== from here

==============================
#–

Copyright 2006 by Chad F., Rich Kilmer, Jim W. and others.

All rights reserved.

See LICENSE.txt for permissions.

#++

require ‘rubygems’

module Kernel
alias gem_original_require require # :nodoc:

We replace Ruby’s require with our own, which is capable of

loading gems on demand.

When you call require ‘x’, this is what happens:

* If the file can be loaded from the existing Ruby loadpath, it

is.

* Otherwise, installed gems are searched for a file that matches.

If it’s found in gem ‘y’, that gem is activated (added to the

loadpath).

The normal require functionality of returning false if

that file has already been loaded is preserved.

def require(path) # :nodoc:
gem_original_require path
rescue LoadError => load_error
if load_error.message =~ /#{Regexp.escape path}\z/ and
spec = Gem.searcher.find(path) then
Gem.activate(spec.name, “= #{spec.version}”)
gem_original_require path
else
raise load_error
end
end
end # module Kernel

============================== to here

==============================

Should I add ‘require xxx’ ?
Are they some wrong codes on custom_require.rb?
Should I update RubyGems?

I’m really happy if you help me.

Sincerely,
bekkou68

The error is a couple steps back up the trace, in rspec’s rails.rb.
The problem is that you’re running an old version of rspec_on_rails,
which expects ApplicationController to be defined in app/controllers/
application.rb, which it isn’t anymore. Upgrading to the new version
of rspec_on_rails will fix this.

–Matt J.

Dear Mr.Matt,

Thanks for your message, and I’m sorry that I reply late.

Upgrading to the new version of rspec_on_rails will fix this.
I tried to update rspec with the following command.
$ ruby script/plugin install git://github.com/dchelimsky/rspec.git -r
‘refs/tags/1.2.7’ --force
$ ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git
-r ‘refs/tags/1.2.7.1’ --force
$ ruby script/generate rspec
(http://wiki.github.com/dchelimsky/rspec/rails)

Then I can’t execute spec,
$ script/spec -v

script/spec:3:in `require’: no such file to load – spec (LoadError)

from script/spec:3

The contents of spec is following,
$ more spec

#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.expand_path(File.dirname(FILE) + "/…/

vendor/plugins/rspec/lib"))

require ‘spec’

Now I can’t solve this problem.
I’m happy when you help me.

Thanks,
bekkou68

rspec-rails 1.2.7.1 is surely working for me.
Your script/spec file seems like broken, though, I think you’d better
recreate your whole project and try again from scratch.
I recommend you not to edit the generated script/spec file unless
you’re writing a patch for the RSpec project to fix a bug within
RSpec.

If you’re not sticking on vendorizing plugins, config.gem feature
might be an easier way for you.
Put the following lines in your config/environments/test.rb file:

config.gem ‘rspec’, :lib => false, :version => ‘1.2.8’
config.gem ‘rspec-rails’, :lib => false, :version => ‘1.2.7.1’

and run:

% ruby script/generate rspec


Akira M.