Saturday, February 28, 2009

Permission denied - db/test.sqlite3

I'm investigating creating a plugin for Redmine and having a good old time when I decide to clear out the test database:

C:\dev\redmine>rake db:test:purge
(in C:/dev/redmine)
rake aborted!
Permission denied - db/test.sqlite3

Boo! 

I don't know what made me think of it but I tried unsetting my RAILS_ENV environment variable (I had it set to "test"):

C:\dev\redmine>set rails_env=

C:\dev\redmine>rake db:test:purge
(in C:/dev/redmine)

C:\dev\redmine>

Hurrah!

Sunday, February 22, 2009

Formatting README.rdoc on github

Github has a neat feature that displays a README file, that it finds in the root directory of a project, on the project page. The README formatting page describes a number of different formats that it will render based on the file extension. I tried renaming to README.rdoc but it still rendered as plain text. The trouble was that the file was intended to be used with a full RDOC site for the source. When I removed the "link" tags from the file and pushed ... Github renders it correctly ... Hurrah!

Saturday, February 14, 2009

BDD WxRuby applications with Cucumber and Nobbie

For a long time now, I've been wanting to write some Cucumber features to describe a WxRuby application I have. A couple of weeks ago, I found a library called wx-nobbie on Rubyforge that seems to be almost exactly what I was looking for.  It provides a simple, high level interface for driving WxRuby applications through commands like "click", "choose" and "type".  I had a little trouble getting the tests to pass to start with, but with a few minor tweaks I got there.  I contacted the original author and got his permission to take it forward.

I created a GitHub repository for Wx-Nobbie and have made a few updates over the last week.  Currently, I've got 4 feature scenarios with 10 steps:

C:\dev\wx-nobbie>rake features
(in C:/dev/wx-nobbie)
In order to test drive a WxRuby application  # features/acceptance_test.feature
As a developer
I want Nobbie to provide acceptance test access to the application
  Scenario: Choosing a radio button  # features/acceptance_test.feature:5
    Then "radio_button" is not chosen# features/step_definitions/acceptance_test_steps.rb:21
    When I choose "radio_button"     # features/step_definitions/acceptance_test_steps.rb:1
    Then "radio_button" is chosen    # features/step_definitions/acceptance_test_steps.rb:17

  Scenario: Choosing a check box  # features/acceptance_test.feature:10
    Then "check_box" is not chosen# features/step_definitions/acceptance_test_steps.rb:21
    When I choose "check_box"     # features/step_definitions/acceptance_test_steps.rb:1
    Then "check_box" is chosen    # features/step_definitions/acceptance_test_steps.rb:17

  Scenario: Type into a text control        # features/acceptance_test.feature:15
    When I type "123" into "text_ctrl"      # features/step_definitions/acceptance_test_steps.rb:5
    Then I should see "123" in "text_ctrl"  # features/step_definitions/acceptance_test_steps.rb:9

  Scenario: Type into a combo box           # features/acceptance_test.feature:19
    When I type "456" into "combo_box"      # features/step_definitions/acceptance_test_steps.rb:5
    Then I should see "456" in "combo_box"  # features/step_definitions/acceptance_test_steps.rb:9


4 scenarios
10 steps passed

With just these 4 scenarios, RCov tells me I have 62.9% coverage.

Hurrah!