<?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>rafi_jacoby.blog</title>
	<atom:link href="http://rjacoby.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rjacoby.wordpress.com</link>
	<description>Does anybody want a peanut?</description>
	<lastBuildDate>Mon, 07 Feb 2011 18:54:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rjacoby.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/aeb286a457886de289aeca25d5f83f39?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>rafi_jacoby.blog</title>
		<link>http://rjacoby.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rjacoby.wordpress.com/osd.xml" title="rafi_jacoby.blog" />
	<atom:link rel='hub' href='http://rjacoby.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using rack-debug with Ruby 1.9.2 and Rails 3</title>
		<link>http://rjacoby.wordpress.com/2010/11/11/using-rack-debug-with-ruby-1-9-2-and-rails-3/</link>
		<comments>http://rjacoby.wordpress.com/2010/11/11/using-rack-debug-with-ruby-1-9-2-and-rails-3/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 21:54:21 +0000</pubDate>
		<dc:creator>rjacoby</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rjacoby.wordpress.com/?p=42</guid>
		<description><![CDATA[At my company, we run all our apps in Passenger (production and dev), and having a debugger that can attach to Passenger is very useful. When we were still on a Ruby 1.8.x/Rails 2.x stack, David Dollar&#8217;s excellent rack-debug worked &#8230; <a href="http://rjacoby.wordpress.com/2010/11/11/using-rack-debug-with-ruby-1-9-2-and-rails-3/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rjacoby.wordpress.com&amp;blog=1114764&amp;post=42&amp;subd=rjacoby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At my company, we run all our apps in Passenger (production and dev), and having a debugger that can attach to Passenger is very useful.<br />
When we were still on a Ruby 1.8.x/Rails 2.x stack, David Dollar&#8217;s excellent <a href="http://rubygems.org/gems/rack-debug">rack-debug</a> worked like a charm.</p>
<p>However, it depends on <a href="http://rubygems.org/gems/ruby-debug">ruby-debug</a> which is incompatible with 1.9.x. I did a quick fork of rack-debug to conditionally depend on <a href="http://rubygems.org/gems/ruby-debug19">ruby-debug19</a>, but when I submitted the pull request, ddollar rightly pointed out that the conditional logic in creating the gemspec wouldn&#8217;t work. It would only make a version of the gem for the ruby version on the machine that cut the gem, and there&#8217;s no way to have conditionals in gemspecs b/c they are YAML. He did however point me to a 1.9.x version he cut, <a href="http://rubygems.org/gems/rack-debug19">rack-debug19</a>.</p>
<p>The install instructions aren&#8217;t up-to-date for Rails 3, so here&#8217;s my version.<br />
<code>
<pre>
# Gemfile
group :development do
  gem "ruby-debug19"
  gem "rack-debug19", :require =&gt; 'rack-debug'
end

# Rakefile
require 'rack-debug/tasks'

# development.rb
YourAppName::Application.configure do
  config.middleware.use 'Rack::Debug'
...
end
</pre>
<p></code></p>
<p>We specify a &#8216;:require&#8217; in the gemfile b/c the gem name has changed, but the libs inside have the original name and bundler needs to require them as such.</p>
<p>Fire off &#8216;bundle install&#8217;, and things should go nicely, with 1.9.x-appropriate version of our debug libs and all their dependencies.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rjacoby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rjacoby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rjacoby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rjacoby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rjacoby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rjacoby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rjacoby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rjacoby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rjacoby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rjacoby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rjacoby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rjacoby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rjacoby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rjacoby.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rjacoby.wordpress.com&amp;blog=1114764&amp;post=42&amp;subd=rjacoby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rjacoby.wordpress.com/2010/11/11/using-rack-debug-with-ruby-1-9-2-and-rails-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fb7444ed04c429d5e6f91068465c1d1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rjacoby</media:title>
		</media:content>
	</item>
		<item>
		<title>Making Minispec and Autotest Play Nice</title>
		<link>http://rjacoby.wordpress.com/2010/10/13/making-minispec-and-autotest-play-nice/</link>
		<comments>http://rjacoby.wordpress.com/2010/10/13/making-minispec-and-autotest-play-nice/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 00:52:24 +0000</pubDate>
		<dc:creator>rjacoby</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rjacoby.wordpress.com/?p=27</guid>
		<description><![CDATA[As I&#8217;m moving into Ruby 1.9 development, I&#8217;m really liking minispec. It&#8217;s much like rspec, but very lightweight and comes with the language. Autotest is also incredibly useful, but it doesn&#8217;t find specs by default. It very much likes there &#8230; <a href="http://rjacoby.wordpress.com/2010/10/13/making-minispec-and-autotest-play-nice/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rjacoby.wordpress.com&amp;blog=1114764&amp;post=27&amp;subd=rjacoby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m moving into Ruby 1.9 development, I&#8217;m really liking minispec. It&#8217;s much like rspec, but very lightweight and comes with the language.</p>
<p>Autotest is also incredibly useful, but it doesn&#8217;t find specs by default. It very much likes there to be a &#8216;test&#8217; directory, with files named like &#8216;test_foo.rb&#8217;.</p>
<p>If you use rspec, it registers its own mappings for autotest and you never have to worry.</p>
<p>Autotest&#8217;s source recommends implementing an &#8216;autotest/discover.rb&#8217; in your project, which it finds and runs automagically for you.</p>
<p>Through some sniffing around the rspec codebase, I came up with this &#8216;discover.rb&#8217; for a gem I&#8217;m working on. It finds &#8216;spec/lib/foo_spec.rb&#8217; and looks for an implementation class of &#8216;lib/foo.rb&#8217;. It&#8217;s really just a super-simplification of rspec&#8217;s discovery strategy.</p>
<pre><code>Autotest.add_hook :initialize do |at|
  at.clear_mappings
  at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
    ["spec/lib/#{m[1]}_spec.rb"]
  }
end

class Autotest::MiniSpec &lt; Autotest
end</code></pre>
<p>The other part required to make autotest happy is a nice &#8216;.autotest&#8217; file in the project.</p>
<pre><code>require 'autotest/restart'

Autotest.add_hook :initialize do |at|
  at.testlib = 'minitest/spec'

  at.add_exception 'coverage.info'
  at.add_exception 'coverage'
end
</code></pre>
<p>There&#8217;s probably a nice way to combine these, given that they both are patching the initialize hook.</p>
<p>And for good measure, here&#8217;s the &#8216;spec/lib/spec_helper.rb&#8217; I&#8217;m including in all the specs:</p>
<pre><code>$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'minitest/autorun'

# Try to make the output nice and fancy with 'turn'
begin
  require 'turn'
rescue LoadError
  puts "Could not find gem 'turn', continuing without prettiness."
end</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rjacoby.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rjacoby.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rjacoby.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rjacoby.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rjacoby.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rjacoby.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rjacoby.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rjacoby.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rjacoby.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rjacoby.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rjacoby.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rjacoby.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rjacoby.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rjacoby.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rjacoby.wordpress.com&amp;blog=1114764&amp;post=27&amp;subd=rjacoby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rjacoby.wordpress.com/2010/10/13/making-minispec-and-autotest-play-nice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fb7444ed04c429d5e6f91068465c1d1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rjacoby</media:title>
		</media:content>
	</item>
		<item>
		<title>rake db:migrate fails silently</title>
		<link>http://rjacoby.wordpress.com/2010/08/06/rake-dbmigrate-fails-silently/</link>
		<comments>http://rjacoby.wordpress.com/2010/08/06/rake-dbmigrate-fails-silently/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 18:29:22 +0000</pubDate>
		<dc:creator>rjacoby</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rjacoby.wordpress.com/?p=21</guid>
		<description><![CDATA[One of our engineers is just getting into Rails development, and he ran into some strange issues getting things working. He had tried in the past, and never quite got all the ducks lined up, so there was a chance &#8230; <a href="http://rjacoby.wordpress.com/2010/08/06/rake-dbmigrate-fails-silently/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rjacoby.wordpress.com&amp;blog=1114764&amp;post=21&amp;subd=rjacoby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of our engineers is just getting into Rails development, and he ran into some strange issues getting things working. He had tried in the past, and never quite got all the ducks lined up, so there was a chance that his environment was a bit off.</p>
<p>He could run &#8216;rake db:create&#8217; and &#8216;rake db:drop&#8217; with success, but &#8216;rake db:migrate&#8217; would fail silently. This is a problem we didn&#8217;t find easily in Google, so I&#8217;m writing this for posterity.</p>
<p>First step, throw &#8216;&#8211;trace&#8217; on the end.<br />
<code><br />
bash$ rake db:migrate --trace<br />
&lt;snip&gt;<br />
** Invoke environment (first_time)<br />
** Execute environment<br />
bash$</code></p>
<p>That&#8217;s odd. So I took a look in the rails gem at the rake files. As suspected, &#8216;db:drop&#8217; and &#8216;db:create&#8217; have different prereqs than &#8216;db:migrate&#8217;, which includes &#8220;=&gt; :environment&#8221; (load the whole Rails environment) in its task definition.</p>
<p>A quick test rakefile added to his project validated the conclusion:</p>
<p><code></p>
<pre>
task :noenvtest do
  puts "*** ohai no env"
end

task :envtest =&gt; :environment do
  puts "*** ohai env"
end
</pre>
<p></code></p>
<p>As expected, &#8216;rake noenvtest&#8217; gave output, and &#8216;rake envtest&#8217; failed silently again.</p>
<p>So, we took a look at his gems. While he had rails 2.3.8 and friends, his rubygems was at 1.3.4 and his gem sources were out of date. We deleted the old sources (gem source -r http://gems.rubyforge.org) and added the right one. Updated the rest of his gems, and db:migrate runs again!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rjacoby.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rjacoby.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rjacoby.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rjacoby.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rjacoby.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rjacoby.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rjacoby.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rjacoby.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rjacoby.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rjacoby.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rjacoby.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rjacoby.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rjacoby.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rjacoby.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rjacoby.wordpress.com&amp;blog=1114764&amp;post=21&amp;subd=rjacoby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rjacoby.wordpress.com/2010/08/06/rake-dbmigrate-fails-silently/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fb7444ed04c429d5e6f91068465c1d1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rjacoby</media:title>
		</media:content>
	</item>
	</channel>
</rss>
