<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>● alloy writes / stuff</title>
  <link href="http://superalloy.nl/feed.xml" rel="self" />
  <link href="http://superalloy.nl/" />
  <updated>2009-04-14T12:18:03+02:00</updated>
  <author>
    <name>Eloy Duran</name>
    <email>me@superalloy.nl</email>
  </author>
  <id>http://superalloy.nl/</id>
  
  <entry>
    <title>Headless Squirrel</title>
    <link href="/2009/04/14/headless-squirrel.html" />
    <id>tag:superalloy.nl,2009-04-14:1239702953</id>
    <updated>2009-04-14T11:55:53+02:00</updated>
    <content type="html">&lt;p&gt;&lt;img src=&quot;/images/headless-squirrel.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Another day, another name&lt;/h3&gt;
&lt;p&gt;Yesterday I wrote &lt;a href=&quot;/2009/04/13/js-test-san.html&quot;&gt;an article about JSTestSan&lt;/a&gt;. Today, however, I decided to move the repo to &lt;a href=&quot;http://github.com/Fingertips/headless-squirrel/tree/master&quot;&gt;our Fingertips account&lt;/a&gt; and also change its name to &lt;strong&gt;“Headless Squirrel”&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The command-line tool is still called &lt;code&gt;jstest&lt;/code&gt;, only the name and locations were changed. I’ve updated the previous post to reflect these changes.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>JSTestSan (Updated!)</title>
    <link href="/2009/04/13/js-test-san.html" />
    <id>tag:superalloy.nl,2009-04-13:1239637553</id>
    <updated>2009-04-13T17:45:53+02:00</updated>
    <content type="html">&lt;p&gt;&lt;strong&gt;Note that the name and locations of this project have changed. The new name and locations in this article have been updated to reflect this. See the &lt;a href=&quot;/2009/04/14/headless-squirrel.html&quot;&gt;Headless Squirrel article&lt;/a&gt; for more info.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A OS X command line tool to run JavaScript (Prototype) unit tests from the comfort of your terminal.&lt;/p&gt;
&lt;h3&gt;Why?&lt;/h3&gt;
&lt;p&gt;Recently I came across &lt;a href=&quot;http://tenderlovemaking.com/2009/04/05/testing-javascript-outside-the-browser/&quot;&gt;an article on testing JavaScript outside the Browser&lt;/a&gt;, which talks about running tests written in Ruby against your JS libraries.&lt;/p&gt;
&lt;p&gt;At the office we loved the idea of being able to run our JS unit tests together with all other (Rails) tests. However, not in the way the aforementioned article suggests.&lt;/p&gt;
&lt;p&gt;Now I know the title of the article explicitly says “outside the Browser”, but running outside of a real browser seems a bit pointless to me. I’d rather run them inside an actual browser, as we are currently doing by hand on Safari. And also write them in a format that would allow us to run them by hand on &lt;em&gt;any&lt;/em&gt; browser, ie HTML/JavaScript.&lt;/p&gt;
&lt;p&gt;Since we’re all on Macs, my Cocoa flags where quickly raised. Especially on the use of &lt;a href=&quot;http://webkit.org&quot;&gt;WebKit&lt;/a&gt;, which, as you might know, powers Safari.&lt;/p&gt;
&lt;p&gt;I fired up my favorite text editor and wrote a prototype. Happy with the results I decided to re-write it for real this weekend. &lt;em&gt;Also because I needed something noteworthy to write about on this new blog ;-)&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Install&lt;/h4&gt;
&lt;p&gt;The source is available as either a Ruby gem, or directly from &lt;a href=&quot;http://github.com/Fingertips/headless-squirrel/tree/master&quot;&gt;GitHub&lt;/a&gt;. To install the gem:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo gem install Fingertips-headless-squirrel -s http://gems.github.com&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Usage&lt;/h3&gt;
&lt;p&gt;Headless Squirrel comes with a command-line tool, called &lt;code&gt;jstest&lt;/code&gt;, which you can feed HTML files that run Prototype unittest.js test cases.&lt;/p&gt;
&lt;p&gt;For instance, let’s run the Prototype test suite which comes bundled with the Headless Squirrel source code (updated slightly):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ jstest test/regression/prototype/unit/*_test.html
...................................................................
...................................................................
....F..............................................................
...................................................................
...................................................................
.....................

  1) Failed:
testViewportDimensions (Unit test file | Dom | default template | 2009-04-11 15:28) [test/regression/prototype/unit/dom_test.html]:
Failure: NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS
expected: &amp;lt;50&amp;gt;, actual: &amp;lt;0&amp;gt;
Failure: NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS
expected: &amp;lt;50&amp;gt;, actual: &amp;lt;0&amp;gt;

Finished in 18.127608 seconds.

356 tests, 2246 assertions, 2 failures, 0 errors
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That should look familiar to people using Ruby’s &lt;code&gt;Test::Unit&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I haven’t added a &lt;code&gt;Rake&lt;/code&gt; task helper yet, but the following should get you going for now.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
namespace :test do
  desc &quot;Run the JavaScript unit tests in public/test&quot;
  task :javascript do
    puts &quot;Running JavaScript tests:&quot;
    sh &quot;jstest #{Dir['public/test/*.html'].join(' ')}&quot;
  end
end

task :test do
  Rake::Task['test:javascript'].invoke
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the last task does not override the &lt;code&gt;test&lt;/code&gt; task that comes with Rails, rather Rake will append the block to the blocks of the existing &lt;code&gt;test&lt;/code&gt; task. So when the original task finishes your JS tests will be ran.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;I’m pretty happy with the current results. But as you can tell, from the output of running Prototype’s test suite, there’s still a problem, and I’m sure there are more like it.&lt;/p&gt;
&lt;p&gt;In this case the problem is that there’s &lt;em&gt;no&lt;/em&gt; actual window object (&lt;code&gt;NSWindow&lt;/code&gt;) associated with the &lt;code&gt;WebView&lt;/code&gt; instance, which is why the poor bugger can’t adjust its dimensions. &lt;em&gt;People shouldn’t be resizing the users windows anyways, so I don&amp;#8217;t worry about this problem too much ;-)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;As stated earlier, Headless Squirrel currently only works with Prototype’s unittest.js, because that’s the combination we are currently using at the office. However, it should be easy enough to add support for other test frameworks. Let me know if you do so.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Kicker kicks for kicks</title>
    <link href="/2009/04/12/kicker-kicks-for-kicks.html" />
    <id>tag:superalloy.nl,2009-04-12:1239550193</id>
    <updated>2009-04-12T17:29:53+02:00</updated>
    <content type="html">&lt;p&gt;A OS X command line tool which executes commands when a file, or a file in a directory, is modified.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/images/kikker.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Thanks to &lt;a href=&quot;http://manfred.github.com&quot;&gt;Manfred Stienstra&lt;/a&gt; for the project’s mascotte image. Kikker means “frog” in Dutch.&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Why?&lt;/h4&gt;
&lt;p&gt;Not so long ago I had to work on some text formatted as Textile. For this task I had to go back and forth to my text editor and terminal to edit and render the text as HTML. This started to get tedious pretty fast, so being the Ruby &lt;em&gt;and&lt;/em&gt; Cocoa head that I am, I quickly whipped up a simple, purpose agnostic, command-line tool which uses the FSEvents API (OS X) to watch for file changes.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I just love how easy it is to write &lt;a href=&quot;/2009/04/13/js-test-san.html&quot;&gt;small&amp;quot; tools with Ruby and Cocoa that do seemingly &amp;#8220;big&amp;#8221; things. For another example see &amp;quot;the next blog post&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Install&lt;/h3&gt;
&lt;p&gt;After some weeks of usage, and finally implementing the ability to watch multiple paths, I can now say it’s definitely usable. Get it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo gem install alloy-kicker -s http://gems.github.com&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now go kick some stuff!&lt;/p&gt;
&lt;p&gt;&lt;em&gt;If you want to checkout the source you can do so on &lt;a href=&quot;http://github.com/alloy/kicker/tree/master&quot;&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Example&lt;/h4&gt;
&lt;p&gt;Say you’d like to run a Ruby test case every time either the library file, or the test case file is saved. This can be accomplished with the following command:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ kicker -e &quot;ruby test/unit/article_test.rb&quot; **/article*.rb&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From now on whenever you save any file which matches the glob expression, the test case will be ran.&lt;/p&gt;
&lt;p&gt;There’s also support for Growl notifications and click callback handlers. See the &lt;a href=&quot;http://github.com/alloy/kicker/blob/master/README.rdoc&quot;&gt;README&lt;/a&gt; for more info.&lt;/p&gt;
&lt;p&gt;So know you know. Go wild!&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Guess Who’s Back</title>
    <link href="/2009/04/10/guess-who’s-back.html" />
    <id>tag:superalloy.nl,2009-04-10:1239384593</id>
    <updated>2009-04-10T19:29:53+02:00</updated>
    <content type="html">&lt;p&gt;I finally found some time to move some personal web applications to my &lt;a href=&quot;http://slicehost.com&quot;&gt;slicehost&lt;/a&gt; vps, which has only been running &lt;a href=&quot;http://pasternak.superalloy.nl&quot;&gt;pasternak&lt;/a&gt; up till now… What a waste of money.&lt;/p&gt;
&lt;p&gt;So here comes an end to that situation!&lt;/p&gt;
&lt;h3&gt;Return of the Mac and web developer&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Return_of_the_Mack&quot;&gt;&lt;img src=&quot;/images/ReturnoftheMackSingle.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I’m back online, so step 1 has been taken care of. Now comes step 2, the hard part, keeping it up-to-date. I think I&amp;#8217;ll be writing some shorter posts and I’d &lt;em&gt;like&lt;/em&gt; to say “more often”, but we’ll just have to see about that. Anyways…&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href=&quot;http://manfred.github.com/&quot;&gt;Manfred Stienstra&lt;/a&gt; who has so kindly offered me to use his styling to base mine on, because really it’s just not my thing. And &lt;a href=&quot;http://webby.rubyforge.org&quot;&gt;Webby&lt;/a&gt; so I can create posts locally, with my favorite text editor, and store revisions in &lt;a href=&quot;http://github.com/alloy/superalloy.nl&quot;&gt;git&lt;/a&gt;; welcome to superalloy.nl version 2 and hope to see you around!&lt;/p&gt;</content>
  </entry>
  
</feed>
