Here's my config.ru
$:.unshift File.join(File.expand_path(File.dirname(__FILE__)), 'config')
require 'boot'
Routes = Rack::Mount::RouteSet.new do |set|
set.add_route App::Users, { :path_info => %r{^/users*} }, {}, :users
set.add_route App::Dashboard, { :path_info => %r{^/$} }, {}, :dashboard
set.add_route Rack::File.new(File.dirname(__FILE__) + "/public"), { :path_info => %r{^/*} }, {}, :public
end
run Routes
boot.rb
require 'bundler'
Bundler.setup
Bundler.require(:default)
Mongoid.load!(File.join(File.dirname(__FILE__), '/mongoid.yml'))
%w(sinatra json yaml rack/mount rack/contrib).each {|l| require l }
Dir["./lib/**/*.rb"].each { |f| require f }
And my lib
contains the apps and the models.
How to let Cucumber to see my application:
here's cucumber env.rb
require 'capybara'
require 'capybara/cucumber'
require 'rspec'
World do
Capybara.app = App
include Capybara
include RSpec::Expectations
include RSpec::Matchers
end
What I want is to let env.rb read my config.ru and get my cucumber ready for testing.
In @amrnt's solution you can replace that line
Capybara.app = eval("Rack::Builder.new {( " + File.read(File.dirname(__FILE__) + '/../../config.ru') + "\n )}")
with this:
Capybara.app, _ = Rack::Builder.parse_file(File.expand_path('../../config.ru', __FILE__))
or
Capybara.app = Rack::Builder.parse_file(File.expand_path('../../config.ru', __FILE__)).first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With