I've recently started using Cucumber & Subdomain-fu together, and it's made me do some terrible things.
I have a step definition that used to look like this:
path = grok_path(path)
get path
That's nice and easy, in my opinion. But now it's this:
path = grok_path(path)
get "http://#{subdomain}.example.com#{path}"
This works, but it's not exactly clean. What's a better way to do this?
Just to make step definitions more readable, you could wrap that stuff in a small method, like follows:
def subdomained_path(path, subdomain):
return "http://#{subdomain}.example.com#{path}"
end
Which allows you to tidy up your step definitions into something like:
path = grok_path(path)
get subdomained_path(path, subdomain)
Functionaly the two are equivalent (and equally as hacky), but the changes I suggested will at least make the code look a bit cleaner. If you have access to modify Net::HTTP.get, you can modify the actual "get" method to accept a subdomain argument, making it even cleaner.