Test environment running in www.example.com domain

I noticed that my tests are run in the www.example.com domain. I’m
using rspec and capybara, so visit sports_url tries to visit
www.example.com/sports. This works fine with the default test driver,
but I have some javascript that I need to test. These tests fail
because the browser tries to access www.example.com/sports (which
obviously doesn’t exist). The browser is used by the selenium driver
of capybara to test javascript. If I use visit sports_path the
local web server is access with both the standard and selenium
drivers.

Should I be configuring the test environment somehow to NOT be running
as www.example.com? Or am I testing in the wrong way?

Thanks