<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>XPlayer</title>
	<atom:link href="http://xplayer.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xplayer.wordpress.com</link>
	<description>my daily efforts to be a better developer, and keep improving every day</description>
	<lastBuildDate>Sat, 21 Jan 2012 23:45:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xplayer.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/3cfc994993561e3fe29b8d0033c0dace?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>XPlayer</title>
		<link>http://xplayer.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xplayer.wordpress.com/osd.xml" title="XPlayer" />
	<atom:link rel='hub' href='http://xplayer.wordpress.com/?pushpress=hub'/>
		<item>
		<title>A Rails project file for Sublime Text 2</title>
		<link>http://xplayer.wordpress.com/2012/01/22/a-rails-project-file-for-sublime-text-2/</link>
		<comments>http://xplayer.wordpress.com/2012/01/22/a-rails-project-file-for-sublime-text-2/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 23:39:03 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=185</guid>
		<description><![CDATA[The simplest thing that you can do to open up the Sublime Text 2 editor on your Rails project is to just type in $ subl . on the Rails root directory¹. A slightly better solution is to create a .sublime-project file &#8230; <a href="http://xplayer.wordpress.com/2012/01/22/a-rails-project-file-for-sublime-text-2/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=185&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The simplest thing that you can do to open up the <a href="http://www.sublimetext.com/" target="_blank">Sublime Text 2</a> editor on your Rails project is to just type in</p>
<pre>$ subl .</pre>
<p>on the Rails root directory¹.</p>
<p>A slightly better solution is to create a .sublime-project file in your project root directory, so that you may launch the editor with something like</p>
<pre>$ subl --project my_rails_project.sublime-project</pre>
<p>A question then arises, &#8220;How do I exclude useless directories as tmp or log from the project file?&#8221;</p>
<p>Answer: just edit the sublime-project file this way:</p>
<pre>{
 "folders":
 [
   {
     "path": ".",
     "folder_exclude_patterns": ["tmp", "log"],
     "file_exclude_patterns": [".tmtags"]
   }
 ]
}</pre>
<p>(and of course you should adapt it to your actual preferences on what to exclude from your project).</p>
<p>Note that you can also specify a <strong>&#8220;file_exclude_patterns&#8221;</strong> property to filter out some files (in my case I wanted to exclude the ctag index file).</p>
<ol>
<li>to install the command line tool, just follow the docs <a href="http://www.sublimetext.com/docs/2/osx_command_line.html">here</a>.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=185&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2012/01/22/a-rails-project-file-for-sublime-text-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>A review of &#8220;Great Bash&#8221; video by Carl Albing (O&#8217;Reilly Media)</title>
		<link>http://xplayer.wordpress.com/2011/08/27/a-review-of-great-bash-video-by-carl-albing-oreilly-media/</link>
		<comments>http://xplayer.wordpress.com/2011/08/27/a-review-of-great-bash-video-by-carl-albing-oreilly-media/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 23:21:41 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Shell Programming]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=176</guid>
		<description><![CDATA[Shell programming is a topic that every professional programmer should care about, and keep improving on, for several reasons. Here are the first two I can think about: Because is essential in order to promote the automation of many manual &#8230; <a href="http://xplayer.wordpress.com/2011/08/27/a-review-of-great-bash-video-by-carl-albing-oreilly-media/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=176&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Shell programming is a topic that every professional programmer should care about, and keep improving on, for several reasons.<br />
Here are the first two I can think about:</p>
<ol>
<li>Because is essential in order to promote the automation of many manual processes (and automation is damn important!).</li>
<li>Because I like to be a programmer as much as a <a title="what is a devop?" href="http://en.wikipedia.org/wiki/DevOps" target="_blank">devop</a>, and I want to be able to deploy what I develop, and take care of all the operational and system stuff related to the system I contribute to build.</li>
</ol>
<p>Me myself made the mistake of underestimate the relevance of this topic for way too time in the past: don&#8217;t make my same mistake :-)</p>
<p><a title="Carl Albing's &quot;Great Bash&quot; by O'Reilly Media" href="http://oreilly.com/catalog/0636920013334" target="_blank">Carl Albing&#8217;s &#8220;Great Bash&#8221; by O&#8217;Reilly Media</a> is a collection of several short video lessons on the basics of the shell programming.</p>
<p>I watch the &#8220;Great Bash&#8221; lessons hoping to learn more about shell programming, but unfortunately Carl Albing&#8217;s video lessons are too introductory (IMHO).</p>
<p>It was nevertheless great to recap many things I learned here and there, and so my time watching it was not wasted at all, but I would recommend this video only to shell programmer beginners.</p>
<p>There are also some (really) minor defects in the technical way the video is recorded: the audio quality may be improved and sometimes the speaker take some long inexplicable pauses. But, that said, the overall quality is really good.</p>
<p>In the end I recommend to watch this video if you are a shell programmer beginner and you want to start understanding more about this topic.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=176&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2011/08/27/a-review-of-great-bash-video-by-carl-albing-oreilly-media/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamically add data accessor methods on &#8220;static&#8221; Rails data model</title>
		<link>http://xplayer.wordpress.com/2011/03/12/dinamically-add-data-accessor-methods-on-static-rails-data-model/</link>
		<comments>http://xplayer.wordpress.com/2011/03/12/dinamically-add-data-accessor-methods-on-static-rails-data-model/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 17:41:07 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=154</guid>
		<description><![CDATA[How metaprogramming may help you in dinamically add helper access methods to Rails models <a href="http://xplayer.wordpress.com/2011/03/12/dinamically-add-data-accessor-methods-on-static-rails-data-model/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=154&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An useful metaprogramming spell I recently played with is the <code>Module#define_method()</code>, which dynamically adds an instance method to the class on which is called.</p>
<p>&nbsp;</p>
<p>I found it particularly useful to add data accessor methods on &#8220;static&#8221; Rails data model: suppose I&#8217;m working an e-commerce Rails webapp, and I have a <code>Country</code> model which maps the countries suitable for shipping, or a <code>PaymentType</code> model which represents all the possible payment types.</p>
<p>For these kind of models (and tables), which are typically static (they don&#8217;t change often), you often have to access specific values, say <code>Country.italy</code> or <code>PaymentType.credit_card</code>.</p>
<p>In these cases, defining dynamically an accessor method may be useful and more clear than always perform a <code>find_by_name("my value")</code>.</p>
<p>So, for example, I open up my country.rb model class and add these lines</p>
<pre>  class &lt;&lt; self
    Country.all.each do |each_country|
      define_method(each_country.name.downcase.gsub('.', '').gsub(' ', '_')) do
        Country.find_by_iso_code(each_country.iso_code)
      end
    end
  end</pre>
<p>And then opening the Rails console I will be able to type</p>
<pre>1.8.7@epistore &gt; Country.sri_lanka
# {
                :id =&gt; 59,
              :zone =&gt; "U9",
           :enabled =&gt; true,
        :created_at =&gt; Tue, 20 Apr 2010 17:01:45 CEST +02:00,
        :updated_at =&gt; Tue, 20 Apr 2010 17:01:45 CEST +02:00,
          :iso_code =&gt; "LK",
    :country_set_id =&gt; nil
}</pre>
<p>Just a note: as I said, <code>Module#define_method()</code> will add an <strong>instance method on the class</strong>. To add a <strong>class method</strong>, which is what I want, we have to use a different approach, using the <code>class &lt;&lt; self</code> syntax to add a singleton method in the receiver.</p>
<p>I may also add a query method on each <code>Country</code> instance to check that country against another country (for example, I may ask <code>my_country.italy?</code>)</p>
<pre>  Country.all.each do |each_country|
    define_method(each_country.name.downcase.gsub('.', '').gsub(' ', '_').concat('?')) do
      has_iso_code? each_country.iso_code
    end
  end</pre>
<p>And then, after issuing a <code>reload!</code> command in the Rails console, I may type:</p>
<pre>1.8.7@epistore &gt; Country.usa.usa?
true
1.8.7@epistore &gt; Country.usa.italy?
false
1.8.7@epistore &gt; Country.usa.south_korea?
false
1.8.7@epistore &gt; Country.south_korea.south_korea?
true</pre>
<p>Depending on the kind of Rails app you have, these may be a useful tip.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=154&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2011/03/12/dinamically-add-data-accessor-methods-on-static-rails-data-model/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>assert_select_rjs reloaded!</title>
		<link>http://xplayer.wordpress.com/2010/09/16/assert_select_rjs-reloaded/</link>
		<comments>http://xplayer.wordpress.com/2010/09/16/assert_select_rjs-reloaded/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 21:50:53 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=146</guid>
		<description><![CDATA[If you hava a Rails webapp with jQuery, then assert_select_rjs may really help you unit-testing all the AJAX-based logic. <a href="http://xplayer.wordpress.com/2010/09/16/assert_select_rjs-reloaded/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=146&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">If you ever dared to unit-test a Rails RJS action, for example something like this:</div>
<blockquote>
<pre>def my_ajax_action
   ...
   render(:update) do |page|
     page.replace_html 'shoppinglist', :partial =&gt; 'cart'
     page.replace_html 'items', :partial =&gt; 'layouts/items', :locals =&gt; { :cart =&gt; @cart }
   end
end</pre>
</blockquote>
<div id="_mcePaste">you may already know and use the <a href="http://rubydoc.info/docs/rails/2.3.8/ActionController/Assertions/SelectorAssertions:assert_select_rjs">assert_select_rjs</a> testing helper, which basically will verify the structure of your RJS response.</div>
<p>This testing method may really help you shortening the TDD feedback loop in an AJAX-based Rails webapp, and then you&#8217;ll may even be confident enough and save one or two brittle Selenium tests.</p>
<div>The only problem with <a href="http://rubydoc.info/docs/rails/2.3.8/ActionController/Assertions/SelectorAssertions:assert_select_rjs">assert_select_rjs</a> is that is (IMHO) poorly documented and rarely googled about.</div>
<div id="_mcePaste">So, this is my turn to give back what we discovered.</div>
<p>If you have a Rails webapp using jQuery as javascript framework, you may have a hard time using <a href="http://rubydoc.info/docs/rails/2.3.8/ActionController/Assertions/SelectorAssertions:assert_select_rjs">assert_select_rjs</a> correctly, and this is why:</p>
<div id="_mcePaste">for jQuery, this is the correct way to use <a href="http://rubydoc.info/docs/rails/2.3.8/ActionController/Assertions/SelectorAssertions:assert_select_rjs">assert_select_rjs</a>:</div>
<blockquote>
<pre>assert_select_rjs :replace_html, '#shoppinglist'</pre>
</blockquote>
<div>it&#8217;s important the &#8216;#&#8217; prefix here to refer to DOM element IDs, since the notation without &#8216;#&#8217; will work only if your app uses Prototype.</div>
<div id="_mcePaste">Another nice thing to know is the way to make assertion on the selection matched by the <a href="http://rubydoc.info/docs/rails/2.3.8/ActionController/Assertions/SelectorAssertions:assert_select_rjs">assert_select_rjs</a>.</div>
<div id="_mcePaste">For example, this code</div>
<blockquote>
<pre>assert_select_rjs :replace_html, '#shoppinglist' do
    assert_select '#shipping_cost_description', /Shipping costs for France/
    assert_select '#shipping_cost_value', /&amp;euro; 12,30/
end</pre>
</blockquote>
<div>will verify that the section replaced inside the &#8216;shoppinglist&#8217; element will match the two followings assetions.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=146&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2010/09/16/assert_select_rjs-reloaded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>My first test using webdriver (aka Selenium 2.0)!</title>
		<link>http://xplayer.wordpress.com/2010/02/19/my-first-test-using-webdriver-aka-selenium-2-0/</link>
		<comments>http://xplayer.wordpress.com/2010/02/19/my-first-test-using-webdriver-aka-selenium-2-0/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 23:24:17 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=143</guid>
		<description><![CDATA[As many say, a good solution to selenese flu is Webdriver (see more at http://code.google.com/p/selenium). Webdriver has been accepted by the Selenium guys as the new approach to web application testing, opposed to the classical &#8220;selenium 1.0&#8243; approach, based on &#8230; <a href="http://xplayer.wordpress.com/2010/02/19/my-first-test-using-webdriver-aka-selenium-2-0/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=143&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<div>
<p><a rel="nofollow" href="http://www.the-arm.com/2010/02/suffering-of-selenese-flu-try-webdriver/">As many say</a>, a good solution to <em>selenese flu</em> is <strong>Webdriver</strong> (see more at <a rel="nofollow" href="http://code.google.com/p/selenium">http://code.google.com/p/selenium</a>).</p>
<p>Webdriver has been accepted by the Selenium guys as the new approach  to web application testing, opposed to the classical &#8220;selenium 1.0&#8243;  approach, based on a javascript driver, which suffers from way too many  issues.<br />
Unfortunately, Selenium 2.0, which plan to fully support Webdriver, is  still on an alpha release, and actually is very difficult to find  ruby-based web testing tools supporting this alpha version of selenium  2.0.<br />
One of those tools is actually Watir (though Webrat too is planning to  support Selenium 2.0 sooner or later), and more precisely <a rel="nofollow" href="http://github.com/jarib/watir-webdriver">this  project</a> is quite stable to allow a first test drive.</p>
<p>So this is what I did:</p>
<p>First: installed required gems</p>
<div>
<div>
<pre>  sudo gem install selenium-webdriver
  sudo gem install watir-webdriver --pre
</pre>
</div>
</div>
<p>Second: configure my Rails testing configuration to use watir</p>
<div>
<div><strong>config/environments/test.rb</strong></div>
<div>
<pre>  ...
  config.gem "watir-webdriver"
  ...
</pre>
</div>
</div>
<div>
<div><strong>test/test_helper.rb</strong></div>
<div>
<pre>  require 'test_help'
  ...
  require 'watir-webdriver'
  ...
</pre>
</div>
</div>
<p>Third: write a test</p>
<div>
<div><strong>test/integration/paypal_integration_test.rb</strong></div>
<div>
<pre>require 'test_helper'

class PaypalIntegrationTest &lt; ActionController::IntegrationTest
  include LocaleHelper
  self.use_transactional_fixtures = false

  def setup
    ... some setup stuff here ...
    @browser = Watir::Browser.new(:firefox)
  end

  def teardown
    @browser.close
  end

  test "something interesting" do
    @browser.goto "https://developer.paypal.com/"
    @browser.text_field(:name, "login_email").set "my_test_account@sourcesense.com"
    @browser.text_field(:name, "login_password").set "mysecret"
    @browser.button(:name, "submit").click

    @browser.goto "https://localhost"

    @browser.link(:id, 'loginlink').click
    @browser.text_field(:name, "email").set @user.email
    @browser.text_field(:name, "password").set @user.password
    @browser.button(:text, "Login").click

    # add_a_product_to_cart
    product = Factory(:product, :code =&gt; "a code", :categories =&gt; [@juve_store])
    Factory(:product_variant, :code =&gt; "03", :availability =&gt; 99, :product =&gt; product)
    @browser.goto "https://localhost/frontend/products/show/#{product.id}"
    @browser.button(:id, "add_to_cart").click

    @browser.link(:text, "Checkout").click
    @browser.link(:id, "gotobuy").click

    # choose "Paypal"
    @browser.radios.last.set

    @browser.link(:id, "gotobuy").click

    sleep 5
    assert @browser.text.include?("Payment for order #{last_order_number()}")

    @browser.text_field(:name, "login_email").set "my_test_buyer@sourcesense.com"
    @browser.text_field(:name, "login_password").set "yetanothersecrethere"
    @browser.button(:text, "Accedi").click
    @browser.button(:text, "Paga ora").click

    sleep 5
    assert @browser.text.include?("Il pagamento è stato inviato")

    @browser.button(:id, "merchantReturn").click
    assert_contain_waiting("Your purchase")
    assert_contain_waiting(last_order_number())

  end

private

  def last_order_number
    Order.last ? Order.last.number : ""
  end

end
</pre>
</div>
</div>
<p>Some comments here:</p>
<ul>
<li>This is a spike, so please don&#8217;t say this test is too long and not  well refactored <img src="https://dev.sourcesense.com/confluence/images/icons/emoticons/smile.gif" border="0" alt="" width="20" height="20" align="absmiddle" /></li>
<li>I had to put two sleep calls in two places (I gotta say that this  specific test, involving paypal sandbox, is really slow due to the  slowness in the paypal response time).</li>
<li>Anyway, this alpha version of webdriver is still lacking: I cannot  say wheather this is a problem I&#8217;ll have even with future (possibly more  stable) version of Webdriver.</li>
</ul>
<p>Some references:</p>
<ul>
<li><a rel="nofollow" href="http://zeljkofilipin.com/2010/01/12/watir-on-webdriver/">http://zeljkofilipin.com/2010/01/12/watir-on-webdriver/</a></li>
<li><a rel="nofollow" href="http://developer-in-test.blogspot.com/2010/01/chromewatir-watir-webdriver-update.html">http://developer-in-test.blogspot.com/2010/01/chromewatir-watir-webdriver-update.html</a></li>
<li><a rel="nofollow" href="http://jarib.github.com/watir-webdriver/doc/index.html">http://jarib.github.com/watir-webdriver/doc/index.html</a></li>
</ul>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/143/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=143&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2010/02/19/my-first-test-using-webdriver-aka-selenium-2-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>

		<media:content url="https://dev.sourcesense.com/confluence/images/icons/emoticons/smile.gif" medium="image" />
	</item>
		<item>
		<title>A (still brief) experience on using Selenium to test a Rails + ajax app</title>
		<link>http://xplayer.wordpress.com/2010/02/08/a-still-brief-experience-on-using-selenium-to-test-a-rails-ajax-app/</link>
		<comments>http://xplayer.wordpress.com/2010/02/08/a-still-brief-experience-on-using-selenium-to-test-a-rails-ajax-app/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 21:50:43 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Testability]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=139</guid>
		<description><![CDATA[This is a note to make a point on our (mine and my team&#8217;s) current use of Selenium to test the ajax behaviour in the Rails webapp we&#8217;re currently developing. Ajax replacing of part of the page is growing, and &#8230; <a href="http://xplayer.wordpress.com/2010/02/08/a-still-brief-experience-on-using-selenium-to-test-a-rails-ajax-app/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=139&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<div>
<p>This is a note to make a point on our (mine and my team&#8217;s) current use of Selenium  to test the ajax behaviour in the Rails webapp we&#8217;re currently developing. Ajax replacing of part of the page is growing, and with it we have  to face the classical question: <em>&#8220;how do we test (I mean  automatically :-) the  ajax/javascript behaviours in our webapp?&#8221;</em>.</p>
<p>This is how we are trying to manage this issue now, after some days  of spiking on Selenium, Watir and BlueRidge (I hope to write more on Watir and BlueRidge in some future post, because these two tools are worth speaking).</p>
<p>Actually we are giving a try to the combination of Webrat + Selenium,  since we already have a big test suite of integration test using Webrat,  and have a good knowledge of the Webrat API.</p>
<p>We added the selenium-client gem to be able to drive Selenium through  the Webrat API.<br />
This is extracted from our test environment configuration file:</p>
<div>
<div><strong>test.rb</strong></div>
<div>
<pre>...
config.gem 'selenium-client', :lib =&gt; 'selenium/client'
config.gem "webrat", :version =&gt; '&gt;= 0.6.0'
...</pre>
</div>
</div>
<p>Then, we defined a class from which all the selenium test cases will  inherit.<br />
This class basically is used to</p>
<ul>
<li>disable the transactional fixtures in Rails, to allow the browser  process where Selenium runs to access the data prepared in the tests</li>
<li>configure Webrat with the &#8220;selenium&#8221; mode</li>
<li>be the place to collect helper methods as &#8220;login&#8221; or &#8220;logout&#8221;, used  in many tests.</li>
</ul>
<div>
<div><strong>selenium_integration_test.rb</strong></div>
<div>
<pre>class SeleniumIntegrationTest &lt; ActionController::IntegrationTest
  self.use_transactional_fixtures = false

  setup :switch_webrat_to_selenium
  def switch_webrat_to_selenium
    Webrat.configure do |config|
      config.mode = :selenium
      config.application_environment = :test
    end

    selenium.set_speed(100)       # default is 0 ms
    selenium.set_timeout(10000)   # default is 30000 ms
  end

  teardown :delete_cookies
  def delete_cookies
    selenium.delete_all_visible_cookies
  end

protected
 ...
 [other helper methods here, like login, logout, and so on...]

 ...</pre>
</div>
</div>
<p>We also added a rake task to be able to launch all the selenium tests</p>
<div>
<div><strong>test.rake</strong></div>
<div>
<pre>namespace :test do
  ...
  ...

  desc "Run Selenium Test"
  Rake::TestTask.new(:selenium) do |t|
    t.libs &lt;&lt; "test"
    t.test_files = FileList['test/selenium/*test.rb']
    t.verbose = true
  end
end</pre>
</div>
</div>
<p>One thing we learned through several repeated mistakes is that the  Webrat API is different when called in the &#8220;selenium&#8221; mode then the one  we were used to when using Webrat in the classical &#8220;rails&#8221; mode.<br />
For example, the &#8220;assert_have_selector&#8221; method for selenium only takes  one argument, that is the CSS selector, while in the classical webrat  mode, the same method takes another parameter to specify the expected  content to match with (see this rdoc: <a rel="nofollow" href="http://gitrdoc.com/brynary/webrat/tree/master">http://gitrdoc.com/brynary/webrat/tree/master</a>).  So we had to define helper methods based on &#8220;assert_have_xpath&#8221; method  using xpath to express the same intent of a method like  assert_have_selector(css_selector, expected_content)</p>
<p>Here is our helper method</p>
<div>
<div><strong>selenium_integration_test.rb</strong></div>
<div>
<pre>  ...
  def assert_has_id id, text_content
    assert_have_xpath "//*[@id='#{id}'][1][text()='#{text_content}']"
  end
  ...</pre>
</div>
</div>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=139&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2010/02/08/a-still-brief-experience-on-using-selenium-to-test-a-rails-ajax-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing SeleniumRC to work with Firefox 3.6</title>
		<link>http://xplayer.wordpress.com/2010/02/04/fixing-seleniumrc-to-work-with-firefox-3-6/</link>
		<comments>http://xplayer.wordpress.com/2010/02/04/fixing-seleniumrc-to-work-with-firefox-3-6/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 23:27:36 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Selenium]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=132</guid>
		<description><![CDATA[The brand new release of Firefox 3.6 brings, together with some improvements in the browser, also some headaches for all selenium users: actually the latest selenium RC jar (selenium-server.jar) won&#8217;t work with Firefox 3.6. The problem is related to the &#8230; <a href="http://xplayer.wordpress.com/2010/02/04/fixing-seleniumrc-to-work-with-firefox-3-6/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=132&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The brand new release of Firefox 3.6 brings, together with some improvements in the browser, also some headaches for all selenium users: actually the latest selenium RC jar (selenium-server.jar) won&#8217;t work with Firefox 3.6.</p>
<p>The problem is related to the addons that Selenium will pretend to have in the Firefox instance fired up when Selenium RC server starts. As a matter of fact, those two addons are not declared to be compatible with 3.6.</p>
<p>The simple fix is then to edit the addons&#8217; install.rdf files in the selenium-server.jar to manually set the compatibility to 3.6.</p>
<p>Alternatively, you can download <a href="http://github.com/saucelabs/saucelenium/blob/master/selenium-sauce.jar">this patched jar</a> from <a href="http://github.com/saucelabs/saucelenium/">this</a> repository, rename it to selenium-server.jar and replace the previous jar with this.</p>
<p>The actual steps to fix my webrat gem (I use Selenium through Webrat) were</p>
<ol>
<li>download the above mentioned file (http://github.com/saucelabs/saucelenium/blob/master/selenium-sauce.jar)</li>
<li>rename it to selenium-server.jar</li>
<li>replace the previous file in the vendor folder of your webrat gem (mine was /usr/local/lib/ruby/gems/1.8/gems/webrat-0.7.0/vendor/selenium-server.jar)</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=132&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2010/02/04/fixing-seleniumrc-to-work-with-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>One (and a half) useful thing to know when using DeepTest gem with MySQL</title>
		<link>http://xplayer.wordpress.com/2010/01/18/one-and-a-half-useful-thing-to-know-when-using-deeptest-gem-with-mysql/</link>
		<comments>http://xplayer.wordpress.com/2010/01/18/one-and-a-half-useful-thing-to-know-when-using-deeptest-gem-with-mysql/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 23:22:52 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=127</guid>
		<description><![CDATA[DeepTest currently won&#8217;t work if you&#8217;ve configured MySQL with no password (in other words, if you are able to connect to mysql with a simple &#8220;mysql -u root&#8221;). To fix this, you have to patch DeepTest (I know, asap I&#8217;ll &#8230; <a href="http://xplayer.wordpress.com/2010/01/18/one-and-a-half-useful-thing-to-know-when-using-deeptest-gem-with-mysql/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=127&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/qxjit/deep-test">DeepTest</a> currently won&#8217;t work if you&#8217;ve configured MySQL with no password (in other words, if you are able to connect to mysql with a simple &#8220;mysql -u root&#8221;).<br />
To fix this, you have to patch DeepTest (I know, asap I&#8217;ll go through the whole process to propose the patch to the original project leader).<br />
Actually, you have to comment out a line, in the <em>DeepTest:Database:MysqlSetupListener#grant_privileges </em>method:</p>
<pre style="background:#f1f0f0 none repeat scroll 0 0;color:#000000;padding-left:30px;"><span style="color:#806030;">.</span><span style="color:#806030;">.</span><span style="color:#806030;">.</span>
<span style="color:#400000;font-weight:bold;">def</span> grant_privileges<span style="color:#806030;">(</span>connection<span style="color:#806030;">)</span>
sql <span style="color:#806030;">=</span> %<span style="color:#806030;">{</span>grant all on <span style="color:#c34e00;">#{worker_database}.*</span>
to %s@<span style="color:#e60000;">'localhost'</span>;<span style="color:#806030;">}</span> % <span style="color:#806030;">[</span>
connection<span style="color:#806030;">.</span>quote<span style="color:#806030;">(</span>worker_database_config<span style="color:#806030;">[</span>:username<span style="color:#806030;">]</span><span style="color:#806030;">)</span><span style="color:#c34e00;"># ,</span>
<span style="color:#c34e00;"># connection.quote(worker_database_config[:password])  &lt;-- mysql with no password won't work</span>
<span style="color:#806030;">]</span>
connection<span style="color:#806030;">.</span>execute sql
<span style="color:#400000;font-weight:bold;">end</span>
<span style="color:#806030;">.</span><span style="color:#806030;">.</span><span style="color:#806030;">.</span>
</pre>
<p>Another tip (the &#8220;half&#8221; in the blog post title):<br />
Don&#8217;t forget to edit the &#8220;pattern&#8221; option in your DeepTest rake task, to be able to grab all the testcases you want.<br />
In my case, I want to skip a whole folder containing selenium tests, so I have to write my Deep Test rake file this way:<br />
(in <em>/lib/tasks/test.rake</em>)</p>
<pre style="background:#f1f0f0 none repeat scroll 0 0;color:#000000;padding-left:30px;"><span style="color:#800000;font-weight:bold;">require</span> <span style="color:#e60000;">"deep_test/rake_tasks"</span>
<span style="color:#806030;">.</span><span style="color:#806030;">.</span><span style="color:#806030;">.</span>

DeepTest::TestTask<span style="color:#806030;">.</span><span style="color:#400000;font-weight:bold;">new</span> <span style="color:#e60000;">"deep"</span> <span style="color:#400000;font-weight:bold;">do</span> |t|
t<span style="color:#806030;">.</span>number_of_workers <span style="color:#806030;">=</span> <span style="color:#c00000;">2</span>
t<span style="color:#806030;">.</span>pattern <span style="color:#806030;">=</span> <span style="color:#e60000;">"test/{unit,functional,integration}/**/*_test.rb"</span>
t<span style="color:#806030;">.</span>libs &lt;&lt; <span style="color:#e60000;">"test"</span>
t<span style="color:#806030;">.</span>worker_listener <span style="color:#806030;">=</span> <span style="color:#e60000;">"DeepTest::Database::MysqlSetupListener"</span>
<span style="color:#400000;font-weight:bold;">end</span>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=127&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2010/01/18/one-and-a-half-useful-thing-to-know-when-using-deeptest-gem-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>ThinkCode.TV goes live!</title>
		<link>http://xplayer.wordpress.com/2009/11/10/thinkcode-tv-goes-live/</link>
		<comments>http://xplayer.wordpress.com/2009/11/10/thinkcode-tv-goes-live/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 22:18:40 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=122</guid>
		<description><![CDATA[ThinkCode.TV, a website specializes in the delivery of high quality commercial screencasts about software development, at a really cheap prices, goes live! <a href="http://xplayer.wordpress.com/2009/11/10/thinkcode-tv-goes-live/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=122&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An advertisement for my friend and mentor Piergiuliano Bossi: his long-waited <a href="http://it.thinkcode.tv/">ThinkCode.TV</a> goes live!</p>
<p><strong>ThinkCode.TV </strong>is a website specializes in the delivery of high quality commercial screencasts about software development, at a really cheap prices.</p>
<p>The first 5 videos are now online (the actual language is italian, but english content is planned for the following months):</p>
<ul>
<li>The first two lessions on <strong>Python</strong>, by Marco Beri</li>
<li>A screencast on <strong>MacRuby</strong>, by Renzo Borgatti</li>
<li>The first two lessions on <strong>TDD</strong>, by Piergiuliano Bossi.</li>
</ul>
<p>Selling all these high-quality screencasts at about <strong>5 euro each </strong>makes them *really* appetible.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=122&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2009/11/10/thinkcode-tv-goes-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
		<item>
		<title>Think different about mock objects!</title>
		<link>http://xplayer.wordpress.com/2009/11/04/think-different-about-mock-objects/</link>
		<comments>http://xplayer.wordpress.com/2009/11/04/think-different-about-mock-objects/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 23:02:57 +0000</pubDate>
		<dc:creator>stoner</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Mock Objects]]></category>

		<guid isPermaLink="false">http://xplayer.wordpress.com/?p=106</guid>
		<description><![CDATA[Another (different) point of view on mock object, too much times used merely as a testing tool. They are more then that, and knowing how to use it in a better way may improve your code too! <a href="http://xplayer.wordpress.com/2009/11/04/think-different-about-mock-objects/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=106&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>Recently, after the post on mock objects by Uncle Bob (<a href="http://blog.objectmentor.com/articles/2009/10/28/manual-mocking-resisting-the-invasion-of-dots-and-parentheses" target="_blank">&#8220;Manual Mocking: Resisting the Invasion of Dots and Parentheses&#8221;</a>), a rather long discussion thread grown in the extreme programming italian newsgroup (starting <a href="http://it.groups.yahoo.com/group/extremeprogramming-it/message/7224" target="_blank">here</a>, but careful, it&#8217;s in italian, sorry!).</div>
<div>This led me to think more deeply about my experience with mock objects, and I&#8217;d like to share my point of view here, as it&#8217;s quite different (or so it seems to me) from the common opinions on this important topic.</div>
<p><div>I&#8217;ve always followed the so-called (as Giuliano would say, isn&#8217;t it <a href="http://thinkingbox.wordpress.com/" target="_blank">Giuliano</a>? :-) &#8220;English School&#8221; of mock objects, the one coming from the pioneering works of <a href="http://www.planningcards.com/iterex/blog.html" target="_blank">Tim Mackinnon</a>,<a href="http://www.m3p.co.uk/blog/" target="_blank"> Steve Freeman</a> and <a href="http://www.natpryce.com/" target="_blank">Nat Pryce</a>, the real fathers of mock objects.</div>
<p><div>And I&#8217;ve always carefully followed their advice, first through their *epic* paper  <strong>&#8220;Mock Roles, not Objects&#8221;</strong> (<a href="http://www.jmock.org/oopsla2004.pdf" target="_blank">http://www.jmock.org/oopsla2004.pdf</a>) &#8211; IMHO the best paper on mock objects and on object oriented programming with mocks &#8211; then through their terrific posts on the blog <a href="http://www.mockobjects.com/" target="_blank">www.mockobjects.com</a>, and finally, through their first (and brand new) book, <a href="http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627" target="_blank">&#8220;Growing Object-Oriented Software, Guided by Tests&#8221;</a>.</div>
<p><div>One thing I learn is that <strong>mock objects are a design tool</strong>, while many people see it only as a technique for speeding up unit tests.</div>
<div>And in this context mock objects are a key tool to support your TDD process, especially in test-driving your domain model, where you follow a process similar to traditional top-down development, in which you start from the highest level of abstraction and then proceed, layer by layer, to reach the core of the domain and then move again towards the boundary of the system, towards the &#8220;services&#8221; (you can find many similarities in <a href="http://alistair.cockburn.us/Hexagonal+architecture" target="_blank">Cockburn&#8217;s approach to Hexagonal Architecture</a>).</div>
<p><div>Then, when you reach the domain boundary, you should stop using mocks.</div>
<div>Mock objects are useful to TDDing the thin adapter layers to your services (that is, third-party libraries or external components (e.g. a database, a JMS queue, &#8230;). But then, the actual adapters will be tested with integration testing.</div>
<p><div>Why?</div>
<p style="padding-left:30px;">Because you should use mock objects as far as you can apply TDD, whereas you can design and *discover* interfaces (and roles), and assign responsibility. On the other hand, in front of a third-party library you cannot follow this process, since the code is not under your control, and you cannot modify it.</p>
<p><div style="padding-left:30px;">Because if you use mock objects with third-party libraries (two concrete examples taken from our recent projects: isolating our tests from the database in a Rails app, or in a java app using Hibernate ORM), you&#8217;ll write tests that *guess* the library behaviour, and your guesses may be far away from the actual behaviour.</div>
<div style="padding-left:30px;">Raise your hands if you never burnt your fingers with this kind of test with mocks, where maybe you *thought* you had a save() method to return an A object while in fact it returned B object! :)</div>
<p><div style="padding-left:30px;">And finally, because this kind of tests with mocks end up to be long, unreadable and fragile (an &#8220;invasion of dots and parentheses&#8221; reported by Uncle Bob in his post), full of mocks and mock expectations. And, hey, you cannot refactor them, since you don&#8217;t own the third-party code!</div>
<p><BR><br />
To verify the correct integration with libraries or external components, which are out of you domain, as well as with integration tests, you may use <a href="http://xunitpatterns.com/Fake%20Object.html" target="_blank">fake</a>s or <a href="http://xunitpatterns.com/Test%20Stub.html" target="_blank">stub</a>s (and, by the way, the example in the Uncle Bob&#8217;s post is actually a stub, not a &#8220;hand-rolled mock&#8221;).</p>
<p><div>So, I&#8217;ll repeat myself, following this &#8220;mocks as a design tool&#8221; approach, you&#8217;ll <a href="http://www.mockobjects.com/2007/04/test-smell-everything-is-mocked.html" target="_blank">mock only types you own</a>.</div>
<p><div>Some useful references to study this topic in depth (you&#8217;ll be OK even if you read just the first 2-3 links :-)</div>
<div>
<ul>
<li><a href="http://www.jmock.org/oopsla2004.pdf" target="_blank">http://www.jmock.org/oopsla2004.pdf</a> (I&#8217;m quoting again this paper, because it&#8217;s a *really* good starting point to understand this approch to mock objects)</li>
<li><a href="http://www.mockobjects.com/2007/04/test-smell-everything-is-mocked.html" target="_blank">http://www.mockobjects.com/2007/04/test-smell-everything-is-mocked.html</a> (if you like to deepen the &#8220;Don&#8217;t mock third-party libraries&#8221; and &#8220;Don&#8217;t mock value objects&#8221; topics)</li>
<li><a href="http://www.mockobjects.com/2006/10/tell-dont-ask-and-mock-objects.html" target="_blank">http://www.mockobjects.com/2006/10/tell-dont-ask-and-mock-objects.html</a></li>
<li><a href="http://www.mockobjects.com/2006/10/jmock-listening-to-opinionated.html" target="_blank">http://www.mockobjects.com/2006/10/jmock-listening-to-opinionated.html</a></li>
<li><a href="http://www.mockobjects.com/2006/09/like-fire-drill.html" target="_blank">http://www.mockobjects.com/2006/09/like-fire-drill.html</a></li>
<li><a href="http://www.mockobjects.com/2007/04/test-smell-bloated-constructor.html" target="_blank">http://www.mockobjects.com/2007/04/test-smell-bloated-constructor.html</a></li>
<li><a href="http://www.mockobjects.com/2007/04/test-smell-i-need-to-mock-object-i-cant.html" target="_blank">http://www.mockobjects.com/2007/04/test-smell-i-need-to-mock-object-i-cant.html</a></li>
<li><a href="http://www.mockobjects.com/files/evolving_an_edsl.ooplsa2006.pdf" target="_blank">http://www.mockobjects.com/files/evolving_an_edsl.ooplsa2006.pdf</a> (yet another paper, very good)</li>
<li> and if you want to know more about the history of mock objects: <a href="http://www.mockobjects.com/2009/09/brief-history-of-mock-objects.html" target="_blank">http://www.mockobjects.com/2009/09/brief-history-of-mock-objects.html</a></li>
</ul>
<p>I hope I give you some useful feedback on this topic!</p>
</div>
<div>And, by the way, feedbacks are warmly welcome!</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xplayer.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xplayer.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xplayer.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xplayer.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xplayer.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xplayer.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xplayer.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xplayer.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xplayer.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xplayer.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xplayer.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xplayer.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xplayer.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xplayer.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xplayer.wordpress.com&amp;blog=532244&amp;post=106&amp;subd=xplayer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xplayer.wordpress.com/2009/11/04/think-different-about-mock-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d4e7e22b936262bcf5c87b43f4f370c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stoner</media:title>
		</media:content>
	</item>
	</channel>
</rss>
