My Tangle with Getting Capybara to See My Little App
Alright, so I wanted to share a bit about my day, wrestling with Capybara. You know how it is, sometimes you just want to test a tiny piece of your application, maybe a specific Rack endpoint or a really simple Sinatra app, without firing up the whole big monster.

I was in that exact spot. Had this small bit of Rack logic, and I thought, “There’s gotta be an easy way to just point Capybara at this thing and nothing else.” I kept thinking about “mounting” this mini-app for Capybara to chew on. My main goal was simple: test this isolated piece quickly.
So, what did I do first? Wasted a bit of time, naturally. I started fiddling around with server settings, thinking I needed to do some complex setup. I was looking for some magic `mount` command within Capybara itself. Searched around, got a bit confused with how Rack itself does mounting, and how that played with Capybara. It felt like I was overcomplicating things, as usual.
I even tried to get clever with Rack::Builder, trying to build a new app on the fly and then somehow tell Capybara to use it. That got messy real quick. Lots of `run` and `map` calls that didn’t quite behave as I expected in the test context.
Then, after a bit more head-scratching and probably another coffee, it clicked. It wasn’t about some fancy “mount” function directly in Capybara for this simple case. It was simpler. It was about telling Capybara what its `app` should be.
Here’s what I ended up doing, and it worked like a charm for my little standalone piece:

- First, I made sure my little Rack app was defined. Something super basic, like:
`my_little_app = proc { env [200, {‘Content-Type’ => ‘text/html’}, [‘Hey there, Capybara!’]] }`
- Then, right in my test setup block – you know, the `before(:each)` or `setup` part – I just set `* = my_little_app`.
- And that was pretty much it! After that, when I did a `visit ‘/’` in my test, Capybara wasn’t talking to my main big application anymore. Nope, it was hitting `my_little_app` directly.
Honestly, it felt a bit anticlimactic after all the faffing about. But man, was it effective. No need to boot the entire framework, no complex server configurations for this specific need. Just point and shoot.
This way, I could test that tiny bit of functionality in complete isolation. Super fast feedback loop, which is always what you want, right? It’s not always about a dedicated `mount` command from Capybara, but more about leveraging its existing way of knowing which app to test against by setting `*`.
So yeah, if you’re trying to test a small Rack-compatible app (like a basic Sinatra app or just a proc) with Capybara and don’t want the overhead of your main application, just try setting `*` directly to your small app. Sometimes the simplest solution is hiding in plain sight. Saved me a bunch of hassle once I stopped overthinking it. Now, testing these little bits is a breeze.