Hello, dear habrasoobschestvu.
Not so long ago, I started to bother not only testing code for ruby, but also js, which is becoming too much in projects. With
In time I got to IU on js, and for testing it was necessary to simulate all sorts of different events. Having searched, I found a solution in one of the libraries on jquery. In the extensions for testing, there was a
required library for simulating events. But bad luck, we use prototype (I’m a hardened rubist and I like it), not jquery.
After some thought, I decided to correct this, for use as a plugin for prototype. What came of it? Well, it helped me a lot in the tests. If you are also a supporter of the tested code, it will be useful for you too.
In use, it looks like this:
')
$('foo').simulate('keypress', Event.KEY_RETURN);
$('foo').simulate("drag", {
dx: 10,
dy: 0,
onComplete: function(element){
alert('drag simulation $(' + element.id + ')');
}
});
I deliberately expanded the Element, and not the Event - it seems more logical to me, although it can be discussed.
The compressed version weighs 3K,
with 7K
documentation .
GitFor jquery fans, the link is higher.