A
Adam Akhtar
Untill now whenever i made a script Id put all its files into a
directory along with any test files. When it came to requiring my own
files I could just do require "filename" as they were all in the same
place.
Now ive tried to create a directory structure that a lot of you pros use
such as
project
/bin
/lib
project.rb
/project
..any related files here
/tests
test.rb
/samples
..any stuff my tests may need e.g. offline webpages to scrape
etc
though im not planning on releasing any gems i just want a tidier
structure. however with this comes the headache of require.
At first i simply put this in my project.rb file at the top
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
and that made things ok
but then when i do tests what do i put in them? do i need to add
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
again or do i just do an include "/../lib/project.rb" and let it declare
the new path??
ideally i want one place where i declare it and then forget all about
it. I have searched previous posts but none seem to mention what to do
in your test files. Any one help?
directory along with any test files. When it came to requiring my own
files I could just do require "filename" as they were all in the same
place.
Now ive tried to create a directory structure that a lot of you pros use
such as
project
/bin
/lib
project.rb
/project
..any related files here
/tests
test.rb
/samples
..any stuff my tests may need e.g. offline webpages to scrape
etc
though im not planning on releasing any gems i just want a tidier
structure. however with this comes the headache of require.
At first i simply put this in my project.rb file at the top
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
and that made things ok
but then when i do tests what do i put in them? do i need to add
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
again or do i just do an include "/../lib/project.rb" and let it declare
the new path??
ideally i want one place where i declare it and then forget all about
it. I have searched previous posts but none seem to mention what to do
in your test files. Any one help?