Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Respect RABBITMQ_URL if it's set. #52
This change makes Sneakers respect the
Since the RabbitMQ virtual host can be set in the URL, this change makes makes it look for the virtualhost there rather than defaulting to '/'.
At present in Sneakers, it's possible to set the amqp_url to a value that includes a virtual host, but unless you explicitly set the virtualhost value as well, Sneakers will still use "/". This caused me a bit of confusion at first, as I was wondering why my URL with a virtual host wasn't sufficient to set that value in Sneakers.
Note that there are no tests in place for this, since at present the DEFAULTS hash is initialized at compile-time and frozen, which means it's too late to set the ENV var in the tests. I think it would be a good idea to implement a Sneakers::Configuration class with accessor methods for the config variables Sneakers uses; I've done something similar in friendly_id, but didn't want to send you too large a pull request unless you agreed with the idea.
Note - i'll merge but feel free to keep discussing here
added a commit
this pull request
Jul 6, 2014
Thanks @jondot for this and the other merges, I'm glad you find them useful.
I don't think in this case mocking would be enough to make this code testable; by the time we can begin to implement our mocks, the Sneakers library will already have been loaded, and the RABBITMQ_URL would have been parsed.
The approach I'd take to solving this issue would be to create a configuration class and instantiate an instance of it at compile time. Then to test it you can create another instance of it in your tests. The code that parses the RABBITMQ_URL could go in the constructor, and set an instance variable for
I'll work on that today and send over a PR to see what you think.
With my coworker @deepakinseattle we also already tweaked the code in this PR to use