Problem using require command

657 views Asked by At

I am simply requiring a file present in the same folder as the testfile however I am getting this wierd message again and again...

<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- a.rb (LoadError)
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from C:/dummyFirefox/test_a.rb:1:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `block in load_spec_files'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `map'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load_spec_files'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in `run'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `block in autorun'

the code that I write in my testfile test_a.rb is simply:

require 'a.rb'

and when I issue the command : rspec test_a.rb the message is the above mentioned error.

I am using ruby-1.9.2 for development.

Hope I don't miss any details. Thanks in advance.

1

There are 1 answers

0
Koraktor On BEST ANSWER

In Ruby 1.9.2 the current working directory is no longer part of the load path ($LOAD_PATH or $:). You have to add it manually using:

$LOAD_PATH.unshift '.'

or

$:.unshift '.'

Or you can require the file explicitly:

require './test_a.rb'