Posts Tagged ‘WordPress should be more like Rails’

WordPress Docs 29th Apr 10

With a couple of days between projects, I had a chance to work on my latest 20% project.

RailsAPI‘s sdoc format is very nice in that it allows searching over all methods and classes, and is generally an intuitive way of doing things.

WordPress is full of PHPDoc comments, the Codex is invaluable, and of course being able to read the source is absolutely necessary much of the time. All in all, WordPress is quite well documented, though there’s really no coherent place that brings that all together. So I am very happy to have this new tool available before my next WordPress jaunt: WordPress Docs.

Testing WordPress with Cucumber 19th Nov 09

I should probably introduce myself first: I’m Tom, Dextrous Web employee #1.

We do quite a bit of work with WordPress, and one of the problems we’ve found is that it doesn’t lend itself to the kind of automated testing that we do with the rest of our projects. The code for themes easily gets pretty cluttered, and it’s hard to know what the consequences of installing a WordPress upgrade or new plugin might be.

One of the tools that we use for our Ruby on Rails projects is Cucumber, a Behaviour Driven Development tool that makes front-end testing of Rails applications really easy. There’s an example below, but in brief: it lets you write human-readable tests and then run them on your application to make sure it’s working properly. Because Cucumber tests the front-ends of web applications, it’s not tied to any one technology — so we thought, why not use it to test WordPress?

So I spent some time writing a little bit of configuration magicks and step definitions, and here it is: cucumber-wordpress.

To get started you’ll want to install the gem:

gem install cucumber-wordpress --source http://gemcutter.org

Then copy the example features directory from the gem into the root of a WordPress installation:

cp -R /usr/lib/ruby/gems/1.8/gems/cucumber-wordpress-1.0/examples/features .

Configure your test database, and where the site is being served from:

vim features/support/config.yml

And test:

cucumber

Here’s a sample:

Background:
    Given WordPress is installed
 
  Scenario: Submitting a post
    Given I am logged in as "admin"
    And I am on admin dashboard
    When I follow "Add New" within "#menu-posts"
    And I fill in "title" with "I <3 cucumber"
    ...

I’ve been testing a plugin with this for a week now, and it’s been very smooth.

Here at The Dextrous Web we’re committed to backporting the Rails culture to WordPress.

Categories

Recommended reading

  • A selection of interesting links. Refresh to see more
  • Digigov @ COI These guys set cross-government digital policy. Lots of interesting things.
  • A List Apart Fantastic articles on usability and the future of the web
  • Public Strategist Thoughts and discussions on strategy from a large central government department
More »