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

<channel>
	<title>David Chelimsky</title>
	<atom:link href="http://blog.davidchelimsky.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.davidchelimsky.net</link>
	<description></description>
	<pubDate>Tue, 24 Jan 2012 06:03:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>rspec-rails-2.8.1 is released</title>
		<link>http://blog.davidchelimsky.net/2012/01/05/rspec-rails-281-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/01/05/rspec-rails-281-is-released/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 05:43:28 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<category><![CDATA[RSpec]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2863</guid>
		<description><![CDATA[Bug fix release

The rails-3.2.0.rc2 release broke stub_model in rspec-rails-2.0.0 > 2.8.0.
The rspec-rails-2.8.1 release fixes this issue, but it means that when you
upgrade to rails-3.2.0.rc2 or greater, you&#8217;ll have to upgrade to
rspec-rails-2.8.1 or greater.

Because rspec-rails-2.8.1 supports all versions of rails since 3.0, I recommend
that you upgrade to rspec-rails-2.8.1 first, and then upgrade to
rails-3.2.0.rc2 (or 3.2.0 once [...]]]></description>
			<content:encoded><![CDATA[<h2>Bug fix release</h2>

<p>The rails-3.2.0.rc2 release broke <code>stub_model</code> in rspec-rails-2.0.0 > 2.8.0.
The rspec-rails-2.8.1 release fixes this issue, but it means that when you
upgrade to rails-3.2.0.rc2 or greater, you&#8217;ll have to upgrade to
rspec-rails-2.8.1 or greater.</p>

<p>Because rspec-rails-2.8.1 supports all versions of rails since 3.0, I recommend
that you upgrade to rspec-rails-2.8.1 first, and then upgrade to
rails-3.2.0.rc2 (or 3.2.0 once it&#8217;s out).</p>

<h3>Changelog</h3>

<p><a href="http://rubydoc.info/gems/rspec-rails/file/Changelog.md">http://rubydoc.info/gems/rspec-rails/file/Changelog.md</a></p>

<h3>Docs</h3>

<p><a href="http://rubydoc.info/gems/rspec-rails">http://rubydoc.info/gems/rspec-rails</a>
<br />
<a href="http://relishapp.com/rspec/rspec-rails">http://relishapp.com/rspec/rspec-rails</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/01/05/rspec-rails-281-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RSpec-2.8 is released!</title>
		<link>http://blog.davidchelimsky.net/2012/01/04/rspec-28-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/01/04/rspec-28-is-released/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 02:38:03 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<category><![CDATA[RSpec]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2856</guid>
		<description><![CDATA[We released RSpec-2.8.0 today with a host of new features and improvements
since 2.7. Some of the highlights are described below, but you can see the
full changelogs at:


http://rubydoc.info/gems/rspec-core/file/Changelog.md
http://rubydoc.info/gems/rspec-expectations/file/Changelog.md
http://rubydoc.info/gems/rspec-mocks/file/Changelog.md
http://rubydoc.info/gems/rspec-rails/file/Changelog.md


Documentation

While not 100% complete yet, we&#8217;ve made great strides on RSpec&#8217;s RDoc:


http://rubydoc.info/gems/rspec-core
http://rubydoc.info/gems/rspec-expectations
http://rubydoc.info/gems/rspec-mocks
http://rubydoc.info/gems/rspec-rails


http://rspec.info is now just a one pager (desperate for
some design love - volunteers please email rspec-users@rubyforge.org). All the
old [...]]]></description>
			<content:encoded><![CDATA[<p>We released RSpec-2.8.0 today with a host of new features and improvements
since 2.7. Some of the highlights are described below, but you can see the
full changelogs at:</p>

<ul>
<li><a href="http://rubydoc.info/gems/rspec-core/file/Changelog.md">http://rubydoc.info/gems/rspec-core/file/Changelog.md</a></li>
<li><a href="http://rubydoc.info/gems/rspec-expectations/file/Changelog.md">http://rubydoc.info/gems/rspec-expectations/file/Changelog.md</a></li>
<li><a href="http://rubydoc.info/gems/rspec-mocks/file/Changelog.md">http://rubydoc.info/gems/rspec-mocks/file/Changelog.md</a></li>
<li><a href="http://rubydoc.info/gems/rspec-rails/file/Changelog.md">http://rubydoc.info/gems/rspec-rails/file/Changelog.md</a></li>
</ul>

<h2>Documentation</h2>

<p>While not 100% complete yet, we&#8217;ve made great strides on RSpec&#8217;s RDoc:</p>

<ul>
<li><a href="http://rubydoc.info/gems/rspec-core">http://rubydoc.info/gems/rspec-core</a></li>
<li><a href="http://rubydoc.info/gems/rspec-expectations">http://rubydoc.info/gems/rspec-expectations</a></li>
<li><a href="http://rubydoc.info/gems/rspec-mocks">http://rubydoc.info/gems/rspec-mocks</a></li>
<li><a href="http://rubydoc.info/gems/rspec-rails">http://rubydoc.info/gems/rspec-rails</a></li>
</ul>

<p><a href="http://rspec.info">http://rspec.info</a> is now just a one pager (desperate for
some design love - volunteers please email rspec-users@rubyforge.org). All the
old pages are redirects to the relevant RDoc at http://rubydoc.info. RSpec-1
info is still available at <a href="http://old.rspec.info">http://old.rspec.info</a>.</p>

<p>We&#8217;ve still got Cucumber features up at
<a href="http://relishapp.com/rspec">http://relishapp.com/rspec</a>, but we&#8217;re going to be
phasing that out as the primary source of documentation. There are a lot of
reasons for this, and I&#8217;ll try to follow up with a separate blog post on this
topic.</p>

<h2>rspec-core</h2>

<h3>Improved support for tags and filtering</h3>

<p>You can now set default tags/filters in either <code>RSpec.configure</code> or a <code>.rspec</code>
file and override these tags on the command line. For example, this configuration
tells rspec to run all the examples that are not tagged <code>:slow</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># in spec/spec_helper.rb</span>
RSpec.<span style="color:#9900CC;">configure</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span>
  c.<span style="color:#9900CC;">treat_symbols_as_metadata_keys_with_true_values</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
  c.<span style="color:#9900CC;">filter_run_excluding</span> <span style="color:#ff3333; font-weight:bold;">:slow</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Now when you want run those, you can just do this:</p>

<pre><code>rspec --tag slow
</code></pre>

<p>This will override the configuration and run onlly the examples tagged <code>:slow</code>.</p>

<h3>&#8211;order rand</h3>

<p>We added an <code>--order</code> option with two supported values: <code>rand</code> and <code>default</code>.</p>

<p><code>rspec --order random</code> (or <code>rand</code>) tells RSpec to run the groups in a random
order, and then run the examples within each group in random order. We
implemented it this way (rather than complete randomization of every example)
because we don&#8217;t want to re-run expensive before(:all) hooks. A fair tradeoff,
as the resulting randomization is just as effective at exposing
order-dependency bugs.</p>

<p>When you use <code>--order random</code>, RSpec prints out the random number it used to
seed the randomizer. When you think you&#8217;ve found an order-dependency bug, you
can pass the seed along and the order will remain consistent:</p>

<pre><code>--order rand:3455
</code></pre>

<p><code>--order default</code> tells RSpec to load groups and examples as they are declared
in each file.</p>

<h3>rspec &#8211;init</h3>

<p>We added an <code>--init</code> switch to the <code>rspec</code> command to generate a &#8220;spec&#8221;
directory, and  &#8220;.rspec&#8221; and &#8220;spec/spec_helper.rb&#8221; files with some starter code
in them.</p>

<h2>rspec-expectations</h2>

<p>We discovered that <a href="https://github.com/rspec/rspec-expectations/blob/master/benchmarks/matcher_dsl_vs_classes.rb">the matcher DSL generates matchers that run considerably
slower than classes which implement the matcher
protocol</a>.
We made some minor improvements in the DSL, but to really improve things we
re-implemented every single built-in matcher as a class.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/01/04/rspec-28-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-2.8.0.rc1 is released</title>
		<link>http://blog.davidchelimsky.net/2011/11/06/rspec-280rc1-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2011/11/06/rspec-280rc1-is-released/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 17:02:40 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<category><![CDATA[RSpec]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2845</guid>
		<description><![CDATA[I just released rspec-2.8.0.rc1, which includes releases of rspec-core,
rspec-expectations, rspec-mocks, and rspec-rails. Changelogs for each are at:


rspec-core
rspec-expectations
rspec-mocks
rspec-rails


What&#8217;s new

Nothing really changed in rspec-rails or rspec-mocks, but rspec-core and
rspec-expectations have both gotten some nice improvements.

Configuration (rspec-core)

rspec-core offers a number of configuration options which can be declared on
the command line, in a config file (.rspec, ~/.rspec, or custom [...]]]></description>
			<content:encoded><![CDATA[<p>I just released rspec-2.8.0.rc1, which includes releases of rspec-core,
rspec-expectations, rspec-mocks, and rspec-rails. Changelogs for each are at:</p>

<ul>
<li><a href="https://github.com/rspec/rspec-core/blob/master/Changelog.md">rspec-core</a></li>
<li><a href="https://github.com/rspec/rspec-expectations/blob/master/Changelog.md">rspec-expectations</a></li>
<li><a href="https://github.com/rspec/rspec-mocks/blob/master/Changelog.md">rspec-mocks</a></li>
<li><a href="https://github.com/rspec/rspec-rails/blob/master/Changelog.md">rspec-rails</a></li>
</ul>

<h2>What&#8217;s new</h2>

<p>Nothing really changed in rspec-rails or rspec-mocks, but rspec-core and
rspec-expectations have both gotten some nice improvements.</p>

<h3>Configuration (rspec-core)</h3>

<p>rspec-core offers a number of configuration options which can be declared on
the command line, in a config file (<code>.rspec</code>, <code>~/.rspec</code>, or custom location),
as well as in an <code>RSpec.configure</code> block (in <code>spec/spec_helper.rb</code> by
convention). Before this release, some options, but not all, could be stored in
config files and then overridden on the command line. The problems were that it
was inconsistent (not all options worked this way), and we couldn&#8217;t override
options that were set in <code>RSpec.configure</code> blocks.</p>

<p>With this release, almost all options declared in <code>RSpec.configure</code> can be
overridden from the command line, and <code>--tag</code> options can override their
inverses. For example, if you have this in <code>.rspec</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--tag ~slow:true</pre></div></div>


<p>That means &#8220;exclude examples tagged <code>:slow =&gt; true</code>&#8220;. So the following example
would be excluded:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">it <span style="color:#996600;">&quot;does something&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:slow</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#008000; font-style:italic;"># ...</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>You can also exclude that example from <code>RSpec.configure</code> like this:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">RSpec.<span style="color:#9900CC;">configure</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span>
  c.<span style="color:#9900CC;">filter_run_excluding</span> <span style="color:#ff3333; font-weight:bold;">:slow</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Note: the naming is different for historical reasons, and we will reconcile
that in a future release, but for now, just know that <code>--tag</code> on the command
line and in <code>.rspec</code> is synonymous with <code>filter_run_[including|excluding]</code> in
<code>RSpec.configure</code>.</p>

<h3>Override from command line</h3>

<p>Whether the default is stored in <code>.rspec</code> or <code>RSpec.configure</code>, it can be overridden
from the command line like this:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">rspec --tag slow:true</pre></div></div>


<h3>&#8220;Profiles&#8221; in custom options files</h3>

<p>The <code>rspec</code> command has an <code>--options</code> option that let&#8217;s store command line args in
arbitrary files and tell RSpec where to find them. For example, you could set things
up so your normal spec run excludes the groups and examples marked <code>:slow</code> by putting
this in <code>.rspec</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--tag ~slow</pre></div></div>


<p>Now add a <code>.slow</code> file with:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--tag slow</pre></div></div>


<p>Now run <code>rspec</code> to run everything but the slow specs, and run <code>rspec --options
.slow</code> or <code>rspec -O.slow</code> to run the slow ones.</p>

<h3>Override from Rake task</h3>

<p>RSpec&#8217;s Rake task supports an <code>rspec_opts</code> config option, which means you can
set up different groupings from rake tasks as well. The fast/slow example above
would look like this:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">namespace <span style="color:#ff3333; font-weight:bold;">:spec</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  desc <span style="color:#996600;">&quot;runs the fast specs&quot;</span>
  <span style="color:#6666ff; font-weight:bold;">RSpec::Core::RakeTask</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:fast</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
    t.<span style="color:#9900CC;">rspec_opts</span> = <span style="color:#996600;">'--options .fast'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#6666ff; font-weight:bold;">RSpec::Core::RakeTask</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:slow</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
    t.<span style="color:#9900CC;">rspec_opts</span> = <span style="color:#996600;">'--options .slow'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Or ..</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">namespace <span style="color:#ff3333; font-weight:bold;">:spec</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  desc <span style="color:#996600;">&quot;runs the fast specs&quot;</span>
  <span style="color:#6666ff; font-weight:bold;">RSpec::Core::RakeTask</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:fast</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
    t.<span style="color:#9900CC;">rspec_opts</span> = <span style="color:#996600;">'--tag ~slow'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#6666ff; font-weight:bold;">RSpec::Core::RakeTask</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:slow</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
    t.<span style="color:#9900CC;">rspec_opts</span> = <span style="color:#996600;">'--tag slow'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<h3>Implicit <code>true</code> value for tags/filters</h3>

<p>This is not new in rspec-2.8, but all the tags/filters in the example above can
be written without explicitly typing <code>true</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--tag slow
--tag ~slow</pre></div></div>



<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">RSpec.<span style="color:#9900CC;">configure</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span> c.<span style="color:#9900CC;">filter_run_excluding</span> <span style="color:#ff3333; font-weight:bold;">:slow</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
it <span style="color:#996600;">&quot;does something&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:slow</span> <span style="color:#9966CC; font-weight:bold;">do</span></pre></div></div>


<p>You have to set a config option to enable this in rspec-2.x:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">RSpec.<span style="color:#9900CC;">configure</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span> c.<span style="color:#9900CC;">treat_symbols_as_metadata_keys_with_true_values</span> = <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>


<p>In rspec-3.0, this will be the default, but without setting this value in 2.x
you&#8217;ll get a deprecation warning when you try to configure things this way.
It&#8217;s ugly, I know, but this enabled us to introduce the new behavior without
breaking compatibility with some suites in a minor release.</p>

<h3>Ordering</h3>

<p>With 2.8, you can now run the examples in random order, using the new <code>--order</code>
option:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--order rand</pre></div></div>


<p>The order is randomized with some reasonable caveats:</p>

<ul>
<li>top level example groups are randomized</li>
<li>nested groups are randomized within their parent group</li>
<li>examples are randomized within their group</li>
</ul>

<p>This provides a very useful level of randomization while maintaining the
integrity of before/after <code>hooks</code>, <code>subject</code>, <code>let</code>, etc.</p>

<p>If you want to run the examples in the default ordering (file-system load
order for files and declaration order for groups/examples), you can override
the order from the command line:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--order default</pre></div></div>


<h3>Pseudo-randomization</h3>

<p>The randomization is managed by Ruby&#8217;s pseudo-randomization. This means that if
you find an order dependency and want to debug/fix it, you can fix the order by
providing the same seed for each run:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--order rand:1234</pre></div></div>


<p>The seed is printed to the console with each run, so you can just copy it to the
command. You can also just specify the seed, which RSpec will assume means you want
to run with <code>--order rand</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--seed 1234</pre></div></div>


<p>Every time you run the suite with the same seed, the examples will run in the
same &#8220;random&#8221; order.</p>

<h3>Built-in matchers are all classes in rspec-expectations</h3>

<p>The <a href="http://rubydoc.info/github/rspec/rspec-expectations/master/RSpec/Matchers">Matcher
DSL</a>
in rspec-expectations makes it dead simple to define custom matchers that suit
your domain. The problem is that it is <a href="https://github.com/rspec/rspec-expectations/blob/master/benchmarks/matcher_dsl_vs_classes.rb">several times slower than defining a
class to do
so</a>.
While this doesn&#8217;t make much difference when you have a custom matcher that you
use a few dozen times (where talking hundredths of seconds here), it does make
a difference if every single matcher invocation in your entire suite suffers
this problem.</p>

<p>The short term fix is that all of the built-in matchers have been
re-implemented as classes rather than using the DSL to declare them. This has
the added benefit of making it easier to navigate the code and RDoc</p>

<p>Longer term, we&#8217;ll try to refactor the internals of the matcher DSL so that it
generates a class at declaration time. Eventually.</p>

<h3>Summing up</h3>

<p>So that&#8217;s it. Nothing ground breaking. Nothing compatibility
breaking. But some nice new features and improvements that will make your life
just a little bit nicer when you upgrade. We&#8217;re doing a release candidate
because enough changed internally that I want to give you time to try it out,
so please, please do so! And please report any issues you&#8217;re having with this
upgrade to:</p>

<ul>
<li><a href="https://github.com/rspec/rspec-core/issues">rspec-core</a></li>
<li><a href="https://github.com/rspec/rspec-expectations/issues">rspec-expectations</a></li>
<li><a href="https://github.com/rspec/rspec-mocks/issues">rspec-mocks</a></li>
<li><a href="https://github.com/rspec/rspec-rails/issues">rspec-rails</a></li>
</ul>

<p>Assuming there are no significant issues, I&#8217;ll release 2.8 final within a week
or two.</p>

<p>Happy spec&#8217;ing!</p>

<p>David</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/11/06/rspec-280rc1-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-core 2.7.1 is released!</title>
		<link>http://blog.davidchelimsky.net/2011/10/20/rspec-core-271-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2011/10/20/rspec-core-271-is-released/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 12:13:43 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<category><![CDATA[RSpec]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2843</guid>
		<description><![CDATA[rspec-core-2.7.1

full changelog


Bug fixes


tell autotest the correct place to find the rspec executable


]]></description>
			<content:encoded><![CDATA[<h3>rspec-core-2.7.1</h3>

<p><a href="http://github.com/rspec/rspec-core/compare/v2.7.0...v2.7.1">full changelog</a></p>

<ul>
<li>Bug fixes

<ul>
<li>tell autotest the correct place to find the rspec executable</li>
</ul></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/10/20/rspec-core-271-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-2.7.0 is released!</title>
		<link>http://blog.davidchelimsky.net/2011/10/16/rspec-270-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2011/10/16/rspec-270-is-released/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 20:28:00 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<category><![CDATA[RSpec]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2840</guid>
		<description><![CDATA[We&#8217;re pleased to announce the release of rspec-2.7.0. Release notes for each
gem are listed below, but here are a couple of highlights:

Just type rspec

With the the 2.7.0 release, if you keep all of your specs in the conventional
spec directory, you don&#8217;t need to follow the rspec command with a path.
Just type rspec.

If you keep your [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re pleased to announce the release of rspec-2.7.0. Release notes for each
gem are listed below, but here are a couple of highlights:</p>

<h2>Just type <code>rspec</code></h2>

<p>With the the 2.7.0 release, if you keep all of your specs in the conventional
<code>spec</code> directory, you don&#8217;t need to follow the <code>rspec</code> command with a path.
Just type <code>rspec</code>.</p>

<p>If you keep your specs in a different directory, just set the <code>--default_path</code>
option to that directory on the command line, or in a <code>.rspec</code> config file.</p>

<h2>The rake task now lets Bundler manage Bundler</h2>

<p>The <code>RSpec::Core::RakeTask</code> invokes the <code>rspec</code> command in a subshell. In
recent releases, it assumed that you wanted it prefixed with <code>bundle exec</code> if
it saw a <code>Gemfile</code>. We then added <code>gemfile</code> and <code>skip_bundler</code> options to the
task, so you could manage this in different ways.</p>

<p>It turns out that Bundler manages this quite well without any help from RSpec.
If you activate Bundler in the parent shell, via the command line or
<code>Bundler.setup</code>, it sets environment variables that activate Bundler in the
subshell with the correct gemfile.</p>

<p>The <code>gemfile</code> and <code>skip_bundler</code> options are therefore deprecated and have no
effect.</p>

<h2>Release Notes</h2>

<h3>rspec-core-2.7.0</h3>

<p><a href="http://github.com/rspec/rspec-core/compare/v2.6.4...v2.7.0">full changelog</a></p>

<p>NOTE: RSpec&#8217;s release policy dictates that there should not be any backward
incompatible changes in minor releases, but we&#8217;re making an exception to
release a change to how RSpec interacts with other command line tools.</p>

<p>As of 2.7.0, you must explicity <code>require "rspec/autorun"</code> unless you use the
<code>rspec</code> command (which already does this for you).</p>

<ul>
<li><p>Enhancements</p>

<ul>
<li>Add example.exception (David Chelimsky)</li>
<li><code>--default_path</code> command line option (Justin Ko)</li>
<li>support multiple <code>--line_number</code> options (David J. Hamilton)

<ul>
<li>also supports <code>path/to/file.rb:5:9</code> (runs examples on lines 5 and 9)</li>
</ul></li>
<li>Allow classes/modules to be used as shared example group identifiers
(Arthur Gunn)</li>
<li>Friendly error message when shared context cannot be found (Sławosz
Sławiński)</li>
<li>Clear formatters when resetting config (John Bintz)</li>
<li>Add <code>xspecify</code> and xexample as temp-pending methods (David Chelimsky)</li>
<li>Add <code>--no-drb</code> option (Iain Hecker)</li>
<li>Provide more accurate run time by registering start time before code
is loaded (David Chelimsky)</li>
<li>Rake task default pattern finds specs in symlinked dirs (Kelly Felkins)</li>
<li>Rake task no longer does anything to invoke bundler since Bundler already
handles it for us. Thanks to Andre Arko for the tip.</li>
<li>Add <code>--failure-exit-code</code> option (Chris Griego)</li>
</ul></li>
<li><p>Bug fixes</p>

<ul>
<li>Include <code>Rake::DSL</code> to remove deprecation warnings in Rake > 0.8.7 (Pivotal
Casebook)</li>
<li>Only eval <code>let</code> block once even if it returns <code>nil</code> (Adam Meehan)</li>
<li>Fix <code>--pattern</code> option (wasn&#8217;t being recognized) (David Chelimsky)</li>
<li>Only implicitly <code>require "rspec/autorun"</code> with the <code>rspec</code> command (David
Chelimsky)</li>
<li>Ensure that rspec&#8217;s <code>at_exit</code> defines the exit code (Daniel Doubrovkine)</li>
<li>Show the correct snippet in the HTML and TextMate formatters (Brian
Faherty)</li>
</ul></li>
</ul>

<h3>rspec-expectations-2.7.0</h3>

<p><a href="http://github.com/rspec/rspec-expectations/compare/v2.6.0...v2.7.0">full changelog</a></p>

<ul>
<li><p>Enhancements</p>

<ul>
<li>HaveMatcher converts argument using <code>to_i</code> (Alex Bepple &amp; Pat Maddox)</li>
<li>Improved failure message for the <code>have_xxx</code> matcher (Myron Marston)</li>
<li>HaveMatcher supports <code>count</code> (Matthew Bellantoni)</li>
<li>Change matcher dups <code>Enumerable</code> before the action, supporting custom
<code>Enumerable</code> types like <code>CollectionProxy</code> in Rails (David Chelimsky)</li>
</ul></li>
<li><p>Bug fixes</p>

<ul>
<li>Fix typo in <code>have(n).xyz</code> documentation (Jean Boussier)</li>
<li>fix <code>safe_sort</code> for ruby 1.9.2 (<code>Kernel</code> now defines <code>&lt;=&gt;</code> for Object)
(Peter van Hardenberg)</li>
</ul></li>
</ul>

<h3>rspec-mocks-2.7.0</h3>

<p><a href="http://github.com/rspec/rspec-mocks/compare/v2.6.0...v2.7.0">full changelog</a></p>

<ul>
<li><p>Enhancements</p>

<ul>
<li>Use <code>__send__</code> rather than <code>send</code> (alextk) </li>
<li>Add support for <code>any_instance.stub_chain</code> (Sidu Ponnappa)</li>
<li>Add support for <code>any_instance</code> argument matching based on <code>with</code> (Sidu
Ponnappa and Andy Lindeman)</li>
</ul></li>
<li><p>Changes</p>

<ul>
<li>Check for <code>failure_message_for_should</code> or <code>failure_message</code> instead of
<code>description</code> to detect a matcher (Tibor Claassen)</li>
</ul></li>
<li><p>Bug fixes</p>

<ul>
<li>pass a hash to <code>any_instance.stub</code>. (Justin Ko)</li>
<li>allow <code>to_ary</code> to be called without raising <code>NoMethodError</code> (Mikhail
Dieterle)</li>
<li><code>any_instance</code> properly restores private methods (Sidu Ponnappa)</li>
</ul></li>
</ul>

<h3>rspec-rails-2.7.0</h3>

<p><a href="http://github.com/rspec/rspec-rails/compare/v2.6.1...v2.7.0">full changelog</a></p>

<ul>
<li><p>Enhancments</p>

<ul>
<li><code>ActiveRecord::Relation</code> can use the <code>=~</code> matcher (Andy Lindeman)</li>
<li>Make generated controller spec more consistent with regard to ids
(Brent J. Nordquist)</li>
<li>Less restrictive autotest mapping between spec and implementation files
(José Valim)</li>
<li><code>require 'rspec/autorun'</code> from generated <code>spec_helper.rb</code> (David Chelimsky)</li>
<li>add <code>bypass_rescue</code> (Lenny Marks)</li>
<li><code>route_to</code> accepts query string (Marc Weil)</li>
</ul></li>
<li><p>Internal</p>

<ul>
<li>Added specs for generators using ammeter (Alex Rothenberg)</li>
</ul></li>
<li><p>Bug fixes</p>

<ul>
<li>Fix configuration/integration bug with rails 3.0 (fixed in 3.1) in which
<code>fixure_file_upload</code> reads from <code>ActiveSupport::TestCase.fixture_path</code> and
misses RSpec&#8217;s configuration (David Chelimsky)</li>
<li>Support nested resource in view spec generator (David Chelimsky)</li>
<li>Define <code>primary_key</code> on class generated by <code>mock_model("WithAString")</code>
(David Chelimsky)</li>
</ul></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/10/16/rspec-270-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Avoid stubbing methods invoked by a framework</title>
		<link>http://blog.davidchelimsky.net/2011/09/22/avoid-stubbing-methods-invoked-by-a-framework/</link>
		<comments>http://blog.davidchelimsky.net/2011/09/22/avoid-stubbing-methods-invoked-by-a-framework/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 23:23:55 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<category><![CDATA[RSpec]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Test Doubles]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2826</guid>
		<description><![CDATA[In a github issue reported to
the rspec-mocks project, the user had
run into a problem in a Rails&#8217; controller spec in which an RSpec-generated test
double didn&#8217;t behave as expected. What follows is an edited version of the
issue and my response, with the hope that it reaches a wider audience and/or
sparks some conversation.

The reported problem: ActiveSupport::JSON::Encoding::CircularReferenceError using [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="https://github.com/rspec/rspec-mocks/issues/78">github issue</a> reported to
the <a href="https://github.com/rspec/rspec-mocks">rspec-mocks</a> project, the user had
run into a problem in a Rails&#8217; controller spec in which an RSpec-generated test
double didn&#8217;t behave as expected. What follows is an edited version of the
issue and my response, with the hope that it reaches a wider audience and/or
sparks some conversation.</p>

<h2>The reported problem: ActiveSupport::JSON::Encoding::CircularReferenceError using doubles</h2>

<p>This spec &#8230;</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'spec_helper'</span>
&nbsp;
describe ListsController <span style="color:#9966CC; font-weight:bold;">do</span>
  let<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:list</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> double<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;List&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
  describe <span style="color:#996600;">&quot;GET 'index'&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    let<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:expected</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#123;</span>id: <span style="color:#996600;">&quot;1&quot;</span>, name: <span style="color:#996600;">&quot;test&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
    before <span style="color:#9966CC; font-weight:bold;">do</span>
      list.<span style="color:#9900CC;">stub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;1&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
      list.<span style="color:#9900CC;">stub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;test&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
      List.<span style="color:#9900CC;">stub</span><span style="color:#006600; font-weight:bold;">&#40;</span>:<span style="color:#CC0066; font-weight:bold;">select</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> list <span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    it <span style="color:#996600;">&quot;should return the list of lists&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      get <span style="color:#ff3333; font-weight:bold;">:index</span>, <span style="color:#CC0066; font-weight:bold;">format</span>: <span style="color:#ff3333; font-weight:bold;">:json</span>
      response.<span style="color:#9900CC;">body</span>.<span style="color:#9900CC;">should</span> == expected.<span style="color:#9900CC;">to_json</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>&#8230; plus this implementation &#8230;</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> ListsController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  respond_to <span style="color:#ff3333; font-weight:bold;">:json</span>
&nbsp;
  expose<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:lists</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> List.<span style="color:#CC0066; font-weight:bold;">select</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;id, name&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> index
    respond_with<span style="color:#006600; font-weight:bold;">&#40;</span>lists<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>&#8230; produces this failure:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">  Failure/Error: get :index, format: :json
     ActiveSupport::JSON::Encoding::CircularReferenceError:
       object references itself</pre></div></div>


<h2>The deeper problem: this is a great example of when <em>not</em> to use stubs.</h2>

<p>Here&#8217;s why: there are three incorrect assumptions hiding behind the stubs!</p>

<ol>
<li><code>select</code> takes an Array: <code>List.select(["id","name"])</code>, but the example stubs it incorrectly.</li>
<li>the id is numeric, but the example uses String.</li>
<li>the json is wrapped: <code>{"list":{"id":1,"name":"test"}}</code>, but the example doesn&#8217;t wrap it.</li>
</ol>

<p>Even if the stubs were properly aligned with reality, the reason for the error
is that <code>respond_with(lists)</code> eventually calls <code>as_json</code> on the <code>list</code> object,
which, in this example, is an RSpec double that doesn&#8217;t implement <code>as_json</code>.
We need to either use a <code>stub_model</code> (which does implement <code>as_json</code>), or
explicitly stub it in the example:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">list.<span style="color:#9900CC;">stub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:as_json</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> list: <span style="color:#006600; font-weight:bold;">&#123;</span>id: <span style="color:#006666;">1</span>, name: <span style="color:#996600;">&quot;test&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>


<p>But I&#8217;d avoid stubs altogether in this case. Stubs are great for well defined
(and understood) public APIs <em>which are invoked by the code being specified</em>.
In this case, we&#8217;re stubbing an API (<code>as_json</code>) that is invoked by the Rails
framework, not the code being specified. If the Rails framework ever changes
how it renders json, this example would continue to pass, but it would be a
false positive.</p>

<h2>One possible remedy</h2>

<h4>Here&#8217;s how I&#8217;d approach this outside-in (based on my own flow, design preferences, and target outcomes. YMMV.)</h4>

<p>Start with a request spec:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'spec_helper'</span>
&nbsp;
describe <span style="color:#996600;">&quot;Lists&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  describe <span style="color:#996600;">&quot;GET 'index.json'&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    it <span style="color:#996600;">&quot;returns the list of lists&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      list = List.<span style="color:#9900CC;">create</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>name: <span style="color:#996600;">&quot;test&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      get <span style="color:#996600;">&quot;/lists.json&quot;</span>
      response.<span style="color:#9900CC;">body</span>.<span style="color:#9900CC;">should</span> == <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#123;</span>list: <span style="color:#006600; font-weight:bold;">&#123;</span>id: list.<span style="color:#9900CC;">id</span>, name: <span style="color:#996600;">&quot;test&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_json</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>This shows exactly what to expect, so when working on clients we can refer
directly to this without having to dig into internals.</p>

<p>Run this and it fails with <code>uninitialized constant List</code>, so generate the list
resource:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">rails generate resource list name:string
rake db:migrate
rake db:test:prepare</pre></div></div>


<p>Run it again and it fails with <code>ActionView::MissingTemplate</code>. Now we have a
couple of choices. The purist view says &#8220;write a controller spec&#8221;, but some
people say controller specs are unnecessary if there are already request specs
(or cukes) as they just add duplication.</p>

<p>For me, the answer depends upon the complexity of the requirement as it
compares to what we get for free from Rails. In this case, the only difference
between the requirement and what Rails gives us for free is that we constrain
the fields to <code>id</code> and <code>name</code> This is something we can implement in the model,
so I&#8217;d just implement this very simple controller code and move on:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> ListsController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  respond_to <span style="color:#ff3333; font-weight:bold;">:json</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> index
    respond_with List.<span style="color:#9900CC;">all</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Now the request spec fails with:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">expected: &quot;[{\&quot;list\&quot;:{\&quot;id\&quot;:1,\&quot;name\&quot;:\&quot;test\&quot;}}]&quot;
     got: &quot;[{\&quot;list\&quot;:{\&quot;created_at\&quot;:\&quot;2011-08-27T14:56:19Z\&quot;,\&quot;id\&quot;:1,\&quot;name\&quot;:\&quot;test\&quot;,\&quot;updated_at\&quot;:\&quot;2011-08-27T14:56:19Z\&quot;}}]&quot;</pre></div></div>


<p>We&#8217;re getting more key/value pairs than we want. I want the model responsible
for constraining the keys in the json (Rails implements json transformations in
the context of the model, so why shouldn&#8217;t we?), so I&#8217;d add a model spec:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'spec_helper'</span>
&nbsp;
describe List <span style="color:#9966CC; font-weight:bold;">do</span>
  describe <span style="color:#996600;">&quot;#as_json&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    it <span style="color:#996600;">&quot;constrains keys to id and name&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      list = List.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;things&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      list.<span style="color:#9900CC;">as_json</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'list'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">keys</span>.<span style="color:#9900CC;">should</span> eq<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#91;</span>id name<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>This fails with:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">expected [&quot;id&quot;, &quot;name&quot;]
     got [&quot;created_at&quot;, &quot;name&quot;, &quot;updated_at&quot;]</pre></div></div>


<p>I expect to see <code>created_at</code> and <code>updated_at</code>, but I&#8217;m surprised (initially) to
see that <code>id</code> is missing. Thinking this through, it makes sense because the
example generates the <code>list</code> using <code>new</code>, so no <code>id</code> is generated.  To get <code>id</code>
to show up in the list of keys, we can use <code>create</code> instead of <code>new</code>, or we can
explicitly set it. I&#8217;m going to go with setting the id explicitly to avoid the
db hit, accepting the self-imposed leaky abstraction. It&#8217;s all trade-offs.</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">it <span style="color:#996600;">&quot;constrains fields to id and name&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  list = List.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;things&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  list.<span style="color:#9900CC;">id</span> = <span style="color:#006666;">37</span>
  list.<span style="color:#9900CC;">as_json</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'list'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">keys</span>.<span style="color:#9900CC;">should</span> eq<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#91;</span>id name<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Now it fails with:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">expected [&quot;id&quot;, &quot;name&quot;]
     got [&quot;created_at&quot;, &quot;id&quot;, &quot;name&quot;, &quot;updated_at&quot;]</pre></div></div>


<p>Now we can implement the constraint:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> List <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> as_json
    <span style="color:#9966CC; font-weight:bold;">super</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span> only: <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#91;</span>id name<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Now the model spec passes, but the request spec fails with:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">ArgumentError:
  wrong number of arguments (1 for 0)</pre></div></div>


<p>This is because the <code>as_json</code> implementation fails to honor the <a href="http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html#method-i-as_json">Rails
API</a>:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">as_json<span style="color:#006600; font-weight:bold;">&#40;</span>options = <span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>


<p><code>as_json</code> is called by the Rails framework with an options hash. Had we done
this without the request spec and weren&#8217;t aware of this information, we&#8217;d have
a bunch of passing specs but the app would blow up. Hooray for testing at
multiple levels!</p>

<p>So we add a new example to the model spec:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">it <span style="color:#996600;">&quot;honors the submitted options hash&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  list = List.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;things&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  list.<span style="color:#9900CC;">id</span> = 37
  list.<span style="color:#9900CC;">as_json</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:only</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:name</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'list'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">keys</span>.<span style="color:#9900CC;">should</span> eq<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#91;</span>name<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>This fails with <code>wrong number of arguments (1 for 0)</code> as well, so now we adjust
the model implementation:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> as_json<span style="color:#006600; font-weight:bold;">&#40;</span>opts=<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">super</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span> only: <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#91;</span>id name<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span>opts<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Now the model spec passes again, and so does the request spec! DONE!</p>

<p>The result is a very nice balance of clarity, speed (in spite of the one db hit
in the request spec) and flexibility. Any new endpoints we add will get the
same json representation because it is expressed in the model (heeding the
principle of least surprise). The model spec not only specifies how the model
should represent itself as json, but it helps to explain how the rails
framework uses the model. All of this with no stubbing at all, and especially
no stubbing of APIs our code isn&#8217;t invoking.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/09/22/avoid-stubbing-methods-invoked-by-a-framework/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Stop typing &#8220;bundle exec&#8221;</title>
		<link>http://blog.davidchelimsky.net/2011/07/18/stop-typing-bundle-exec/</link>
		<comments>http://blog.davidchelimsky.net/2011/07/18/stop-typing-bundle-exec/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 13:15:26 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2818</guid>
		<description><![CDATA[Bundler serves two primary purposes:


it helps you to install the correct gem versions
it constrains the load path to the correct gem versions at runtime


Assuming you&#8217;re using Bundler to constrain your runtime environment (which you
are if you&#8217;re using Rails 3 defaults), then you are likely prefixing most shell
commands with bundle exec.

We interrupt this post for an [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://gembundler.com/">Bundler</a> serves two primary purposes:</p>

<ol>
<li>it helps you to install the correct gem versions</li>
<li>it constrains the load path to the correct gem versions at runtime</li>
</ol>

<p>Assuming you&#8217;re using Bundler to constrain your runtime environment (which you
are if you&#8217;re using Rails 3 defaults), then you are likely prefixing most shell
commands with <code>bundle exec</code>.</p>

<h3>We interrupt this post for an important update:</h3>

<p>Two important pieces of information in the comments:</p>

<ol>
<li>Prepending <code>./bin</code> to your path exposes a serious security risk. Proceed with caution.</li>
<li><a href="http://beginrescueend.com/integration/bundler/">rvm >= 1.6.18 + bundler >= 1.0.5 removes the need for this altogether</a>.</li>
</ol>

<h3>We now return you to our regularly scheduled post:</h3>

<p>Here&#8217;s a little tip to help save you the prefix, without adding any aliases or
functions to your environment.</p>

<p><pre>
bundle install --binstubs
export PATH=./bin:$PATH
</pre></p>

<p><code>bundle install --binstubs</code> creates a <code>bin</code> directory at the root of your
project, and fills it with Bundler-enabled wrappers for all of the executables
installed by the gems listed in your Gemfile. This enables you to type
<code>bin/rake</code> instead of <code>bundle exec rake</code>, for example, ensuring that the
correct version of rake is loaded.</p>

<p>Now prepend <code>./bin</code> to your path and you can just type <code>rake</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/07/18/stop-typing-bundle-exec/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-core-2.6.4 is released!</title>
		<link>http://blog.davidchelimsky.net/2011/06/06/rspec-core-264-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2011/06/06/rspec-core-264-is-released/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 11:47:22 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[RSpec]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2814</guid>
		<description><![CDATA[full changelog


Bug fixes


Support exclusion filters in DRb. (Yann Lugrin)
Fix &#8211;example escaping when run over DRb. (Elliot Winkler)
Use standard ANSI codes for color formatting so colors work in a wider set
of color schemes.


]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/rspec/rspec-core/compare/v2.6.3...v2.6.4">full changelog</a></p>

<ul>
<li>Bug fixes

<ul>
<li>Support exclusion filters in DRb. (Yann Lugrin)</li>
<li>Fix &#8211;example escaping when run over DRb. (Elliot Winkler)</li>
<li>Use standard ANSI codes for color formatting so colors work in a wider set
of color schemes.</li>
</ul></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/06/06/rspec-core-264-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rake 0.9 and gem version constraints</title>
		<link>http://blog.davidchelimsky.net/2011/05/28/rake-09-and-gem-version-constraints/</link>
		<comments>http://blog.davidchelimsky.net/2011/05/28/rake-09-and-gem-version-constraints/#comments</comments>
		<pubDate>Sat, 28 May 2011 22:03:57 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2799</guid>
		<description><![CDATA[There's been some confusion surrounding the rake-0.9.0 release, and I'd like to
take the opportunity to clarify some things and hopefully draw attention to gem
versioning policies and their implications for everybody in the Ruby community.

First, there are three distinct issues related to the rake release:]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been some confusion surrounding the rake-0.9.0 release, and I&#8217;d like to
take the opportunity to clarify some things and hopefully draw attention to gem
versioning policies and their implications for everybody in the Ruby community.</p>

<p>First, there are three distinct issues related to the rake release:</p>

<h3>1. Backward-incompatibility</h3>

<p>Rake 0.9 includes backward-incompatible changes. Per the
<a href="https://github.com/jimweirich/rake/blob/master/CHANGES">changelog</a>:</p>

<pre><code>## Version 0.9.0

* *Incompatible* *change*: Rake DSL commands ('task', 'file', etc.)  are
  no longer private methods in Object.  If you need to call 'task :xzy' inside
  your class, include Rake::DSL into the class.  The DSL is still available at
  the top level scope (via the top level object which extends Rake::DSL).
</code></pre>

<p>This conflicts with the way Rails, among others, uses Rake, among others.  The
workaround recommended by <a href="https://twitter.com/dhh">@dhh</a> is to constrain the
rake version in the Gemfiles in your Rails applications:</p>

<pre><code>gem "rake", "0.8.7"
</code></pre>

<p>This is a perfectly fine short term solution to keep your applications running,
but it won&#8217;t be long before a gem that your Rails application depends on,
either directly or through the transitive property of dependencies, is going to
specify any of:</p>

<pre><code>gemspec.add_dependency 'rake', '0.9.0'
gemspec.add_dependency 'rake', '&gt;= 0.9.0'
gemspec.add_dependency 'rake', '~&gt; 0.9.0'
</code></pre>

<p>When that happens, you&#8217;ll need to loosen the constraint in your app if you want
to upgrade any of the gems downstream from the gem that introduces this
dependency. This is not a big deal because you can control the situation
directly in your own Gemfile in your own application.</p>

<h3>Libraries are not applications</h3>

<p>This advice should <em>not</em>, however, be applied to any gems that depend on Rake.
Let&#8217;s say you&#8217;re using two gems that both provide Rake tasks and therefore
depend on the rake gem. At some point the maintainer of gem aaa changes the
constraint to <code>"= 0.8.7"</code>, and the maintainer of gem bbb keeps a looser
constraint: either <code>"&gt;= 0.8.7"</code> or <code>"~&gt; 0.8.7"</code>. You upgrade to the new version
of aaa and everything is fine because both constraints are satisfied by
rake-0.8.7.</p>

<p>A little while down the road, the constraint in bbb changes to <code>"~&gt; 0.9.0"</code>. At
this point you are unable to have the newest versions of aaa and bbb in the
same application. This may not seem like a big deal because you can choose to
not upgrade bbb at this point, but the further upstream the dependency (i.e.
aaa depends on bbb, which depends on ccc), the more likely you are to be
constrained in your upgrade choices.</p>

<p>In short, if you are maintaining a gem that applications or other gems depend
on, you are doing end users a disservice by locking down any upstream
dependency at one and only one version number.</p>

<p>Now here&#8217;s the catch: while some gem maintainers follow some sort of standard
versioning and/or release policy, there are many that don&#8217;t.  If you put in a
looser version constraint on a gem whose maintainers introduce breaking changes
in patch releases, you are also doing your users a disservice. More on this
later.</p>

<h3>2. Rake is used to run tasks that depend on Rake</h3>

<p>Perhaps you&#8217;ve run into this interaction (or similar):</p>

<pre><code>$ bundle install
$ rake db:migrate
You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7. Consider using bundle exec.
</code></pre>

<p>In this case, the application has an explicit dependency on rake-0.8.7, but
rake-0.9.0 is installed in the shell environment. When you type <code>rake xxx</code>,
Rubygems activates the 0.9.0 version (the newest version installed), and then
tries to activate 0.8.7 when the app is running.</p>

<p>This is a catch 22 that we&#8217;ve been lulled into ignoring by the mere fact that
there have not been any rake releases for a couple of years (rake-0.9.0 was
released 2 years and 5 days after rake-0.8.7). We all expect to type <code>rake xxx</code>
and have it just work. Why not? It&#8217;s worked thus far, right?</p>

<p>During the two years of rake-0.8.7, Bundler was born. You may remember that the
Bundler team took a lot of heat during its early days. One of the complaints I
remember was that people didn&#8217;t want to have to type <code>bundle exec</code> to run a
rake task. The result is that pretty much all apps that use Bundler and Rake
have this in their Rakefiles:</p>

<pre><code>require 'rubygems'
require 'bundler'
Bundler.setup
</code></pre>

<p>This enables us to type <code>rake xxx</code> and let Bundler manage loading every other
gem besides rake, which is already loaded by Rubygems. So now when we find both
rake-0.8.7 and 0.9.0 in our gem environment, and the app we&#8217;re working with depends
explicitly on 0.8.7, we have (at least) three options:</p>

<h4>a. Tell bundler to install the rake command PROJECT_ROOT/bin</h4>

<pre><code>bundle install --binstubs
</code></pre>

<p>Now you can run this</p>

<pre><code>bin/rake xxx
</code></pre>

<h4>b. Explicitly run bundle exec</h4>

<pre><code>bundle exec rake
</code></pre>

<p>In either of the first two options, Bundler controls the activation of the rake
gem for you, which allows it to put the correct version on the <code>$LOAD_PATH</code>.</p>

<h4>c. Just remove 0.9 from the current gem environment</h4>

<pre><code>gem uninstall rake
</code></pre>

<p>This only works if you&#8217;re using an isolated gemset for the current project
(e.g. using rvm) or you simply don&#8217;t need rake-0.9.0 on your system. It also is
not a very reliable way to deal with this if you have any sort of automated
build or deployment system that is installing gems into a shared gem
environment on the build or production servers.</p>

<p>The real problem here is not that we have to type a different command on the
command line. We humans can adapt and get used to doing that. The deeper
problem is that there are countless automation scripts out in the wild that
depend on <code>rake xxx</code>. In order to support both versions of Rake, they will all
have to be changed to use one of the first two solutions noted above. The cost
of this is no small chunk of change, but it is nobody&#8217;s fault but our own for
failing to recognize the cyclical nature of using a versioned tool to run
applications that might require a different version.</p>

<h3>3. Not all gems expose their dependencies in a way that Bundler or Rubygems can control them</h3>

<p>On my team at DRW, we tried to constrain our rake dependencies to 0.8.7 as a
temporary measure, but each time we installed into a new gem environment we
found that rake-0.9.0 was being installed. It turned out that a gem we depended
on was installing rake through a back door, and with no version constraint at
all.  The result was that neither Bundler nor Rubygems had any control over
this installation relative to our application (Bundler told Rubygems to install
this gem, and this gem silently installed rake). And, to make things more
confusing, Bundler reported that it was installing rake-0.8.7 and said nothing
about 0.9.0.</p>

<p>The maintainer of that gem released new versions right away, so that issue is now
resolved, but it&#8217;s entirely possible that other gems you&#8217;re using are doing the
same (or similar). Just something to keep your eye out for.</p>

<h3>What can we learn from all of this?</h3>

<p>One issue this exposes is a lack of common understanding and agreement about
how to manage releases and dependencies. The <a href="http://docs.rubygems.org/read/chapter/7">Rubygems Rational
Versioning</a> policy and
<a href="http://semver.org">Semantic Versioning</a> are both very sound approaches that share a common
scheme for version numbers:</p>

<p>A version has three parts: major, minor, and patch.  For example, release 3.0.0
is a major release because the first number was incremented from 2 to 3, 3.2.0
is a minor release because the second number was incremented from 1 to 2, and
3.2.1 is a patch release because the third number was incremented from 0 to 1.
Both specs state the following:</p>

<ol>
<li>Patch releases (3.2.1) should only include bug fixes and internal implementation changes.</li>
<li>Minor releases (3.2.0) can include bug fixes, internal changes, and new features, but no breaking changes.</li>
<li>Major releases (3.0.0) can include bug fixes, internal changes, new features, and breaking changes.</li>
</ol>

<p>If everybody adhered to either policy, we&#8217;d all be able to declare our gem dependencies like this:</p>

<pre><code>spec.add_dependency "foo", "&gt;= 2.3", "&lt; 3.0"
</code></pre>

<p>&#8230; or the following, oft misunderstood, shortcut for same:</p>

<pre><code>spec.add_dependency "foo", "~&gt; 2.3"
</code></pre>

<p>This tells Rubygems to install the newest version that is >= 2.3.0, trusting
that no version 2.y.x will include breaking changes.</p>

<h3>RSpec</h3>

<p>I&#8217;ll confess that I didn&#8217;t adhere to either approach with RSpec until the
rspec-2.0.0 release, last October. I knowingly introduced breaking changes in
the 1.x series and RSpec likely lost the confidence of a fair sum of users
during that time.</p>

<p>The good news, vis a vis RSpec, is that we&#8217;ve been following Rubygems Rational
Versioning since the rspec-2.0 release.  While we&#8217;ve had a couple of
regressions in the process (followed swiftly by patch releases that addressed
them), there has been only one intentionally breaking change, and that was
related to integration with another library. That change was announced,
documented, and I don&#8217;t recall seeing any issues reported related to it.</p>

<p>We&#8217;re not doing SemVer yet because it is more strict than RRV, and RSpec does
not currently meet all of its criteria. I do hope, however, to have RSpec on
SemVer before the year is out.</p>

<h3>This all sounds great, but &#8230;</h3>

<p>&#8230; the reality is that getting every gem developer to commit to RRV or SemVer
is very unlikely. What those of us who do <em>can</em> do, however, is try to provide
a balance of flexibility and safety when we declare upstream dependencies. The
<a href="https://rubygems.org/gems/rspec-expectations">rspec-expectations</a> gem, for
example, declares the following runtime dependency:</p>

<pre><code>diff-lcs ~&gt; 1.1.2
</code></pre>

<p>This expresses an opinion that it is safe for your application (that depends on
rspec-expectations) to depend on any 1.1.x version of diff-lcs greater than or
equal to 1.1.2, but it is not safe to depend on 1.2.0.  While this provides a
high degree of safety, it also provides low flexibility: if any other gem your
app depends on depends on diff-lcs-1.2 in the future (not likely, since 1.1.2
was released in 2004, but that&#8217;s besides the point), you won&#8217;t be able to use
it with the current release of rspec-expectations, even if the diff-lcs-2.2
release does not include any breaking changes.</p>

<p>If diff-lcs was still under regular maintenance, and it&#8217;s maintainers were
committed to RRV or SemVer, then rspec-expectations would be able to use this
dependency instead:</p>

<pre><code>diff-lcs ~&gt; 1.2
</code></pre>

<p>This would provide significantly more flexibility in rspec-expectations&#8217;s
ability to play nice with other gems that also depend on diff-lcs in the same
applciation over a longer period of time.</p>

<p>Note that every gem page on <a href="http://rubygems.org">rubygems.org</a> now includes a
recommendation to use the pessamistic constraint using a three-part version
number (e.g. <code>rake ~&gt; 0.9.0</code>). As just discussed, this provides safety, but
lacks long term flexibility.</p>

<h3>Depending on rake</h3>

<p>So what should maintainers of gems that depend on rake do now? The likelihood
is that some end users will constrain their applications to rake <code>0.8.7</code>, and
others will constrain them to <code>= 0.9.0</code>, <code>~&gt; 0.9.0</code>, or <code>&gt;= 0.9.0</code>. Unless Jim
Weirich announces that rake will follow RRV or SemVer, we have to allow for the
possibility that rake <code>0.10.0</code> will introduce new breaking changes. In this
case, I think the responsible thing to do is make sure our gems work with both
rake-0.8 and 0.9, and specify the dependency like this:</p>

<pre><code>spec.add_runtime_dependency 'rake', '&gt;= 0.8.7', '&lt; 0.10'
</code></pre>

<p>Trusting that no rake 0.9.x version will introduce breaking changes, this
provides the greatest flexibility to end users without exposing them to the
risk of breaking changes in rake-0.10.0.</p>

<h3>Feedback</h3>

<p>I&#8217;m curious to hear what you think about all of this. Do you think this all
makes sense?  Do you think I&#8217;m over or understating the importance, complexity,
or severity of these issues?  Do you have a different approach to recommend in
moving forward?  I look forward to your feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/05/28/rake-09-and-gem-version-constraints/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-rails-2.6.1 is released!</title>
		<link>http://blog.davidchelimsky.net/2011/05/25/rspec-rails-261-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2011/05/25/rspec-rails-261-is-released/#comments</comments>
		<pubDate>Thu, 26 May 2011 02:24:04 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[RSpec]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2793</guid>
		<description><![CDATA[This is a bug fix release that is compatible with the rails-3.0.0 to 3.0.7, 3.0.8.rc1, and 3.1.0.rc1 (it is mostly, but not fully compatible with but not rails-3.1.0.beta1).

rspec-rails-2.6.1 / 2011-05-25

full changelog


Bug fixes


fix controller specs with anonymous controllers with around filters
exclude spec directory from rcov metrics (Rodrigo Navarro)
guard against calling prerequisites on nil default rake task [...]]]></description>
			<content:encoded><![CDATA[<p>This is a bug fix release that is compatible with the rails-3.0.0 to 3.0.7, 3.0.8.rc1, and 3.1.0.rc1 (it is mostly, but not fully compatible with but not rails-3.1.0.beta1).</p>

<h3>rspec-rails-2.6.1 / 2011-05-25</h3>

<p><a href="http://github.com/rspec/rspec-rails/compare/v2.6.0...v2.6.1">full changelog</a></p>

<ul>
<li>Bug fixes

<ul>
<li>fix controller specs with anonymous controllers with around filters</li>
<li>exclude spec directory from rcov metrics (Rodrigo Navarro)</li>
<li>guard against calling prerequisites on nil default rake task (Jack Dempsey)</li>
</ul></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2011/05/25/rspec-rails-261-is-released/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

