0
votes

I am planning on using rspec for integration tests and cucumber for acceptance tests for my application. I wish to use the same page objects for both. I have placed my page objects in the lib directory and I have managed to get cucumber seeing the objects but for some reason rspec cant see the objects in the lib folder.

I have tried using the require_all method. So my spec helper has the following:

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'require_all'
require_all('lib') 

my folder structure is as follows:

>selenium
  >features (this contains my cucumber scenarios, support dir with env file etc)
  >lib (this is the folder with the page objects contained in sub directories)
  >spec
    spec_helper.rb
    >features (rspec scenarios)
    >support

When I attempt to run a test using the command rspec testfile.rb I get the error message: 'rescue in require_all': no such file to load -- lib (LoadError)'

Anybody have any idea what I am doing wrong here? Any help would be greatly appreciated!

Thanks!

1

1 Answers

0
votes

require_all is looking for the folder relative to the working directory. Assuming you are running the rspec command from the spec/features folder, then require_all('lib') is looking for a lib folder in features (ie spec/features/lib). I do not believe that require_all checks the $LOAD_PATH.

I would suggest using require_rel instead as it is relative to the current file. In the spec_helper.rb, do the following instead.

require 'require_all'
require_rel ('../lib')