From: Carl Jenkins on 23 Jul 2010 17:58
> On Fri, Jul 23, 2010 at 2:28 PM, Carl Jenkins <carljenkins(a)gmail.com>
>> In order to test the new_file.rb my new_test.rb must have the path to
>> the new_file.rb as the require correct? Something like require
>> Or is there a different way to do that?
> Just looked at one of my bones-generated projects:
> $ cat spec/spec_helper.rb
> require File.expand_path(
> File.join(File.dirname(__FILE__), %w[.. lib fooz]))
haha - that's genius..
(I should have known better and just looked myself.)
Posted via http://www.ruby-forum.com/.
From: Jarmo Pertman on 27 Jul 2010 12:42
On Jul 23, 9:28 pm, Carl Jenkins <carljenk...(a)gmail.com> wrote:
> In order to test the new_file.rb my new_test.rb must have the path to
> the new_file.rb as the require correct? Something like require
> Or is there a different way to do that?
> Thanks for all the help - (everyone) this is most helpful!
I would play with the $LOAD_PATH in your spec_helper or whatnot:
require "spec_helper" # require in every spec file
require "my_class" # now it's possible to require my_class from lib
dir because of changed $LOAD_PATH
describe MyClass do
it "test, test, test!" do
Or, if using really RSpec, then create a spec.opts file into the spec
directory and require it from there:
Then you can remove those require statements from spec files
themselves. Although if you're using some kind of an IDE, then they
might get confused, but i don't mind :)
IT does really matter - http://www.itreallymatters.net