Tests for plugins - "require"d files

Hi,

I’m having trouble writing tests for a plugin I’m working on.
In my plugin directory, I have /lib/my_plugin.rb :

require ‘extensions’ # in [plugin]/lib

class NewClass < ActiveForm # ActiveForm defined in a different plugin
end

My [plugin]/test/my_test.rb has the following

require ‘test/unit’
require File.dirname(FILE) + ‘/…/lib/my_plugin’

However, I get

“in `gem_original_require’: no such file to load – extensions
(LoadError)”

and, if I remove the call to require ‘extensions’

======
uninitialized constant ActiveForm (NameError)

How can I write my tests/structure my plugin to avoid these errors?

As an aside, is there any documentation on what the load path is at any
given
time? I mean something saying “[these] directories are available when
[…]”
rather than me having to try 'puts’ing a variable at different points in
my
application to learn through trial and error

Thanks,
Gareth

This is the situation:

[plugin]/lib/my_module.rb

require ‘validations’

module MyModule
module Transaction
class Request

All of these give a NameError

include Validations

include parent.Validations

include MyModule::Transaction::Validations

  [...]
end

end
end

[plugin]/lib/validations.rb

require ‘validations’

module MyModule
module Transaction
module Validations
[…]
end
end
end

[plugin]/init.rb

require ‘validations’
require ‘my_module’

Also gives the same NameError:

VSPDirect::Transaction::Request.module_eval do

include Validations

end

======

The question is, what is the best way of doing what I’m trying to do? I
hope
it’s obvious, but if it’s not then ask for clarification

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs