Reputation: 2095
Trying to create the initial config for a cucumber/ruby test framework and I was thinking about defining some global paths in the env.rb file as follow:
def project_path
File.expand_path(File.dirname(__FILE__) + '/../../../')
end
def config_path
"#{project_path}/features/support/config"
end
thinking about then invoking those Paths from the ruby code.
The problem I'm having is that when I try to run the tests, they fail with:
undefined local variable or method `config_path' for Configuration:Class (NameError)
I suppose that 'config_path' is not define before the module/class is trying to use it? Is there a way to indicate that we'd like everything in the env.rb file to be processed before anything else is done? (Not sure if this is even been done already and the failure is in another point?)
Upvotes: 2
Views: 3117
Reputation: 6036
try this in env.rb
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode'
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'
require 'webrat'
require 'webrat/core/matchers'
Webrat.configure do |config|
config.mode = :rails
config.open_error_files = false
end
ActionController::Base.allow_rescue = false
Cucumber::Rails::World.use_transactional_fixtures = true
Upvotes: 1