Coder Social home page Coder Social logo

gutkumber's Introduction

Gutkumber

by Daniel Lucraft ([email protected])

Description

A set Ruby-GNOME2 automation helpers. Comes with Cucumber formatters and steps for writing features.

Features

  • Interact with dialogs using Cucumber steps:

     When I click on "OK" in the "Save changes?" dialog
    
  • Make keypresses:

     When I press "Shift+K"
    
  • and mouse clicks:

     When I right click on ....
    
  • Type into TextEntrys or TextViews

     When I type "hello"
    

Install & Requirements

Clone from git://github.com/danlucraft/gutkumber.git Requires Cucumber >= 0.3

Usage

Gutkumber requires that the Gtk main loop NOT be started, in order that it can control the flow of events between steps. Therefore the code that starts the main loop should be modified to look like this:

unless $gutkumber
  Gtk.main_with_queue(100)
end

Other than that, you can load your application normally, from your Cucumber env.rb file.

When you run your Cucumber tests, you must specify one of the Gtk formatters, like this:

--format Cucumber::Formatter::GtkFormatter
--format Cucumber::Formatter::GtkProgressFormatter

Writing a testable Ruby-GNOME2 application

In normal Gtk, Dialog#run blocks. This is no good for testing. To see why, imagine these (imaginary) steps:

When I open the "Save" dialog
And I fill in a filename of "Foo.rb"
And I click on "Save"

Since the Dialog#run method blocks (makes your application do nothing until it receives some input into the dialog), the second two steps will never be reached.

Therefore Gutkumber overrides Dialog#run to just show the Dialog, and not block.

So if you use Dialog#run in your application, then the implication is that you MUST make sure that ALL effects from the Dialog are handled in response blocks. The following will not work anymore:

response = dialog.run
# ... do stuff based on response

Previously the other stuff would only be run after the dialog closed, but in the testing environment, dialog.run will just show the dialog and return nil immediately. Change this code to:

dialog.run do |response|
  # ... do stuff based on response.
end
# absolutely nothing can go here.

This is not ideal. But I haven't been able to come up with any other way to make testing dialogs possible.

License

Gutkumber is copyright 2009 Daniel B. Lucraft and contributors. It is licensed under the GPL2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.