<?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>Wed, 16 May 2012 01:16:04 +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>Spec smell: explicit use of subject</title>
		<link>http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/</link>
		<comments>http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/#comments</comments>
		<pubDate>Mon, 14 May 2012 02:13:46 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2918</guid>
		<description><![CDATA[
  .update { color: red }
  .gist { font-size: 0.8em }


TL;DR

Explicit use of the &#8220;subject&#8221; abstraction is a code smell, and should be
refactored to use a more intention revealing name whenever possible.

One liners

rspec-core supports a one-liner syntax to reduce the noise of common
requirements like validations:



Without support for this syntax, the same example might [...]]]></description>
			<content:encoded><![CDATA[<p><style>
  .update { color: red }
  .gist { font-size: 0.8em }
</style></p>

<h2>TL;DR</h2>

<p>Explicit use of the &#8220;subject&#8221; abstraction is a code smell, and should be
refactored to use a more intention revealing name whenever possible.</p>

<h2>One liners</h2>

<p>rspec-core supports a one-liner syntax to reduce the noise of common
requirements like validations:</p>

<script src="https://gist.github.com/2691548.js?file=example-1.rb"></script>

<p>Without support for this syntax, the same example might look like this:</p>

<script src="https://gist.github.com/2691548.js?file=example-2.rb"></script>

<p>The benefit of this more verbose example is that it we can read it and
understand all the parts right away: an object is initialized and assigned to a
local variable, then that variable is used for an expectation.</p>

<p>The benefit of the one-liner is that it&#8217;s terse and expressive, but that comes
at a cost: you can&#8217;t see what the expectation is being evaluated against, so you
have to understand some underlying mechanics in order to isolate/understand a
failure.</p>

<h2>The <code>subject</code> abstraction</h2>

<p>Behind the scenes, the one-liner uses a &#8220;subject&#8221; abstraction supported by two
methods named <code>subject</code>. One is a class method on <code>ExampleGroup</code>, used to
declare the &#8220;subject&#8221; of all of the examples in the group:</p>

<script src="https://gist.github.com/2691548.js?file=example-3.rb"></script>

<p>The other is an instance method on <code>ExampleGroup</code>. The first time it is called
within an example the block passed to the class&#8217; <code>subject</code> method is evaluated
and its result memoized, returning the same value from that and each subsequent
<code>subject</code> call:</p>

<script src="https://gist.github.com/2691548.js?file=example-4.rb"></script>

<p>Here is what they look like together:</p>

<script src="https://gist.github.com/2691548.js?file=example-5.rb"></script>

<p>The problem with this example is that the word &#8220;subject&#8221; is not very intention
revealing.  That might not appear problematic in this small example because you
can see the declaration on line 3 and the reference on line 6.  But when this
group grows to where you have to scroll up from the reference to find the
declaration, the generic nature of the word &#8220;subject&#8221; becomes a hinderance to
understanding and slows you down.</p>

<p>In this case, we&#8217;d be better served by using a method (or a <code>let</code> declaration)
with an intention revealing name:</p>

<script src="https://gist.github.com/2691548.js?file=example-6.rb"></script>

<p>If we can do that, you might wonder why we have &#8220;subject&#8221; at all.  Well, it was
originally designed to never be seen:</p>

<h2>Implicit subject</h2>

<p>Note in the example with <code>subject { Article.new }</code>, that the <code>subject</code> declaration is initializing an
<code>Article</code> with no args.  Since RSpec knows that the first argument to
<code>describe</code> is the <code>Article</code> class, it can store a similar block in the
background as a default, implicit subject declaration, leaving us with:</p>

<script src="https://gist.github.com/2691548.js?file=example-7.rb"></script>

<p>That&#8217;s a little better, but now <code>subject</code> appears out of nowhere in the
example, leaving the reader to wonder where it came from.  To remove the need
for explicitly referencing <code>subject</code>, the example delegates <code>should</code> and
<code>should_not</code> to <code>subject</code> when it is, itself, the receiver:</p>

<script src="https://gist.github.com/2691548.js?file=example-8.rb"></script>

<p>Starting that line with &#8220;should&#8221; seems a bit odd though, so the final step is to
do it all in one line:</p>

<script src="https://gist.github.com/2691548.js?file=example-1.rb"></script>

<p>Now we have a completely implicit subject, and the result reads quite nicely in
both the code and the output when run with <code>--format documentation</code>:</p>

<pre><code>Article
  should validate presence of :title
</code></pre>

<p>We still need to trust that something is doing some work for us but it&#8217;s all
operating at the same level of abstraction, so we don&#8217;t have to try to
interpret half of the functionality.</p>

<h2>Avoid explicit use of <code>subject</code></h2>

<p>Intention revealing names are crucial if you want to be able to quickly scan
and understand code as you navigate around different parts of a system. This is
as true for specs as it is for implementation, and the generic nature of the
word &#8220;subject&#8221; makes it a poor choice when a more intention revealing name can
be used.</p>

<h2>Is an explicit <code>subject</code> ever OK?</h2>

<p>Guidelines are guidelines; YMMV. In general I would recommend that if there is
a reasonable way to use an intention revealing name instead of &#8220;subject&#8221;, you
should. The only use case I can think of in RSpec in which another name can&#8217;t
be used is the one liner syntax:</p>

<script src="https://gist.github.com/2698271.js?file=example-13.rb"></script>

<p>Here we <em>have</em> to use <code>subject</code> because that&#8217;s the only way to tell RSpec where
to send <code>should</code> and <code>should_not</code>. In my opinion, any other explicit appearance
of <code>subject</code> can and should be refactored to use an intention revealing name.</p>

<h2><span class="update">Update 2012-05-15</span></h2>

<p>Based on feedback on this post, I added support for a &#8220;named subject,&#8221; which
lets you reference the declared subject implicitly in one-liners and with an
intention revealing name in standard examples:</p>

<script src="https://gist.github.com/2698271.js?file=example-14.rb"></script>

<p>This will be released with rspec-core-2.11. Keep your eyes out for it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-mocks and rspec-rails-2.10.1 are released!</title>
		<link>http://blog.davidchelimsky.net/2012/05/05/rspec-mocks-and-rspec-rails-2101-are-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/05/05/rspec-mocks-and-rspec-rails-2101-are-released/#comments</comments>
		<pubDate>Sat, 05 May 2012 06:34:08 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2914</guid>
		<description><![CDATA[These are patch releases recommended for anybody who has already upgraded to 2.10.

rspec-mocks-2.10.1

full changelog

Bug fixes


fix regression of edge case behavior


fixed failure of object.should_receive(:message).at_least(0).times.and_return value
fixed failure of object.should_not_receive(:message).and_return value



rspec-rails-2.10.1

full changelog

Bug fixes


fix regression introduced in 2.10.0 that broke integration with Devise

]]></description>
			<content:encoded><![CDATA[<p>These are patch releases recommended for anybody who has already upgraded to 2.10.</p>

<h3>rspec-mocks-2.10.1</h3>

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

<p>Bug fixes</p>

<ul>
<li>fix <a href="https://github.com/rspec/rspec-mocks/issues/132">regression of edge case behavior</a>

<ul>
<li>fixed failure of <code>object.should_receive(:message).at_least(0).times.and_return value</code></li>
<li>fixed failure of <code>object.should_not_receive(:message).and_return value</code></li>
</ul></li>
</ul>

<h3>rspec-rails-2.10.1</h3>

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

<p>Bug fixes</p>

<ul>
<li>fix <a href="https://github.com/rspec/rspec-rails/issues/534">regression introduced in 2.10.0 that broke integration with Devise</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/05/05/rspec-mocks-and-rspec-rails-2101-are-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-2.10 is released!</title>
		<link>http://blog.davidchelimsky.net/2012/05/03/rspec-210-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/05/03/rspec-210-is-released/#comments</comments>
		<pubDate>Fri, 04 May 2012 01:29:34 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2906</guid>
		<description><![CDATA[API Docs (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

Cucumber docs

http://relishapp.com/rspec/rspec-core
http://relishapp.com/rspec/rspec-expectations
http://relishapp.com/rspec/rspec-mocks
http://relishapp.com/rspec/rspec-rails

rspec-core-2.10.0

full changelog

Enhancements


Add prepend_before and append_after hooks (preethiramdev)


intended for extension libs
restores rspec-1 behavior

Reporting of profiled examples (moro)


Report the total amount of time taken for the top slowest examples.
Report what percentage the slowest examples took from the total runtime.



Bug fixes


Properly parse SPEC_OPTS options.
example.description returns the location of the example if there is no
explicit description [...]]]></description>
			<content:encoded><![CDATA[<h3>API Docs (RDoc)</h3>

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

<h3>Cucumber docs</h3>

<p><a href="http://relishapp.com/rspec/rspec-core">http://relishapp.com/rspec/rspec-core</a><br/>
<a href="http://relishapp.com/rspec/rspec-expectations">http://relishapp.com/rspec/rspec-expectations</a><br/>
<a href="http://relishapp.com/rspec/rspec-mocks">http://relishapp.com/rspec/rspec-mocks</a><br/>
<a href="http://relishapp.com/rspec/rspec-rails">http://relishapp.com/rspec/rspec-rails</a></p>

<h3>rspec-core-2.10.0</h3>

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

<p>Enhancements</p>

<ul>
<li>Add <code>prepend_before</code> and <code>append_after</code> hooks (preethiramdev)

<ul>
<li>intended for extension libs</li>
<li>restores rspec-1 behavior</li>
</ul></li>
<li>Reporting of profiled examples (moro)

<ul>
<li>Report the total amount of time taken for the top slowest examples.</li>
<li>Report what percentage the slowest examples took from the total runtime.</li>
</ul></li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Properly parse <code>SPEC_OPTS</code> options.</li>
<li><code>example.description</code> returns the location of the example if there is no
explicit description or matcher-generated description.</li>
<li>RDoc fixes (Grzegorz Świrski)</li>
<li>Do not modify example ancestry when dumping errors (Michael Grosser)</li>
</ul>

<h3>rspec-expectations-2.10.0</h3>

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

<p>Enhancements</p>

<ul>
<li>Add new <code>start_with</code> and <code>end_with</code> matchers (Jeremy Wadsack)</li>
<li>Add new matchers for specifying yields (Myron Marson):

<ul>
<li><code>expect {...}.to yield_control</code></li>
<li><code>expect {...}.to yield_with_args(1, 2, 3)</code></li>
<li><code>expect {...}.to yield_with_no_args</code></li>
<li><code>expect {...}.to yield_successive_args(1, 2, 3)</code></li>
</ul></li>
<li><code>match_unless_raises</code> takes multiple exception args</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Fix <code>be_within</code> matcher to be inclusive of delta.</li>
<li>Fix message-specific specs to pass on Rubinius (John Firebaugh)</li>
</ul>

<h3>rspec-mocks-2.10.0</h3>

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

<p>Bug fixes</p>

<ul>
<li>fail fast when an <code>exactly</code> or <code>at_most</code> expectation is exceeded </li>
</ul>

<h3>rspec-rails-2.10.0</h3>

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

<p>Bug fixes</p>

<ul>
<li><code>render_views</code> called in a spec can now override the config setting. (martinsvalin)</li>
<li>Fix <code>render_views</code> for anonymous controllers on 1.8.7. (hudge, mudge)</li>
<li>Eliminate use of deprecated <code>process_view_paths</code></li>
<li>Fix false negatives when using <code>route_to</code> matcher with <code>should_not</code></li>
<li><code>controller</code> is no longer nil in <code>config.before</code> hooks</li>
<li>Change <code>request.path_parameters</code> keys to symbols to match real Rails
environment (Nathan Broadbent)</li>
<li>Silence deprecation warnings in pre-2.9 generated view specs
(Jonathan del Strother)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/05/03/rspec-210-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-expectations-2.9.1 is released!</title>
		<link>http://blog.davidchelimsky.net/2012/04/03/rspec-expectations-291-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/04/03/rspec-expectations-291-is-released/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 19:18:10 +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=2892</guid>
		<description><![CDATA[This is a bug-fix only release, and is recommended for everybody using rspec-2.9.

full changelog

Bug fixes


Provide a helpful message if the diff between two objects is empty.
Fix bug diffing single strings with multiline strings.
Fix for error with using custom matchers inside other custom matchers
(mirasrael)
Fix using execution context methods in nested DSL matchers (mirasrael)

]]></description>
			<content:encoded><![CDATA[<p>This is a bug-fix only release, and is recommended for everybody using rspec-2.9.</p>

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

<p>Bug fixes</p>

<ul>
<li>Provide a helpful message if the diff between two objects is empty.</li>
<li>Fix bug diffing single strings with multiline strings.</li>
<li>Fix for error with using custom matchers inside other custom matchers
(mirasrael)</li>
<li>Fix using execution context methods in nested DSL matchers (mirasrael)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/04/03/rspec-expectations-291-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-2.9.0 is released!</title>
		<link>http://blog.davidchelimsky.net/2012/03/17/rspec-290-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/03/17/rspec-290-is-released/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 23:10:59 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[RSpec]]></category>

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

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

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2889</guid>
		<description><![CDATA[rspec-2.9.0 is released wtih lots of bug fixes and a few minor feature improvements as well. Enjoy!

rspec-core-2.9.0 / 2012-03-17

full changelog

Enhancements


Support for &#8220;X minutes X seconds&#8221; spec run duration in formatter. (uzzz)
Strip whitespace from group and example names in doc formatter.
Removed spork-0.9 shim. If you&#8217;re using spork-0.8.x, you&#8217;ll need to upgrade
to 0.9.0.


Bug fixes


Restore --full_backtrace option
Ensure that [...]]]></description>
			<content:encoded><![CDATA[<p>rspec-2.9.0 is released wtih lots of bug fixes and a few minor feature improvements as well. Enjoy!</p>

<h3>rspec-core-2.9.0 / 2012-03-17</h3>

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

<p>Enhancements</p>

<ul>
<li>Support for &#8220;X minutes X seconds&#8221; spec run duration in formatter. (uzzz)</li>
<li>Strip whitespace from group and example names in doc formatter.</li>
<li>Removed spork-0.9 shim. If you&#8217;re using spork-0.8.x, you&#8217;ll need to upgrade
to 0.9.0.</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Restore <code>--full_backtrace</code> option</li>
<li>Ensure that values passed to <code>config.filter_run</code> are respected when running
over DRb (using spork).</li>
<li>Ensure shared example groups are reset after a run (as example groups are).</li>
<li>Remove <code>rescue false</code> from calls to filters represented as Procs</li>
<li>Ensure described_class gets the closest constant (pyromaniac)</li>
<li>In &#8220;autorun&#8221;, don&#8217;t run the specs in the at_exit hook if there was an
exception (most likely due to a SyntaxError). (sunaku)</li>
<li>Don&#8217;t extend groups with modules already used to extend ancestor groups.</li>
<li><code>its</code> correctly memoizes nil or false values (Yamada Masaki)</li>
</ul>

<h3>rspec-expectations-2.9.0 / 2012-03-17</h3>

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

<p>Enhancements</p>

<ul>
<li>Move built-in matcher classes to RSpec::Matchers::BuiltIn to reduce pollution
of RSpec::Matchers (which is included in every example).</li>
<li>Autoload files with matcher classes to improve load time.</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Align <code>respond_to?</code> and <code>method_missing</code> in DSL-defined matchers.</li>
<li>Clear out user-defined instance variables between invocations of DSL-defined
matchers.</li>
<li>Dup the instance of a DSL generated matcher so its state is not changed by
subsequent invocations.</li>
<li>Treat expected args consistently across positive and negative expectations
(thanks to Ralf Kistner for the heads up)</li>
</ul>

<h3>rspec-mocks-2.9.0 / 2012-03-17</h3>

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

<p>Enhancements</p>

<ul>
<li>Support order constraints across objects (preethiramdev)</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Allow a <code>as_null_object</code> to be passed to <code>with</code></li>
<li>Pass proc to block passed to stub (Aubrey Rhodes)</li>
<li>Initialize child message expectation args to match any args (#109 -
preethiramdev)</li>
</ul>

<h3>rspec-rails-2.9.0 / 2012-03-17</h3>

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

<p>Enhancments</p>

<ul>
<li>add description method to RouteToMatcher (John Wulff)</li>
<li>Run &#8220;db:test:clone_structure&#8221; instead of &#8220;db:test:prepare&#8221; if Active Record&#8217;s
schema format is &#8220;:sql&#8221;. (Andrey Voronkov)</li>
</ul>

<p>Bug fixes</p>

<ul>
<li><code>mock_model(XXX).as_null_object.unknown_method</code> returns self again</li>
<li>Generated view specs use different IDs for each attribute.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/03/17/rspec-290-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Validations are behavior, associations are structure</title>
		<link>http://blog.davidchelimsky.net/2012/02/12/validations-are-behavior-associations-are-structure/</link>
		<comments>http://blog.davidchelimsky.net/2012/02/12/validations-are-behavior-associations-are-structure/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 22:53:27 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[RSpec]]></category>

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

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2869</guid>
		<description><![CDATA[TL;DR:


TDD is about specifying behavior, not structure.
Validations are behavior, and should be specified.
Associations are structure, and need not be.


Disclaimer

This is my personal viewpoint, though it is not mine alone. YMMV.

Declarations

ActiveRecord provides a declarative interface for describing the structure and
behavior of a model:



While syntactically similar, these two declarations do fundamentally different
things.

Validations are behavior

The validates_presence_of :title declaration [...]]]></description>
			<content:encoded><![CDATA[<h2>TL;DR:</h2>

<ul>
<li>TDD is about specifying behavior, not structure.</li>
<li>Validations are behavior, and should be specified.</li>
<li>Associations are structure, and need not be.</li>
</ul>

<h2>Disclaimer</h2>

<p>This is my personal viewpoint, though it is not mine alone. YMMV.</p>

<h2>Declarations</h2>

<p>ActiveRecord provides a declarative interface for describing the structure and
behavior of a model:</p>

<script src="https://gist.github.com/2359140.js?file=article.rb"></script>

<p>While syntactically similar, these two declarations do fundamentally different
things.</p>

<h2>Validations are behavior</h2>

<p>The <code>validates_presence_of :title</code> declaration changes the behavior of
the <code>save</code> method (and other methods that use <code>save</code>), and should be specified
explicitly. Here&#8217;s an example using shoulda matchers:</p>

<script src="https://gist.github.com/2359140.js?file=validate_presence_of_title.rb"></script>

<p>Even though the matcher&#8217;s name looks just like the likely implementation, the
<code>validate_presence_of</code> matcher specifies that you can not save an <code>Article</code>
without a non-nil value for <code>title</code>, not that the
<code>validates_presence_of(:title)</code> declaration exists.</p>

<h2>Associations are structure</h2>

<p>The <code>has_many</code> declaration exposes a <code>comments</code> method to clients that appears
to be a collection of <code>Comment</code> objects. Doing Test-Driven Development, you
would add this declaration when a specified behavior requires it e.g.</p>

<script src="https://gist.github.com/2359140.js?file=with_comments_by.rb"></script>

<p>This example needs a <code>comments</code> method that returns a collection in order to
pass.  If it doesn&#8217;t exist already (because no other example drove you to add
it), this would be all the motivation you need to introduce it. You don&#8217;t need
an example that says <code>it "should have_many(:comments)"</code>.</p>

<h2>Testing the framework</h2>

<p>Some will argue that we don&#8217;t need to spec validations either, suggesting that
<code>it "should validate_presence_of(:title)"</code> is testing the Rails framework,
which we trust is already tested.  If you think of TDD as a combination of
specification, documentation, and regression testing, then this argument falls
short on the specification/documentation front because the validation is
behavior and, thus, the spec should specify the validation.</p>

<p>Even if you view testing as nothing more than a safety net against regressions,
the argument still falls down in the face of refactoring. If we add a <code>Review</code>
class that also <code>has_many(:comments)</code> and <code>validates_presence_of(:title)</code>, and
we want to extract that behavior to a <code>Postable</code> module that gets included in
both <code>Article</code> and <code>Review</code>, we&#8217;d want a regression test to fail if we failed
to include either of those declarations in the <code>Postable</code> module.</p>

<h2>But declarations are already declarative!</h2>

<p>Another argument is that declarations supply sufficient documentation. e.g. we
can look at <code>rental_contract.rb</code> and know that it validates the presence of
<code>:rentable</code>:</p>

<script src="https://gist.github.com/2359140.js?file=rental_contract.rb"></script>

<p>This is an interesting argument that I think has some merit, but I think it
would require an extraordinarily disciplined and consistent approach of using
declarations 100% of the time in model files such that each one <em>is the spec</em>
for that model, e.g.</p>

<script src="https://gist.github.com/2359140.js?file=contract.rb"></script>

<p>100% may sound extreme, but as soon as we define a single method body in any
one of the models, the declarative nature of the file begins to degrade, and so
does its fitness for the purpose of specification. Plus, if we can only
understand the expected behavior of a model by looking at <em>both</em> its spec and
its implementation, we&#8217;ve lost some of the power of a test-driven approach.</p>

<h2>What do you think?</h2>

<p>Do you spec associations? If so, what value do you get from doing so? If not,
have you run into situations where you wished you had?</p>

<p>Same questions for validations.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/02/12/validations-are-behavior-associations-are-structure/feed/</wfw:commentRss>
		</item>
		<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>
	</channel>
</rss>

