Is it possible to run an rspec on a file which requires other files?
my .rb file has the following lines:
require "colorize"
require "./board_initializer"
require "./pieces"
and when running a rake I get the following error:
.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- ./board_initializer (LoadError)
Thanks!
The error means board_initializer.rb isn't in the current working directory for __FILE__. Some ways to resolve this include:
require
.require_relative
with a valid relative path.There are certainly other ways to resolve this, but they all amount to ensuring that board_initializer.rb can be found by the interpreter when you load or require the file.