> Ultimately, it looks like they tap into existing HTTP classes in Ruby as well as support for other HTTP classes. I don’t think we’d get that ability with ColdFusion. Railo maybe?
On ColdFusion, No. On Railo, sort of-- but not programmatically. You’d have to install an extension or tag manually by copying some files. Such is the nature of a more “monolithic” type of architecture with everything built in far below the covers. FWIW, Railo is moving in the right direction here. Especially with the move to OSGI bundles in Railo 5 to start breaking up the core.
> Seems reasonable to say “Make HTTP Calls with this ColdBox wrapper for consistency and testability.”
I would agree, and I would encourage you to help author such a library 
> I’m not quite sure where I would start contributing something like that.
Just look at the ColdBox “core” modules. They’re all on GitHub under the “ColdBox” account. Each repo has a little MVC test app, but the actual module code is just in the modules/moduleName folder. For instance, here’s the MessageBox module that replaced the old MessageBox plugin:
https://github.com/ColdBox/cbox-messagebox/tree/master/modules/cbmessagebox
> I would imagine something like this would require extensions to ColdBox-core
No, actually you don’t have to touch the ColdBox core at all. In fact, that’s kind of the whole purpose of modules
All you’re doing is providing a model CFC that provides some utility to a developer. The simplest version of this could literally just be two files:
/modules/foobar/ModuleConfig.cfc
/modules/foobar/models/MyService.cfc
That it. The ModuleConfig wouldn’t even need any special configuration either. When the module is loaded, ColdBox will find MyService.cfc in the “models” convention and register “myService@foobar” automatically.
Then in your docs, you just tell people to do this in their code:
getInstance( ‘myService@foobar’ ).doSomethingCool();
That’s really it.
> would require extensions to ColdBox-core and MockBock.
So MockBox-- I think there’s a couple different thoughts here and I’m not sure they’re mutually inclusive.
-
The first thought is that MockBox would have some functionality to mock HTTP requests, however that supposes the existence of some sort of known wrapper library.
-
The second thought is for the actual wrapper library itself, which for all practical intents and purposes could include the ability to mock the response of a URI which makes me question if the MockBox component is even necessary.
I think the biggest issue is that I can imagine at least two separate scenarios in which a developer might want to mock a remote endpoint:
-
Needs to develop against an unreachable, incomplete, or non-existent remote URI. Would most likely be configured as an per-environment overridden setting just like the MailService settings allow you to send mail to a file only on your dev and stage server.
-
Needs to seamlessly bypass actual HTTP call only when running code inside of a testing suite for the sake of speed and/or isolation of the SUT. The testing suite would either need to programmatically change settings on the fly, or apply a AOP aspect to the HTTP Service to intercept its calls.
Also, keep in mind that when we’re talking about ColdBox we have our full array of tools such as modules, model conventions, CacheBox, LogBox, etc at our disposal. However, MockBox is a standalone tool used by a lot of poor, misguided folk who haven’t found the light of ColdBox and, well, they’re pretty much out in the cold when it comes to standardized code reusability. Therefore, any Mockbox solution pretty much has to be written from scratch and capable of running standalone outside of any framework.
IMO, this is why the lack of modules as a first class citizen of the CFML engines and no singular wide-spread CFML framework is the bane of CF developers existence. We can build nice things, but the non-ColdBox people will never be able to use it-- but I digress…
> Ruby community seems to really like YAML for stuff, but I think something like JSON would be fine too.
My opinion (which assumes a ColdBox-centric module approach) is not to tie your implementation to ANY format. We built an awesome storage aggregator/API called CacheBox which allows you to store arbitrary data in any storage medium you with in a flexible and pluggable fashion. So, just set stuff in CacheBox and allow the dev to choose a cache storage in memory, database, Couchbase, Memcached, or yes, even a file. The format is really irrelevant unless you plan on reading the files. It might as well be base64 encoded binary as long as it just works.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com