<?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>confabulus &#187; Uncategorized</title>
	<atom:link href="http://blog.confabulus.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.confabulus.com</link>
	<description>rails, coding, and the goings on at confabulus</description>
	<lastBuildDate>Tue, 26 Jul 2011 20:40:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bulk ammending commit messages in git</title>
		<link>http://blog.confabulus.com/2011/07/25/bulk-ammending-commit-messages-in-git/</link>
		<comments>http://blog.confabulus.com/2011/07/25/bulk-ammending-commit-messages-in-git/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 00:54:20 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[perforce]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=180</guid>
		<description><![CDATA[At my job I&#8217;m using git-p4 to work locally with some rails code in git and push to perforce. It&#8217;s working okay but one issue for me is that we require every commit to perforce to have a code review by someone, and we put the reviewer&#8217;s name at the bottom of each commit. For [...]]]></description>
			<content:encoded><![CDATA[<p>At my job I&#8217;m using git-p4 to work locally with some rails code in git and push to perforce. It&#8217;s working okay but one issue for me is that we require every commit to perforce to have a code review by someone, and we put the reviewer&#8217;s name at the bottom of each commit. For example:<br />
<code><br />
Live changes to histograms<br />
-commonized the histograms views &#038; logic</p>
<p>CR: JamesM<br />
</code></p>
<p>Well when I&#8217;m working in the git repo, I don&#8217;t know who is going to code review it, so I end up having to add CR: JamesM to several commits. It can be done with rebase -i, but it is several steps per commit. I could use git-notes, but that doesn&#8217;t follow the format that we like (it puts Notes: in). Because this is a local repo only, changing the commit history is not a big deal. After some searching I found the way:<br />
<code><br />
git filter-branch --msg-filter 'cat &#038;&#038; echo "CR: REVIEWER"' p4/master~1..HEAD<br />
</code></p>
<p>This little beauty will append CR: REVIEWER to all of the commits from the master to the current head (all of the local commits).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2011/07/25/bulk-ammending-commit-messages-in-git/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>updating embedded jruby gems with ant</title>
		<link>http://blog.confabulus.com/2009/12/08/updating-embedded-jruby-gems-with-ant/</link>
		<comments>http://blog.confabulus.com/2009/12/08/updating-embedded-jruby-gems-with-ant/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 20:05:17 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=149</guid>
		<description><![CDATA[Recently I have been using cuke4duke on a java project (which I&#8217;ll discuss in a later article). We have jruby running from jruby-lib/jruby-complete.jar. Our gems are embedded in the project with the GEM_HOME/GEM_PATH being set to jruby-lib/gems. All of this is under source control. We don&#8217;t have jruby installed at all on the system, it [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been using cuke4duke on a java project (which I&#8217;ll discuss in a later article). We have jruby running from jruby-lib/jruby-complete.jar. Our gems are embedded in the project with the GEM_HOME/GEM_PATH being set to jruby-lib/gems. All of this is under source control. We don&#8217;t have jruby installed at all on the system, it is only in this project. I&#8217;ve mainly been the one on the team (of 4 total) who has been maintaining the jruby stuff as none of the other devs have jruby experience.</p>
<p>So one of the problems I had recently was how to update the gems that are checked into source. One of the other devs wanted to use multi-line strings in cucumber and found that it didn&#8217;t work with cuke4duke until cucumber-0.4.4. We had 0.4.2. So what I needed was an easy way for the other devs to be able to update the gems without relying on jruby being &#8220;installed&#8221; on the machine. Since these are java guys, ant seemed the best solution.</p>
<p>Here is the ant task I used:</p>
<pre class="brush: xml">
&lt;path id=&quot;jruby.classpath&quot;&gt;
	&lt;fileset dir=&quot;jruby-lib&quot;&gt;
		&lt;include name=&quot;**/*.jar&quot; /&gt;
		&lt;exclude name=&quot;gems/*&quot; /&gt;
	&lt;/fileset&gt;
&lt;/path&gt;
&lt;target name=&quot;update.gems&quot; description=&quot;update the installed gems&quot;&gt;
	&lt;!-- this updates the gems on the system --&gt;
	&lt;java classname=&quot;org.jruby.Main&quot; fork=&quot;true&quot; failonerror=&quot;true&quot;&gt;
		&lt;classpath refid=&quot;jruby.classpath&quot; /&gt;
		&lt;env key=&quot;GEM_PATH&quot; value=&quot;jruby-lib/gems&quot; /&gt;
		&lt;env key=&quot;GEM_HOME&quot; value=&quot;jruby-lib/gems&quot; /&gt;
		&lt;arg value=&quot;-S&quot; /&gt;
		&lt;arg value=&quot;gem&quot; /&gt;
		&lt;arg value=&quot;update&quot; /&gt;
	&lt;/java&gt;
	&lt;!-- this removes any obsoleted / previous version of all gems --&gt;
	&lt;java classname=&quot;org.jruby.Main&quot; fork=&quot;true&quot; failonerror=&quot;true&quot;&gt;
		&lt;classpath refid=&quot;jruby.classpath&quot; /&gt;
		&lt;env key=&quot;GEM_PATH&quot; value=&quot;jruby-lib/gems&quot; /&gt;
		&lt;env key=&quot;GEM_HOME&quot; value=&quot;jruby-lib/gems&quot; /&gt;
		&lt;arg value=&quot;-S&quot; /&gt;
		&lt;arg value=&quot;gem&quot; /&gt;
		&lt;arg value=&quot;cleanup&quot; /&gt;
	&lt;/java&gt;
&lt;/target&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2009/12/08/updating-embedded-jruby-gems-with-ant/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Announcing Mainline</title>
		<link>http://blog.confabulus.com/2009/01/30/125/</link>
		<comments>http://blog.confabulus.com/2009/01/30/125/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 02:26:02 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=125</guid>
		<description><![CDATA[
Mainline is a rails plugin which exposes your rails app via webrick to allow
testing with browser automators such as Selenium or Watir. Mainline allows
your rails actions to run in the same transaction as your unit tests so you
can use fixtures, factories, or whatever.
Basically you can now test selenium in your same transaction and don&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
Mainline is a rails plugin which exposes your rails app via webrick to allow<br />
testing with browser automators such as Selenium or Watir. Mainline allows<br />
your rails actions to run in the same transaction as your unit tests so you<br />
can use fixtures, factories, or whatever.</p></blockquote>
<p>Basically you can now test selenium in your same transaction and don&#8217;t have to worry about rolling back your fixtures or factories.</p>
<p>Grab it from <a href="http://github.com/gaffo/mainline.git">Github</a><br />
Bug Reports at <a href="http://gaffo.lighthouseapp.com/projects/24578-mainline/overview">Lighthouse</a><br />
Docs at <a href="http://rdocul.us/repos/mainline/master/index.html">RDocul.us</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2009/01/30/125/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>chicken and egg</title>
		<link>http://blog.confabulus.com/2008/12/27/chicken-and-egg/</link>
		<comments>http://blog.confabulus.com/2008/12/27/chicken-and-egg/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 00:54:56 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=56</guid>
		<description><![CDATA[I can&#8217;t believe this still hapens. Unzip software that is zipped. I was trying to unzip a file off of the web to install on my palm and they had zipped the 15k zip prc file to save those few extra bytes on the web making it impossible to actually download and use the software [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t believe this still hapens. Unzip software that is zipped. I was trying to unzip a file off of the web to install on my palm and they had zipped the 15k zip prc file to save those few extra bytes on the web making it impossible to actually download and use the software without a full computer.</p>
<p>Ugh.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2008/12/27/chicken-and-egg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>testing named scopes</title>
		<link>http://blog.confabulus.com/2008/11/24/testing-named-scopes/</link>
		<comments>http://blog.confabulus.com/2008/11/24/testing-named-scopes/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 02:33:58 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=80</guid>
		<description><![CDATA[Named scopes are a nice feature that came out in rails 2.1, however, testing them is not very obvious.
Say we have a named scope in our member object which looks like this:

class Member &#60; ActiveRecord::Base
  named_scope :active, {:conditions =&#62; {:status =&#62; Member::STATUS_ACTIVE}}
end

There are 2 things we need to do to test them. 
First would [...]]]></description>
			<content:encoded><![CDATA[<p>Named scopes are a nice feature that came out in rails 2.1, however, testing them is not very obvious.</p>
<p>Say we have a named scope in our member object which looks like this:</p>
<pre class="brush: ruby">
class Member &lt; ActiveRecord::Base
  named_scope :active, {:conditions =&gt; {:status =&gt; Member::STATUS_ACTIVE}}
end
</pre>
<p>There are 2 things we need to do to test them. </p>
<p>First would be to make sure that the conditions are the same as we think they are. This one is open for debate a bit as it is somewhat tying the implementation directly to the test.</p>
<p>Second, we actually have to USE the scope. Just calling Member.active does not actually use the scope. This is because named scopes can be cascaded. If I had recent scope on a member that only showed me those that signed up recently, I could actually do Member.active.recent, and it would not execute against database, it would just nest the conditions.</p>
<p>So how do I use the scope? Use any collection method on them. I like size, but I&#8217;m completely open to suggestions. So below is how I am testing named scopes.</p>
<pre class="brush: ruby">
class MemberTest &lt; ActiveRecord::TestCase
  context &#039;named scope active&#039; do
    setup do
      @scoped_find = Member.active
    end

    should &quot;have condition active&quot; do
      expected_conditions  = {:conditions =&gt; [&quot;member.status == #{Member::STATUS_ACTIVE}&quot;]}
      assert_equal expected_conditions, @scoped_find.proxy_options
    end

    should &quot;have results&quot; do
      assert_not_nil(scoped.active.size)
    end
  end
end
</pre>
<p>The first test does part 1, the 2nd, part 2.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2008/11/24/testing-named-scopes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql issue with rails and antivirus on windows</title>
		<link>http://blog.confabulus.com/2008/10/31/mysql-issue-with-rails-and-antivirus-on-windows/</link>
		<comments>http://blog.confabulus.com/2008/10/31/mysql-issue-with-rails-and-antivirus-on-windows/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 19:40:12 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=78</guid>
		<description><![CDATA[
abstract_adapter.rb:150:in log': Mysql::Error: Can't create/write to file 'C:\MySQL5\tmp\#sql_190_0.MYI' (Errcode: 13)
I had been getting this issue quite a bit recently. The cause actually turned out to be a conflict between McAfee and MySQL. What was happening is that McAfee scans any file that is recently written to, especially those in tmp directories. McAfee reading the file [...]]]></description>
			<content:encoded><![CDATA[<p><code><br />
abstract_adapter.rb:150:in log': Mysql::Error: Can't create/write to file 'C:\MySQL5\tmp\#sql_190_0.MYI' (Errcode: 13)</code></p>
<p>I had been getting this issue quite a bit recently. The cause actually turned out to be a conflict between McAfee and MySQL. What was happening is that McAfee scans any file that is recently written to, especially those in tmp directories. McAfee reading the file causes the above issue to MySQL. The fix is 2 fold. First, if you have not already, move the location of the MySQL tmp file. You can do this by editing my.ini in your MySQL directory. For Example:<br />
<code><br />
tmpdir="C:/Program Files/MySQL/tmp/"<br />
</code></p>
<p>You may also have to add an exception to your antivirus so that it will no longer scan this file. I had to do this because I was using corporate antivirus. You may have to get your Sysadmin to do this.</p>
<p><a href="http://forums.mysql.com/read.php?24,169274,178492">Here is a post on mysql&#8217;s forums describing this issue as well</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2008/10/31/mysql-issue-with-rails-and-antivirus-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>testing protected and private methods in ruby</title>
		<link>http://blog.confabulus.com/2008/10/26/testing-protected-and-private-methods-in-ruby/</link>
		<comments>http://blog.confabulus.com/2008/10/26/testing-protected-and-private-methods-in-ruby/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 19:39:14 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[def]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=31</guid>
		<description><![CDATA[When I was looking for how to test protected an private methods in ruby on the net, I found many sites arguing whether you should, and several methods for doing so. I am of the opinion that if your method contains any logic at all, it should have a test. Some examples of what I [...]]]></description>
			<content:encoded><![CDATA[<p>When I was looking for how to test protected an private methods in ruby on the net, I found many sites arguing whether you should, and several methods for doing so. I am of the opinion that if your method contains any logic at all, it should have a test. Some examples of what I consider logic:</p>
<p><strong>Object:</strong></p>
<pre class="brush: ruby">
class User
  validates_presence_of :first_name, :last_name, :company_id
  belongs_to :company
  def full_name
    &quot;#{last_name}, #{first_name}&quot;
  end
  def company_name
    company.name
  end
end
</pre>
<p><strong>Test:</strong></p>
<pre class="brush: ruby">
class UserTest &lt; Test::Unit
  def test_full_name
    assert_equal(&quot;Gaffney, Mike&quot;, User.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;))
  end
  def test_company_name
    company = Company.new(:name =&gt; &quot;CompanyName&quot;)
    user = User.new(:company =&gt; company)
    assert_equal(&quot;CompanyName&quot;, user.company_name)
  end
end
</pre>
<p>This may seem like overkill but when many people are looking at the code it greatly helps communicate intention to others.</p>
<p><strong>Testing:</strong></p>
<p>I also found several methods to test protected and private methods in ruby, so I will cover the pluses and minuses the ones I know of.</p>
<p>Lets say we have a User class and an unassociated comments class. Comments are only attributed to a poster&#8217;s full name. There is no direct ID link between comments and users.</p>
<pre class="brush: ruby">
class User
  validates_presence_of :first_name, :last_name
  def find_comments
    Comments.find(:all, :conditions =&gt; {:poster =&gt; full_name})
  end
  protected
  def full_name
    &quot;#{last_name}, #{first_name}&quot;
  end
end
</pre>
<p>Here are the approaches I&#8217;m going to use to test this:</p>
<ul>
<li>Using a Mock to open access restrictions</li>
<li>Make single (protected/private) methods public on the tested class.</li>
<li>Make all (protected/private) methods public on the tested class.</li>
<li>Hybrid Mock Approach</li>
<li>Using instance_eval and send</li>
<li>send</li>
</ul>
<p><strong>Using Mocks:</strong><br />
Mocks should be pretty familiar to most developers. Basically you create a class or subclass that the test will use. In our case we are simply opening the access restrictions with a subclass. Our test class looks like this:</p>
<pre class="brush: ruby">
class MockUser &lt; User
  def full_name
    super
  end
end
class UserTest &lt; Test::Unit
  def test_full_name
    user = User.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;)
    assert_equal(&quot;Gaffney, Mike&quot; user.full_name)
  end
end
</pre>
<p>Plusses:</p>
<ul>
<li>Simple and familiar to most developers from many languages</li>
</ul>
<p>Minuses:</p>
<ul>
<li>Can&#8217;t test private methods (subclass doesn&#8217;t have access).</li>
<li>With complicated classes you end up with quite a few mocks for all of the different cases. Managing the mocks becomes tedious.</li>
</ul>
<p><strong>Make single methods public:</strong><br />
Next we will make use of the runtime nature of ruby to change a function from protected to public. This also works for private methods:</p>
<pre class="brush: ruby">
class UserTest &lt; Test::Unit
  def test_full_name
    User.send(:public, :first_name)
    user = User.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;)
    assert_equal(&quot;Gaffney, Mike&quot; user.full_name)
  end
end
</pre>
<p>or</p>
<pre class="brush: ruby">
class User
    public :first_name
end
class UserTest &lt; Test::Unit
  def test_full_name
    user = User.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;)
    assert_equal(&quot;Gaffney, Mike&quot; user.full_name)
  end
end
</pre>
<p>Plusses:</p>
<ul>
<li>Lets us directly access the private or protected function.</li>
</ul>
<p>Minuses:</p>
<ul>
<li>This pollutes the default namespace for all of the other tests. Remember that tests can (and should be able to) run in random order. Take for example:
<ol>
<li>Full Name is a public function that some other objects use.</li>
<li>We make this function into a protected one and use this method to make it public for testing.</li>
<li>If this new test runs before the tests for the objects using the old public full_name, full_name will still be public even though it is actually protected.</li>
<li>The other tests do not fail but the code will fail during runtime.</li>
</ol>
</ul>
<p><strong>Make all methods public:</strong><br />
To save us some time on a big class, we can make all private and protected methods public:</p>
<pre class="brush: ruby">
class User
  public *protected_methods.collect(&amp;amp;amp;amp;:to_sym)
  public *private_methods.collect(&amp;amp;amp;amp;:to_sym)
end
class UserTest
  def test_full_name
    user = User.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;)
    assert_equal(&quot;Gaffney, Mike&quot; user.full_name)
  end
end
</pre>
<p>or </p>
<pre class="brush: ruby">
class UserTest &lt; Test::Unit
  def test_full_name
    User.send(:public, *MyClass.protected_instance_methods)
    User.send(:public, *MyClass.private_instance_methods)
    user = User.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;)
    assert_equal(&quot;Gaffney, Mike&quot; user.full_name)
  end
end
</pre>
<p>This has the same issues as above but can be done one to make large classes easy to test, especially using the first method.</p>
<p><strong>Hybrid Approach:</strong><br />
This works like the mock example and the previous example combined:</p>
<pre class="brush: ruby">
class AllAccessUser
  public *protected_methods.collect(&amp;amp;amp;amp:to_sym)
end
class UserTest &lt; Test::Unit
  def test_full_name
    user = AllAccessUser.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;)
    assert_equal(&quot;Gaffney, Mike&quot; user.full_name)
  end
end
</pre>
<p>This is easy like the previous but does not pollute the namespace. However it cannot be used for private methods.</p>
<p><strong>Using send</strong><br />
Now we will use the built in reflection method to call the protected/private method on the class. This makes use of the fact that protected and private in ruby aren&#8217;t really like protected and private in other languages.</p>
<pre class="brush: ruby">
class UserTest &lt; Test::Unit
  def test_full_name
    user = User.new(:first_name =&gt; &quot;Mike&quot;, :last_name =&gt; &quot;Gaffney&quot;)
    assert_equal(&quot;Gaffney, Mike&quot; user.send(:full_name))
  end
end
</pre>
<p>Plusses:</p>
<ul>
<li>Doesn&#8217;t pollute the namespace.</li>
<li>All code is right in the test.</li>
<li>Works for protected and private.</li>
</ul>
<p>Minuses:</p>
<ul>
<li>Some people don&#8217;t like using send </li>
</ul>
<p><strong>Summary:</strong><br />
Testing protected and private methods should be done, and ruby makes it much easier than some other languages. My preferred technique is the final one of using send. It is slightly less readable but keeps everything contained in one location.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2008/10/26/testing-protected-and-private-methods-in-ruby/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>new has_a block</title>
		<link>http://blog.confabulus.com/2008/09/23/new-has_a-block/</link>
		<comments>http://blog.confabulus.com/2008/09/23/new-has_a-block/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 03:29:00 +0000</pubDate>
		<dc:creator>gaffo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://blog.confabulus.com/?p=12</guid>
		<description><![CDATA[Pretty simple post, but any ruby object can be post conifged in a line with somthing like:
User.new(:name =&#62; &#8220;tony&#8221;){&#124;u&#124; u.save}
which is great for active record tests.
Or in a bigger example:

@trip = Trip.new{&#124;t&#124; t.save!}
@invite1 = Invitation.new(:user =&#62; users(:aaron),
                   [...]]]></description>
			<content:encoded><![CDATA[<p>Pretty simple post, but any ruby object can be post conifged in a line with somthing like:</p>
<p>User.new(:name =&gt; &#8220;tony&#8221;){|u| u.save}</p>
<p>which is great for active record tests.</p>
<p>Or in a bigger example:</p>
<pre class="brush: ruby">
@trip = Trip.new{|t| t.save!}
@invite1 = Invitation.new(:user =&gt; users(:aaron),
                                   :status =&gt; Invitation::STATUS_MAYBE){|i| i.save}
@invite1 = Invitation.new(:user =&gt; users(:aaron),
                                   :status =&gt; Invitation::STATUS_MAYBE){|i| i.save}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.confabulus.com/2008/09/23/new-has_a-block/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

