RSS feed

Nutsmuggling

Faking an IP with Webrat

Lately I have been diving into TDD, and more specifically BDD, thanks to the wonderful Cucumber testing framework.

Today I have had to test a specifical IP based feature. Simply put, I get the user IP and store it into the database.

The simple rails way to get a visitor IP address is

request.remote_ip

If you do this while developing you’ll usually get a predictable

127.0.0.1

How do I test that my controller puts a correct IP in the database?
At first I thought about creating a mock request object. But this way I would be testing only the saving portion of the method, not the part detecting the IP. In other words, I needed to simulate an IP address at a lower layer.

Webrat to the rescue! Thanks to the nice folks at the webrat irc channel I got an answer. Simply:

header('REMOTE_ADDR', ip_address)

The Webrat headermethod lets you set all the header variable of you session. Handy, isn’t it?

Events Manager comments disabled

Hi folks,
just a quick note for warning that comments on EM are going to be disabled for a while.
Why?
Despite a disclaimer at the beginning of the post and a huge banner people is posting support problems as comments, instead that on the forum. I guess I should increase the banner size of make it flashy with JS.
As soon as I have some time (not that sooinish) I’ll clean the thread and leave only relevant comments (pre-forum tweak suggestions and release announcements). And re-enable commenting.
For now comments are closed. Use the forum, PLEASE!
Davide

Say hello to Marcus AKA netweblogic

Great news for all ye Events Manager fans. Let us all say hello to Marcus Skyes that jumped on board, and is now co-authoring Events Manager.

Marcus contacted me a few weeks ago, sending a modded version of Events Manager. As soon as I gave it a try I realised that Marcus had done a wonderful job patching and integrating new features into EM.

Thanks to Marcus’s work now we have a number of frequently requested features:

  • WP 2.8 support
  • Events Categories
  • WYSIWYG editor for events description (and you can add pictures too!)
  • multi-day events, kinda

And much more.1

Since Marcus is expanding the plugin for some of his gigs, I invited him to co-author Events Manager, and I am glad he accepted.

I just tagged EM 2.0rc2 with Marcus’s integration, hope you’ll enjoy it as much as I did.

Download EM 2.0rc2

Davide

Notes

  1. Since these features are not yet fully documented, I suggest you take a look at the change log in the readme for instructions. []