Categories
Java Ruby

String#casecmp

As far as I can tell, this is the correct way to do case-insensitive string comparison in Ruby:

if string1.casecmp(string2) == 0
  # strings match, ignoring case
end

That’s so ugly, it almost looks like Java. Actually, it’s worse than Java, which has String#equalsIgnoreCase.

Categories
Agile Ruby Software

Driving Selenium from the RSpec Story Runner (RBehave)

[Update] The story runner is now included in the 1.1 release of RSpec, so a lot of the hackery mentioned below is no longer required. See http://rspec.info/ for details.

Background

A while ago I cobbled together some code to drive Selenium from Exactor (which was the acceptance testing framework we were using at the time). That project was offshored shortly afterwards, and I’m pretty sure Selenium never actually got integrated into the build (sneaking a peek at the continuous integration server reveals that even the pre-Selenium acceptance test build hasn’t run successfully for months), but I was convinced of the value of Selenium for testing non-trivial web applications.

On my next project (the Web21C SDK portal) we used Selenium on Rails heavily for automated acceptance testing. This worked well, although the fact that the tests are deployed with the application limits what you can do – you can’t interrogate the database after a test, for example, or dynamically set up stubs for systems you interface with (unless you also deploy the stubs as part of the application, and drive them from the browser).

With Mojo there’s an additional complication: as well as being accessible through a browser, most functionality is also available as a RESTful API, using digest-based authentication. To keep our acceptance tests in one place, we wanted to be able to drive a browser using Selenium, alongside other tests which talked to the server directly. The obvious answer was to use Selenium Remote Control, and I also liked the look of RBehave, which has now been incorporated into RSpec (but not released yet).

The RSpec story runner

The story runner in the upcoming release of RSpec is an evolution of Dan North’s RBehave, which in turn is based on JBehave (from the same author). In the past couple of weeks, David Chelimsky has done some excellent work on extracting the text of stories from the code, leading to the plain text story runner.

Read on for the gory details of my solution to running Selenium tests from the story runner.

Categories
General nonsense

Parochial Ethnicity Option

This from the profile page on Orkut (which is, of course, an international site):

Orkut ethnicity options

Someone really ought to tell them that African American isn’t a globally-applicable synonym for Black.

Categories
Rants

An Apostrophe is not an Open Quote

Just spotted this dreadful logo for Le Web 3:

Le Web Logo

I know this often happens in body text when an over-enthusiastic ‘smart quotes’ feature in a word processor mistakes the apostrophe for an opening quotation mark, but someone really should have noticed it in a logo.

Categories
Rants

Corporate Web Filtering

The other day I was listening to someone speaking about the rollout of an open source web-filtering solution to 20,000 pupils in the Yorkshire and Humber area. A mildly interesting story in itself, and a nice win for the OSS community, but it got me thinking.

When it comes to Internet access, Why do some companies literally treat their employees like children?

Categories
BT

No Internet and no Software

One of the questions for the panel at Wednesday’s Open Source event at BT Centre concerned the fact that most of the company doesn’t have a connection to the Internet; just proxied web access. Also, installing any software not on a relatively small approved list is forbidden.

“Given that we don’t have the Internet or any software, how are we supposed to work with Open Source?”

Doc Searls‘s response:

“The current policy is freaking insane! It’s utterly inconsistent with BT’s strategy, and I can’t understand why anyone would want to come and work here… Maybe we ought to go and storm the head office or something.”

[tags]policy, internet, open source, doc searls[/tags]

Categories
Apple Ruby

Ruby in Leopard: so close and yet…

I was quite excited to see the announcement of improved Ruby and Rails support in Leopard, and one of the first things I did after upgrading was to delete my MacPorts installations of Ruby and RubyGems, and try using the built-in ones instead.

For a while, all seemed well. The milk was cold, the food stayed fresh, my specs still passed, my Rails projects still worked, and even the light worked when you opened the door.

But then the trouble started.

Firstly I tried updating and installing gems while behind a firewall. The gem command completely ignored my http_proxy setting, and when I explicitly provided the proxy using -p, I got this error:

ERROR:  While executing gem ... (NoMethodError)
    undefined method `[]=' for #

I worked round this by downloading the gems manually and installing the local copies (despite this being a pain, especially when there are dependencies).

I then tried using gemsonrails to freeze some gems, and it got confused by the fact that Leopard stores built-in gems separately from user-installed ones. Thinking about it, if I’d successfully frozen the gem, it might have turned out to have been tweaked in some Mac-specific way and broken on other platforms.

Forgetting about that issue, I carried on with other work for a while, then found that autotest wouldn’t work, and mysteriously was trying to run something from /opt/local (where MacPorts install lived). Even after removing any gem-related scripts from /opt/local/bin, the problem persisted.

Oh well, looks like I’ll be re-installing everything using MacPorts. I’m not sure whether all these problems are intrinsic to the Ruby installation that comes with the system, or whether some are caused by lingering remains of my MacPorts installation – I’d be interested to hear how others got on.

[tags]ruby, rails, mac, 10.5, leopard[/tags]

Categories
Rails Software

Rails, SOAP and REST

From the list of new features coming in Rails 2.0:

It’ll probably come as no surprise that Rails has picked a side in the SOAP vs REST debate. Unless you absolutely have to use SOAP for integration purposes, we strongly discourage you from doing so.

Categories
General nonsense

LolSecretz

Ever wondered what would happen if you mixed lolcats with PostSecret?

Of course you have.

Categories
General nonsense

Cool steganography trick

Very clever.