I'm trying to practice writing tests for challenges on CodeEval. Each challenge I'm creating a folder, inside the project folder I create 'lib' & 'spec' folder. From the command line I run:
rspec --init
it tells me that 'spec/spec_helper.rb' & '.rspec' are created. I put the source file in the 'lib' folder & the spec file in the 'spec/lib' folder & name them accordingly. Here's an example of a spec:
require 'spec_helper'
require 'file_name'
describe '#swap_elements' do
it 'should swap 1 pair of numbers' do
swap_elements('1 2 3 4 5 6 7 8 9',0,8).should == '9 2 3 4 5 6 7 8 1'
end
end
from the project's root directory I run:
rspec /spec/lib/file_name_spec.rb
and the result is the following:
/Users/username/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load': cannot load such file -- /spec/lib/swap_elements_spec.rb (LoadError)
from /Users/username/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /Users/username/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /Users/username/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /Users/username/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/username/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /Users/username/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
This is a recent problem & I haven't installed any updated rspec gems. Any idea why this is happening?
/spec/lib/swap_elements_spec.rbfile and is it "loadable"? - Peter Alfvin