CIT 591 Testing and running Shoes
Fall 2009, David Matuszek

Here is an example of a trivial Shoes GUI with separate model and test files.


example_gui.rb model.rb
def double n
  2 * n
end
require 'model'

Shoes.app do
  stack do
    number = edit_line
    button "Double" do
      number.text = double(number.text.to_i).to_s
    end
  end

end

How to run this:

  1. Double-click the Shoes program,
  2. Click on Open an App.
  3. Navigate to the file example_gui.rb.
  4. Open the file.

test.rb
require "test/unit"
require "model"

class ModelTest < Test::Unit::TestCase

  def test_double
    assert_equal 26, double(13)
  end
  
end

How to run this:

  1. Open a terminal (DOS) window,
  2. Navigate to the folder containing this file,
  3. Enter ruby test.rb