I suspect that:
- in irb, when you
require 'cowboy'
, that tells rubygems to set up the load paths automatically to point to the currently installed gem dir. - when you run
test/test_cowboy.rb
it doesn'trequire 'cowboy'
. This makes sense because during development, you don't want to load the installed version of the gem, which could be different from the code in your working dir.
I think you should create a test/test_helper.rb
file that sets up the load path:
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
You may need to add other dirs if the compiled shared object file (.so
or .bundle
) isn't placed in lib
.
Then in each test file (e.g. test/test_cowboy.rb
), require test/test_helper.rb
:
require File.expand_path('../test_helper.rb', __FILE__)
You'll need to adjust that relative path if you have subdirs. E.g. if you have a file test/shoes/spur.rb
, you'd use:
require File.expand_path('../../test_helper.rb', __FILE__)