The Simplest Possible Cucumber Test

I’m not really that good at testing. So what, so are a lot of people. Having some tests is better than none! And, the way testing tutorials are written can seem really complex and scary. Today I started thinking about the simplest possible way to get started with web app testing.

When I’m getting back into a project after not working on it for a while, I just want to know whether the application works. I want to know whether it will run on my development environment, even if I’m on a new machine. I have three computers that I use at various locations so this is important to me.

So for me the simplest possible test would be:

  • The home page should load. That is the default route should return a successful page without any errors. It will have some key piece of text that says it’s working.

Here’s how I do it with cucumber:

If you haven’t installed the cucumber gems yet, put this in your config/test.rbfile.

If you haven’t cucumber set up yet, run

script/generate cucumber

Then, create the file below:

File: features/homepage.feature

Feature: View homepage for app
  In order to make sure the app loads
  As a user
  I want to see the home page

Scenario: Homepage should say Search
  When I go to the homepage
  Then I should see "Search"

Tip: none of what you write in the Feature section really matters. It’s just for you or your client’s benefit.

Then, run

cucumber features

You should get the following output:

:> cucumber features
Feature: View homepage for app
  In order to make sure the app loads
  As a user
  I want to see the home page

  Scenario: Homepage should say Search # features/homepage.feature:6
    When I go to the homepage          # features/step_definitions/webrat_steps.rb:10
    Then I should see "My Telltale Text" # features/step_definitions/webrat_steps.rb:118

1 scenario (1 passed)
2 steps (2 passed)

Some cool things about this: “the homepage” is something that cucumber / webrat understands out of the box. See features/step_definitions/webrat_steps.rb for how to define other custom route names. And also, “I should see “something in quotes” is out of the box cucumber goodness.

Posted in Technology, Web Design, rubyonrails | Tagged , , , , , , , | Leave a comment

Real Direct Democracy

We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness. That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed.

Not all corporations are created equal, as our conservative supreme court seems to think. It’s time to use our people power to set that straight. And, while we’re at it, let’s set up a direct democracy party too! The Australians have already made a first step!

Posted in Technology | Tagged , | Leave a comment

Tired of Time Machine Running All the Time?

If you have a Mac laptop, and use an external drive for a backup, you may have noticed it seems like Time Machine is calculating changes almost all the time, or at least way too often. This is probably because it starts a backup after the computer wakes from sleep.

If you’re like me, and don’t need hourly backups — one a day will do, thanks — there is a free program called TimeMachineEditor that lets you set a backup schedule. I have mine set for 2:30am so that it does not intrude on my work day.

Posted in Uncategorized | Tagged , , , | Leave a comment

Rails Rescue Handbook, an ebook by Mike Gunderloy

Rails is a powerful development tool for web applications – but that power can lead inexperienced developers astray. If you're working on a Rails project gone bad, the targeted advice in this ebook will get you back on track quickly.

Posted in Uncategorized | Tagged , | Leave a comment

Ruby on Rails Tutorial: Learn Rails by Example | by Michael Hartl

Rails Tutorial contains integrated tutorials not only for Rails, but also for the underlying Ruby language,4 as well as for HTML, CSS, some JavaScript, and even a little SQL. This means that, no matter where you currently are in your knowledge of web development, by the time you finish this tutorial you will be ready for more advanced Rails resources, as well as for the more systematic treatments of the other subjects mentioned. A book-in-progress—drafts currently available for chapters 1–7.

Posted in Uncategorized | Tagged , , | Leave a comment

New Report: Green Marketing Brings in the Dough – The Green Inkwell

How effective is Green marketing, really?

That’s what the authors of Green Marketing: What Works; What Doesn’t – A Marketing Study Of Practitioners asked in a recent study by Watershed Publishing. The report summarizes the real-life results of Green marketing by the audiences of five industry publications.

Posted in Uncategorized | Tagged , , | Leave a comment

WHM/cPanel Manual Site Removal – The Planet Forums

How to remove a corrupted cpanel account via command line

Posted in Uncategorized | Tagged , , | Leave a comment

What’s My DNS? – Global DNS Propagation Checker

A great tool for checking what your DNS name servers are from around the world – to see how propagation is going when transferring web hosts.

Posted in Uncategorized | Leave a comment

WebNotions: How to Avoid Getting Screwed by New Clients (fishers and wolves)

One consultant's process for weeding out troublesome clients up front. Includes a discovery phase, which I like. This is for new potential clients, not for existing clients that you are having trouble with.

Posted in Uncategorized | Leave a comment

Twitter Weekly Updates for 2009-12-13

Powered by Twitter Tools

Posted in Uncategorized | Leave a comment