<?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/"
	>

<channel>
	<title>andy goundry &#187; programming</title>
	<atom:link href="http://www.andygoundry.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andygoundry.com</link>
	<description>web developer</description>
	<lastBuildDate>Wed, 01 Feb 2012 16:01:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ensuring that Heroku does not install gems within the Bundler :development group</title>
		<link>http://www.andygoundry.com/2012/01/07/ensuring-that-heroku-does-not-install-gems-within-the-bundler-development-group/</link>
		<comments>http://www.andygoundry.com/2012/01/07/ensuring-that-heroku-does-not-install-gems-within-the-bundler-development-group/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 00:38:06 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=634</guid>
		<description><![CDATA[Tonight, i ran into an issue with Heroku, where is was failing when installing a gem that i have within my :development bundler group:
group :development, :test, :cucumber do
gem &#8216;ruby-debug19&#8242;
end
As the clear solution was to prevent heroku installing gems that it didn&#8217;t need, i found this handy heroku command:
heroku config:add BUNDLE_WITHOUT=&#8221;development:test:cucumber&#8221;
Running this has told heroku to [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight, i ran into an issue with Heroku, where is was failing when installing a gem that i have within my :development bundler group:</p>
<blockquote><p>group :development, :test, :cucumber do</p>
<p>gem &#8216;ruby-debug19&#8242;</p>
<p>end</p></blockquote>
<p>As the clear solution was to prevent heroku installing gems that it didn&#8217;t need, i found this handy heroku command:</p>
<blockquote><p>heroku config:add BUNDLE_WITHOUT=&#8221;development:test:cucumber&#8221;</p></blockquote>
<p>Running this has told heroku to ignore gems that it doesn&#8217;t need, meaning the deploy worked fine. Further details: http://devcenter.heroku.com/articles/bundler</p>
<p>This resolves the heroku error:</p>
<blockquote><p>Installing linecache19 (0.5.12) with native extensions /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions&#8217;: ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/01/07/ensuring-that-heroku-does-not-install-gems-within-the-bundler-development-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Paperclip generated expiring S3 urls with RSpec, Cucumber and Timecop</title>
		<link>http://www.andygoundry.com/2011/12/21/using-cucumber-to-test-s3-expiring-urls/</link>
		<comments>http://www.andygoundry.com/2011/12/21/using-cucumber-to-test-s3-expiring-urls/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 07:07:15 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=529</guid>
		<description><![CDATA[The need
I have a Rails app that is using Paperclip to generate expiring urls for files stored in S3. The urls are set to expire after 1 minute. As much as i trust Paperclip and Amazon, I need tests that prove that these generated urls do in fact expire on time, and that visitors to [...]]]></description>
			<content:encoded><![CDATA[<h2>The need</h2>
<p>I have a Rails app that is using Paperclip to generate expiring urls for files stored in S3. The urls are set to expire after 1 minute. As much as i trust Paperclip and Amazon, I need tests that prove that these generated urls do in fact expire on time, and that visitors to those files after they&#8217;ve expired are prevented from accessing the file.</p>
<h2 style="font-size: 1.5em;">Disclaimer</h2>
<p>This has been a bit of a rush, so no doubt i&#8217;ll refactor and tidy the code and this post laster today / in the week.</p>
<h2 style="font-size: 1.5em;">The solution</h2>
<p>I&#8217;ve used RSpec and Cucumber to check expiring urls that the system generates to ensure they expire successfully. RSpec simply checks that a generated url includes the Expires parameter and it&#8217;s value is set exactly to 60 seconds from now. Cucumber goes further than this by uploading files and checking if they are accessible before and after expiration.</p>
<h3><span style="color: #333399;"> RSpec to simply test that the expiration time generated for a link is correctly set to 1 minute<br />
</span></h3>
<p>This test simply asks the model containing the attachment (in this case an &#8220;Asset&#8221; model), how many seconds from now remain before the attachment expires.</p>
<p><strong>Spec</strong></p>
<blockquote><p>describe Asset do</p>
<p style="padding-left: 30px; "><strong> it &#8220;should return an attachment link that expires within 1 minute&#8221; do</strong></p>
<p style="padding-left: 60px;">asset = Factory.build(:asset)<br />
asset.seconds_until_attachment_expires.should == 60</p>
<p style="padding-left: 30px; ">end</p>
<p>end</p></blockquote>
<p>This depends on a few new methods in the Asset model class, which take care of extracting the Expires param from the expiring url, and comparing to Time.now.</p>
<p><strong>Asset Model Class</strong></p>
<p>First, we create an instance helper method that returns the number of seconds an object&#8217;s url has left before it expires</p>
<blockquote><p>def seconds_until_attachment_expires</p>
<p style="padding-left: 30px;">Asset.seconds_until_attachment_expires(expiring_attachment_url)</p>
<p>end</p></blockquote>
<p>I decided to pass the responsibility of calculating this number to a class method. I did this because the Cucumber tests need to request the same calculation for urls that were generated in the past. If they interacted with an instance of the Asset class, by default it would return a new url each time it was asked. So, rather than clutter up the instance method with a decision about whether to issue a new url or return an existing one, i simply passed the responsibility to the class. That seems to work for now, although I might refactor it later.</p>
<p>Next, we create the class level method that calculates time left until expiration. This accepts a url, meaning we can test urls generated now or in the past</p>
<blockquote><p>def self.seconds_until_attachment_expires(url)</p>
<p style="padding-left: 30px;">seconds = attachment_expiration_in_seconds_from_epoch(url) &#8211; Time.now.strftime(&#8221;%s&#8221;).to_i<br />
seconds.round</p>
<p>end</p></blockquote>
<p>This method simply strips the time from the generated url (via the attachment_expiration_in_seconds_from_epoch method) and rounds the value.</p>
<blockquote><p>def self.attachment_expiration_in_seconds_from_epoch(url)</p>
<p style="padding-left: 30px;">url.split(&#8221;&amp;&#8221;).second.split(&#8221;=&#8221;).last.to_i</p>
<p>end</p></blockquote>
<p>Clearly, this is tightly coupled to the format of the generated url string, so a cleaner way should be sought. However, for now, this method is only used in the tests and it does work, so it&#8217;ll do for the moment.</p>
<p>Finally, to ensure that Rspec, Cucumber and the app all interact with a url generated exactly 60 seconds from now, we create a model instance method that generates the link. All requests for the link call this method.</p>
<blockquote><p>def expiring_attachment_url</p>
<p style="padding-left: 30px;">attachment.expiring_url(60)</p>
<p>end</p></blockquote>
<h3 style="font-size: 1.17em;"><span style="color: #333399;">Cucumber to test actual file access via the browser</span></h3>
<p>Cucumber takes things 1 step further. It interacts with all the same methods that we created on the Asset model, but also goes off and uploads attachments and then tries to access them before and after they&#8217;ve expired. We use <a href="http://www.google.co.uk/url?sa=t&amp;rct=j&amp;q=timecop%20gem&amp;source=web&amp;cd=1&amp;ved=0CCEQFjAA&amp;url=https%3A%2F%2Fgithub.com%2Fjtrupiano%2Ftimecop&amp;ei=CarxTpfiJMLLswbLlM3mDw&amp;usg=AFQjCNHx9MgEnBzIw0ysdxhOMlxC40j_4Q">Timecop</a> to create expired urls, and a Cucumber <em>before</em> hook to ensure all scenarios run from the current time by default.</p>
<p><strong>Scenarios</strong></p>
<blockquote><p>@selenium<br />
<strong>Scenario: Viewing an active attachment on an object</strong></p>
<p style="padding-left: 30px;"><strong> </strong>Given some object has been created and a plain text file attached<br />
When I visit the object&#8217;s attachment url<br />
Then I should see the contents of the uploaded attachment<br />
And I should not see &#8220;Request has expired&#8221;</p>
<p>@selenium<br />
<strong>Scenario: Viewing an expired attachment on an object</strong></p>
<p style="padding-left: 30px;"><strong> </strong>Given some object has been created and a plain text file attached<br />
When I visit the object&#8217;s attachment url after it has expired<br />
Then I should not see the contents of the uploaded attachment<br />
And I should see &#8220;Request has expired&#8221;</p>
</blockquote>
<p><strong>features/support/hooks.rb</strong></p>
<blockquote><p>Before do</p>
<p style="padding-left: 30px;">Timecop.return</p>
<p>end</p></blockquote>
<p>NB: For the sake of completeness (even though we&#8217;re not calling Timecop from our Rspec specs), to be completely satisfied that Timecop isn&#8217;t affecting our specs in any unexpected way, we add the same to spec_helper.rb too:</p>
<p><strong>spec/spec_helper.rb</strong></p>
<p><strong><span style="font-weight: normal; "> </span></strong></p>
<blockquote><p>config.before do</p>
<p style="padding-left: 30px;">Timecop.return</p>
<p>end</p></blockquote>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 776px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">config.before do</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 776px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Timecop.return</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 776px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">end</div>
<p><strong>steps</strong></p>
<p>This is where Timecop offers a wonderfully simple way of generating expired urls.</p>
<blockquote><p><strong>And /^I visit the question&#8217;s attachment url after it has expired$/ do</strong></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;"><span style="color: #008080;"><span style="color: #99ccff;"><span style="color: #ff9900;"><span style="color: #333399;"><strong>#First, go back in time 2 minutes and generate the expiring url, and make sure it&#8217;s set to expire in 1 minute</strong><br />
</span> </span> </span> </span> </span> Timecop.freeze(Time.now &#8211; 2.to_i.minutes) do</p>
<p style="padding-left: 60px;">@url = current_object.asset.expiring_attachment_url<br />
Asset.attachment_expires_in(@url).should == 60</p>
<p style="padding-left: 30px;">end</p>
<p style="padding-left: 30px;"><strong><span style="color: #3366ff;"><span style="color: #008080;"><span style="color: #99ccff;"><span style="color: #ff9900;"><span style="color: #333399;"> #Next, return to the current time and make sure the previously generated expiring url has now been expired for 1 minute<br />
</span> </span> </span> </span> </span></strong> Timecop.return<br />
Asset.attachment_expires_in(@url).should == -60</p>
<p style="padding-left: 30px;"><strong><span style="color: #3366ff;"><span style="color: #008080;"><span style="color: #99ccff;"><span style="color: #ff9900;"><span style="color: #333399;"> #Finally, go visit the expired url<br />
</span> </span> </span> </span> </span></strong> visit @url</p>
<p>end</p></blockquote>
<p>When run, cucumber correctly reports that expired urls result in the user seeing the message &#8220;Request has expired&#8221;, and non-expired urls correctly provide access to the uploaded file.</p>
<h2 style="font-size: 1.5em;">Summary</h2>
<p>Although a rough and ready solution, and most likely needing refactoring, it does provide us with a way to test expiration of uploads to S3.</p>
<p>I hope you found this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2011/12/21/using-cucumber-to-test-s3-expiring-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting up and running with Git and Rails on EC2</title>
		<link>http://www.andygoundry.com/2011/11/06/getting-up-and-running-with-git-and-rails-on-ec2/</link>
		<comments>http://www.andygoundry.com/2011/11/06/getting-up-and-running-with-git-and-rails-on-ec2/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 23:17:20 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[EC2]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=505</guid>
		<description><![CDATA[Here&#8217;s a short list of things to do to get Git and Rails running on EC2:
Install Git
 
sudo yum install -y git

sudo yum install -y git

Install Rails

sudo yum install -y rubygems ruby-devel gcc libxml2 libxml2-devel libxslt libxslt-devel mysql mysql-devel
sudo gem update &#8211;system
sudo gem install rails

]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a short list of things to do to get Git and Rails running on EC2:</p>
<p><strong>Install Git</strong></p>
<p><strong> </strong></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">sudo yum install -y git</div>
<ul>
<li>sudo yum install -y git</li>
</ul>
<p><strong>Install Rails</strong></p>
<ul>
<li>sudo yum install -y rubygems ruby-devel gcc libxml2 libxml2-devel libxslt libxslt-devel mysql mysql-devel</li>
<li>sudo gem update &#8211;system</li>
<li>sudo gem install rails</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2011/11/06/getting-up-and-running-with-git-and-rails-on-ec2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick notes on creating a local git branch and pushing it into the wild</title>
		<link>http://www.andygoundry.com/2010/12/06/quick-notes-on-creating-a-local-git-branch-and-pushing-it-into-the-wild/</link>
		<comments>http://www.andygoundry.com/2010/12/06/quick-notes-on-creating-a-local-git-branch-and-pushing-it-into-the-wild/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 18:06:15 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=488</guid>
		<description><![CDATA[
Checkout the branch you want to switch from
git checkout branch_to_branch_from
Create the local branch
git branch branch_name
Switch to the branch
git checkout branch_name
Push to Remote
git push origin branch_name

]]></description>
			<content:encoded><![CDATA[<ol>
<li><strong>Checkout the branch you want to switch from<br />
</strong>git checkout branch_to_branch_from</li>
<li><strong>Create the local branch<br />
</strong>git branch branch_name</li>
<li><strong>Switch to the branch<br />
</strong>git checkout branch_name</li>
<li><strong>Push to Remote<br />
</strong>git push origin branch_name</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2010/12/06/quick-notes-on-creating-a-local-git-branch-and-pushing-it-into-the-wild/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tiny post &#8211; how to use .htaccess to redirect visitors</title>
		<link>http://www.andygoundry.com/2010/03/22/how-to-use-htaccess-to-redirect-visitors/</link>
		<comments>http://www.andygoundry.com/2010/03/22/how-to-use-htaccess-to-redirect-visitors/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 20:10:52 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=468</guid>
		<description><![CDATA[redirect 301 /help_decide/index.html http://showcase.health2works.com/help_decide/Homepage.html
Damn, it&#8217;s been ages since i&#8217;ve posted. This is a tiny one that is simple yet very useful.
The Situation
I have a Napkee site that consists of a bunch of html files linked together. This was naturally created from a set of Balsamiq screens. Within these Balsamiq screens was a screen called &#8216;Homepage&#8217; [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">redirect 301 /help_decide/index.html http://showcase.health2works.com/help_decide/Homepage.html</div>
<p>Damn, it&#8217;s been ages since i&#8217;ve posted. This is a tiny one that is simple yet very useful.</p>
<p><strong>The Situation</strong></p>
<p>I have a Napkee site that consists of a bunch of html files linked together. This was naturally created from a set of Balsamiq screens. Within these Balsamiq screens was a screen called &#8216;Homepage&#8217; (not index, because that would have been machine friendly but user unfriendly). So, on Napkee export, no index.html file had been created, which is just messy when sending out links to the Napkee screens because i didn&#8217;t want to include Homepage.html in the link.</p>
<p><strong>The Need</strong></p>
<p>I wanted to redirect all requests for http://www.website.com/napkee_mockup to http://www.website.com/napkee_mockup/Homepage.html</p>
<p><strong>The Options</strong></p>
<ul>
<li><strong>[<span style="color: #ff0000;">Bad</span>] An error page</strong>: Not an option so i&#8217;ll say no more about it.</li>
<li><strong><strong>[<span style="color: #ff0000;">Bad</span>] </strong>A Meta Refresh</strong>, where the following code is added to the Meta tags within the file Head. Again this was not an option as it gives the redirect task to the end user&#8217;s browser.</li>
</ul>
<blockquote><p>&lt;META HTTP-EQUIV=&#8221;refresh&#8221; content=&#8221;0;URL=http://www.new.com/new.htm&#8221;&gt;<br />
&lt;META NAME=&#8221;ROBOTS&#8221; CONTENT=&#8221;NOINDEX, NOFOLLOW&#8221;&gt;</p></blockquote>
<ul>
<li><strong><strong>[<span style="color: #ff0000;">Bad</span>] </strong>JavaScript Refresh</strong>: Too ugly to even paste the code in here, so i won&#8217;t bother. This is again bad because you&#8217;re forcing the user to not only do the redirecting for you, but you&#8217;re also demanding that they use JavaScript to do it. Not very friendly.</li>
<li><strong><strong>[<span style="color: #008000;">Good</span>] </strong>.htaccess redirect</strong>: This is the only correct way to do it.</li>
</ul>
<p><strong>The Solution</strong></p>
<blockquote><p>cd [www]/napkee_mockup</p>
<p>vim .htaccess</p>
<p><strong><span style="font-weight: normal;">add the following: </span></strong></p>
<p><strong><span style="font-weight: normal;">redirect 301 /napkee_mockup/index.html http://website.com/napkee_mockup/Homepage.html</span></strong></p></blockquote>
<div>The key is to ensure that the FROM url is relative to the web application root (so you have to include /napkee_mockup/) and you shouldn&#8217;t include the domain details (http://website.com)</div>
<div>
<p>I hope this helps a little.</p></div>
<p>There&#8217;s more good reading at <a href="http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm">http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2010/03/22/how-to-use-htaccess-to-redirect-visitors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to use thor with the latest version of merb</title>
		<link>http://www.andygoundry.com/2009/11/26/using-thor-with-a-merb-app-and-merb-version/</link>
		<comments>http://www.andygoundry.com/2009/11/26/using-thor-with-a-merb-app-and-merb-version/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 14:45:46 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Merb]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[thor]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=463</guid>
		<description><![CDATA[The latest version of thor (0.12.0) doesn&#8217;t work with the latest version of merb (1.0.15).
To use thor with your merb 1.0.15 app, you need to install thor -v0.9.9 and then follow the instructions on this page: http://wiki.merbivore.com/deployment/bundling
]]></description>
			<content:encoded><![CDATA[<p>The latest version of thor (0.12.0) doesn&#8217;t work with the latest version of merb (1.0.15).</p>
<p>To use thor with your merb 1.0.15 app, you need to install thor -v0.9.9 and then follow the instructions on this page: <a href="http://wiki.merbivore.com/deployment/bundling">http://wiki.merbivore.com/deployment/bundling</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2009/11/26/using-thor-with-a-merb-app-and-merb-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merb Gem Cleanup</title>
		<link>http://www.andygoundry.com/2009/11/25/merb-gem-cleanup/</link>
		<comments>http://www.andygoundry.com/2009/11/25/merb-gem-cleanup/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 18:33:31 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[DataMapper]]></category>
		<category><![CDATA[Merb]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=461</guid>
		<description><![CDATA[It seems to be a common issue for us Merbists, who depend on multiple Gems for merb to play nicely to get into a bit of a mess as gems are updated.
So, at times a cleanup is in order. Here is what i&#8217;ve done to cleanup my merb setup:

$ sudo gem update --system
$ gem search [...]]]></description>
			<content:encoded><![CDATA[<p>It seems to be a common issue for us Merbists, who depend on multiple Gems for merb to play nicely to get into a bit of a mess as gems are updated.</p>
<p>So, at times a cleanup is in order. Here is what i&#8217;ve done to cleanup my merb setup:</p>
<blockquote>
<pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 12px; color: #000000; overflow-x: auto; overflow-y: auto; background-color: #f3f3f3; padding: 1em;">$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> update --system
$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> search --no-version merb | grep merb | xargs <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> un<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">install</span> -a # NOTE: removes all old version of merb
$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> search --no-version dm | grep dm | xargs <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> un<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">install</span> -a # NOTE: removes all old version of data_mapper
$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> search --no-version data_objects | grep data_objects | xargs <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> un<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">install</span> -a # NOTE: removes all old version of data_objects
$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> sources -c
$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> rm PATH_TO_<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">GEM</span>S/cache/merb* # PATH_TO_<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">GEM</span>S is the path to your ruby<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span>s <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">install</span>.  Mine is /usr/lib/ruby/<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span>s/1.8
$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> rm PATH_TO_<span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">GEM</span>S/cache/dm*
$ <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">sudo</span> <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">gem</span> <span style="color: #000000; background-color: #ffff99; padding: 0px; margin: 0px;">install</span> -r merb</pre>
</blockquote>
<p>This was taken from the meb installation instructions at: <a href="http://wiki.merbivore.com/howto/installation/gems">http://wiki.merbivore.com/howto/installation/gems</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2009/11/25/merb-gem-cleanup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Call TextMate from command line</title>
		<link>http://www.andygoundry.com/2009/09/07/call-textmate-from-command-line/</link>
		<comments>http://www.andygoundry.com/2009/09/07/call-textmate-from-command-line/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 12:15:04 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=445</guid>
		<description><![CDATA[A really neat feature of TextMate is the ability to call it from the command line and pass a directory or file as the object to open. Works great.
For this to work, you need to run a quick one-liner on the command line:
sudo ln -s /Applications/TextMate.app/Contents/Resources/mate /usr/local/bin/mate
Once done, you can call mate and pass it [...]]]></description>
			<content:encoded><![CDATA[<p>A really neat feature of TextMate is the ability to call it from the command line and pass a directory or file as the object to open. Works great.</p>
<p>For this to work, you need to run a quick one-liner on the command line:</p>
<blockquote><p>sudo ln -s /Applications/TextMate.app/Contents/Resources/mate /usr/local/bin/mate</p></blockquote>
<p>Once done, you can call mate and pass it any object you want to open, such as:</p>
<blockquote><p>$ mate my_rails_app</p></blockquote>
<p>and it opens the entire directory as if it were a TextMate project.</p>
<p>Lots more detail available here: <a href="http://manual.macromates.com/en/using_textmate_from_terminal.html">http://manual.macromates.com/en/using_textmate_from_terminal.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2009/09/07/call-textmate-from-command-line/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Cucumber, Webrat and Selenium to test ajax form field validations</title>
		<link>http://www.andygoundry.com/2009/09/04/using-cucumber-webrat-and-selenium-to-test-ajax-form-field-validations/</link>
		<comments>http://www.andygoundry.com/2009/09/04/using-cucumber-webrat-and-selenium-to-test-ajax-form-field-validations/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 18:11:09 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Merb]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Webrat]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=439</guid>
		<description><![CDATA[I have an app that fires an ajax request on a form field to validate its contents when I take focus off the field.
I am also using Cucumber, Webrat and Selenium for my integration tests.
I needed my integration tests to test the Ajax responses and the tests weren&#8217;t receiving a response from the Ajax requests.
The [...]]]></description>
			<content:encoded><![CDATA[<p>I have an app that fires an ajax request on a form field to validate its contents when I take focus off the field.</p>
<p>I am also using Cucumber, Webrat and Selenium for my integration tests.</p>
<p>I needed my integration tests to test the Ajax responses and the tests weren&#8217;t receiving a response from the Ajax requests.</p>
<p><strong>The Problem</strong></p>
<p>I found that by simply completing the web form, the ajax request was not being fired and my test was therefore failing when i checked for the existance of the Ajax response. It soon became clear that selenium doesn&#8217;t really interact with the form in the sense of selecting fields and entering values; It simply enters values. As such, the Ajax request was not firing and my test was failing.</p>
<p><strong>The Solution</strong></p>
<p>The solution is Selenium&#8217;s fireEvent method, which you can pass a form field id and the blur method:</p>
<blockquote><p>selenium_session.fireEvent(&#8221;field&#8221;, &#8220;blur&#8221;);</p></blockquote>
<p>In Webrat, this is ever simpler:</p>
<blockquote><p>fire_event(&#8221;field&#8221;,&#8221;blur&#8221;)</p></blockquote>
<p>On using this in a Cucumber step, the ajax is fired as the blur command tells the browser to take focus off the field.</p>
<p>Lovely!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2009/09/04/using-cucumber-webrat-and-selenium-to-test-ajax-form-field-validations/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up Merb, Cucumber and Webrat (and friends) on Snow Leopard</title>
		<link>http://www.andygoundry.com/2009/09/04/setting-up-merb-cucumber-and-webrat-on-snow-leopard-some-good-some-bad/</link>
		<comments>http://www.andygoundry.com/2009/09/04/setting-up-merb-cucumber-and-webrat-on-snow-leopard-some-good-some-bad/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 14:36:06 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Merb]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Webrat]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=428</guid>
		<description><![CDATA[
My upgrade to Snow Leopard killed my Merb, Cucumber and Webrat setup so i had to start afresh. That was the bad. The good is that some manual hacks that were required in Leopard are no longer necessary, meaning I can rely on direct gem installations.
Here&#8217;s what i did:

Install Ruby and Gems
Follow instructions on http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/
Install [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>My upgrade to Snow Leopard killed my Merb, Cucumber and Webrat setup so i had to start afresh. That was the bad. The good is that some manual hacks that were required in Leopard are no longer necessary, meaning I can rely on direct gem installations.</p>
<p>Here&#8217;s what i did:</p>
<ol>
<li><strong>Install Ruby and Gems<br />
<span style="font-weight: normal; ">Follow instructions on <a href="http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/">http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/</a></span></strong></li>
<li><strong>Install merb, rspec, cucumber, merb_cucumber and mongrel and dependencies<br />
<span style="font-weight: normal; ">sudo gem install merb rspec cucumber roman-merb_cucumber mongrel term-ansicolor treetop diff-lcs nokogiri do_sqlite3</span></strong></li>
<li><strong>Install webrat<br />
<span style="font-weight: normal;">sudo gem install hoe hpricot webrat</span></strong></li>
<li><strong><span style="font-weight: normal;"><strong>Fix Firefox bug with Snow Leopard<br />
<span style="font-weight: normal;">For some reason the libsqlite3.dylib  library in FireFox 3.5.2 is out of date and breaks cucumber under Snow Leopard. Thankfully, it&#8217;s a simple fix:<br />
mv /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib.orig<br />
cp /usr/lib/libsqlite3.dylib /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib</span></strong></span></strong></li>
<li><strong><span style="font-weight: normal;"><strong><span style="font-weight: normal;"><strong>Install Selenium<br />
<span style="font-weight: normal;">sudo gem install Selenium<br />
sudo gem install selenium-client</span></strong></span></strong></span></strong></li>
<li><strong>Install the textmate cucumber bundle<br />
<span style="font-weight: normal;"><a href="http://github.com/bmabey/cucumber-tmbundle/tree/master">http://github.com/bmabey/cucumber-tmbundle/tree/master</a></span></strong></li>
</ol>
<p><strong>Deprecated Instructions on Snow Leopard that were required on Leopard</strong></p>
<p>The following ugly hacks were required on Leopard with it&#8217;s default Ruby installation. These are no longer required (at least on my machine) on Snow Leopard:</p>
<p><span style="text-decoration: underline;">Manual hack of Selenium</span></p>
<p>http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium</p>
<p>As the instructions recommended replacing the Selemium RC jar file () in the installed gem with one from the Selenium website, i had to find out where the gem had installed. Thankfully, gem -h pointed me toward gem help commands and from there i ran gem environment &#8211; This told me where gems are installed locally and i found that Selemium RC had been installed into /Library/Ruby/Gems/1.8/gems/Selenium-1.1.14/ I replaced as advised and then ran selenium from within the app root and all worked fine, using the replacement. I then downloaded and ran the test selenium code from http://github.com/aslakhellesoy/cucumber/tree/master/examples/selenium running selenium in a different console and then running cucumber examples/selenium/features/ . It worked a treat and booted up selenium as required. Great!</p>
<p><span style="text-decoration: underline;">Manual hack installation of webrat</span></p>
<p>Download http://github.com/gwynm/webrat/tree/master tar file. Git clone doesn&#8217;t work</p>
<p>sudo gem install hoe hpricot<br />
cd downloaded and untarred file<br />
rake gem<br />
sudo gem install pkg/webrat-0.2.1.gem</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2009/09/04/setting-up-merb-cucumber-and-webrat-on-snow-leopard-some-good-some-bad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

