I want to fake an API with a little Sinatra app, following this method. Meaning I have a Rails app, and in the spec/support folder, a very simple Sinatra app:
module FakePrograms
class Application < Sinatra::Base
get "/API/V1/programs" do
{
programs: [
...
]
}.to_json
end
end
end
Part of the goal is to launch this app locally, so I can work on my Rails app with a fake API. Problem: when I do ruby spec/support/fake_programs.rb
, the app can't boot, and I get a
config/puma.rb:14:in `block in _load_from':
uninitialized constant
#<Class:#<Puma::DSL:0x007fac0b0e0380>>::ActiveRecord (NameError)
Looks like Sinatra is booting using my Rails configuration. I don't need ActiveRecord nor Puma for my fake API.
I've read this question and this other one, but theese are in different context, because they need their Sinatra app to share routes with the Rails app.
Content of config/puma.rb:
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
I was looking at the config.ru file, but @max is right, it's not correlated.