en:
activerecord:
attributes:
user:
sex: Gender
All your validation and form fields are magically renamed. Voila!
en:
activerecord:
attributes:
user:
sex: Gender
Io’s syntax is remarkably compact. You can learn Io very quickly. Once you understand the core syntax, everything else is learning the library structures. I found that I could work my way into metaprogramming quite quickly, within my first month of using the language. In Ruby, getting to the same point took a little longer. In Java, it took many months to get to the point where I could make any sense of metapro- gramming at all.

Closet := Object clone do(
closet := list()
stash := method(item,
self closet append(item)
)
peek := method(
self closet foreach(item, item println)
)
)
myCloset := Closet clone
yourCloset := Closet clone
myCloset stash("rollerskates")
yourCloset stash("bowling ball")
"My closet looks like:" println
myCloset peek
"Your closet looks like:" println
yourCloset peek
My closet looks like:
rollerskates
bowling ball
Your closet looks like:
rollerskates
bowling ball
Closet := Object clone do(
init := method(
self closet := list()
)
stash := method(item,
self closet append(item)
)
peek := method(
self closet foreach(item, item println)
)
)
My closet looks like:
rollerskates
Your closet looks like:
bowling ball
Image recognition can be a useful weapon in your testing arsenal. Our current project is a rails app that generates advertisements. We use sikuli's image recognition to detect that the text and images that we expected to be in the advertisement were actually in the ad. To integrate sikuli with our build we simply created a cucumber step that calls sikuli. Let's cut to the chase and see a sample test.Cool. The magic sikuli step is the one that looks at the ad proof. Here is the step implementation.
Scenario: Dealer places a Campaign Ad
Given "Bill Murray"'s dealership "Ghostbusters" exists in the system
When I log in as "Bill Murray"
And I book a "Year End" campaign ad
Then the ad proof will look like "ghostbusters_tag.png"
Then /^the ad proof will look like "([^\"]*)"$/ do |filename|Pretty straightforward. Call sikuli and pass it a sikuli script and the image. The sikuli script returns the word 'hallelujah' if it looks at your app and determines that the verification image exists anywhere on the screen. Ok. Lets drill down into what the sikuli script looks like. Get your Python goggles on...
feature_dir = File.expand_path(File.dirname(__FILE__) + '/../../features')
sikuli_script_dir = "#{feature_dir}/sikuli"
verification_image = "#{feature_dir}/images/#{filename}"
result = `/Applications/Sikuli-IDE.app/Contents/MacOS/JavaApplicationStub #{sikuli_script_dir}/verify_existance.skl '#{verification_image}'`
result.should match(/hallelujah/)
end
import sysThis one is brief, but I'll explain a bit. Sikuli is a cross platform tool for scripting your computer as well as interacting via image recognition. In this script we make sure that firefox is the app in focus. The image we care about is at the bottom of the page so command down tells firefox to go to the bottom of the page. Finally it looks for the image match. The 0.91 number is basically telling sikuli to be damn sure. We print hallelujah if there is a match.
image = sys.argv[1]
switchApp("Firefox.app")
type(Key.DOWN, KEY_CMD)
if exists(Pattern(image).similar(0.91)):
print "hallelujah"
else:
print "bugger"
