<?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, 28 Nov 2012 17:16:00 +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>Myron Marston and Andy Lindeman are RSpec&#8217;s new project leads</title>
		<link>http://blog.davidchelimsky.net/2012/11/28/myron-marston-and-andy-lindeman-are-rspecs-new-project-leads/</link>
		<comments>http://blog.davidchelimsky.net/2012/11/28/myron-marston-and-andy-lindeman-are-rspecs-new-project-leads/#comments</comments>
		<pubDate>Wed, 28 Nov 2012 17:16:00 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/2012/11/28/myron-marston-and-andy-lindeman-are-rspecs-new-project-leads/</guid>
		<description><![CDATA[TL;DR

Myron Marston is taking over leadership of the RSpec project, and will
be the lead maintainer of the rspec-core, rspec-expectations, and
rspec-mocks gems.

Andy Lindeman is taking over as lead maintainer of the rspec-rails gem.

Myron Marston is RSpec&#8217;s new project lead

Myron Marston has been contributing to RSpec since the ramp up to the
2.0 release in 2010, and joined [...]]]></description>
			<content:encoded><![CDATA[<h2>TL;DR</h2>

<p>Myron Marston is taking over leadership of the RSpec project, and will
be the lead maintainer of the rspec-core, rspec-expectations, and
rspec-mocks gems.</p>

<p>Andy Lindeman is taking over as lead maintainer of the rspec-rails gem.</p>

<h3>Myron Marston is RSpec&#8217;s new project lead</h3>

<p>Myron Marston has been contributing to RSpec since the ramp up to the
2.0 release in 2010, and joined the core team in early 2011. In addition
to solid contributions to the code base, Myron has taken responsibility
for many bug reports, feature requests, pull requests, etc. He also
makes a habit of answering RSpec-related questions on Stack Overflow and
Twitter, and he does this all with thoughtfulness, patience, and
wisdom.</p>

<p>I can&#8217;t think of a better choice to lead the RSpec project, so I invited
him to do so. Thankfully, <a href="http://www.seomoz.org/">SEOmoz</a>, Myron&#8217;s
employer, is allowing him to work on RSpec during work hours, and so he
accepted.</p>

<p>In addition to the overall project lead, Myron will be the lead
maintainer of the rspec-core, rspec-expectations, and rspec-mocks
gems. While Myron uses these core rspec libs every day for his work,
he doesn&#8217;t do much with Rails, so we discussed and agreed that we&#8217;d ask
somebody else to take care of the rspec-rails gem. Enter Andy Lindeman.</p>

<h3>Andy Lindeman is the new lead maintainer of rspec-rails</h3>

<p>Andy Lindeman is the newest addition to the rspec core team. Like Myron,
Andy takes great care in shepherding pull requests and answering
questions in addition to making his own rock solid contributions.  Andy
also writes Rails apps and does Rails training at
<a href="http://bignerdranch.com/">Big Nerd Ranch</a>, which puts him in a great
position to ensure that rspec-rails keeps up with changes in Rails
remains a great choice for developing Rails apps.</p>

<p>Thanks in part to <a href="http://bignerdranch.com/">Big Nerd Ranch</a> for their
support of Andy&#8217;s work on RSpec, Andy has agreed to take the lead on
rspec-rails.</p>

<h3>As for me &#8230;</h3>

<p>When Dave Astels introduced Steven Baker&#8217;s new RSpec library to me back
in 2005, I started submitting patches, Steven gave me commit rights and,
a year later, he decided to move on to other work and offered me
leadership of the project.  I was overjoyed to accept.</p>

<p>In those days, I was teaching TDD/Refactoring courses for Object
Mentor. I was encouraged to work on OSS in my bench time, and I was
particularly interested in tools that helped to promote the
documentation and design aspects of TDD. RSpec and some of the early
definitions/discussions of BDD (&#8221;it&#8217;s all behavior!&#8221;) fit perfectly into
my thinking and my world.</p>

<p>After I left Object Mentor, RSpec was part of my day to day work on Ruby
applications, but most of my work on its maintenance moved to my spare
time. This was fine at first, as I had the support of employers and
family, but I found myself doing less and less of pretty much everything
else that I enjoy and learn from.</p>

<p>Back in June, I joined a project team at DRW Trading that deals in a lot
of Clojure and almost no Ruby.  In the roughly 6 months since, I&#8217;ve been
learning a new domain, a new language, new programming models, and even
a new text editor. I consider myself extraordinarily fortunate to be
able to learn all of these new things, but I&#8217;ve found myself less and
less able to balance my work on RSpec with my job and with everything
else I want to do.</p>

<p>And so, it is time.</p>

<p>Of course, I&#8217;ll continue to contribute to the project and surrounding
conversation, and I look forward to seeing all my friends in the
community at assorted conferences in the coming year(s). I&#8217;ll just
be arriving without my RSpec Lead hat on.</p>

<p>Thank you to Steven Baker for handing me the wheel, and thank you to
everybody who has participated in the project and all RSpec users for
your support over these 6+ years. It&#8217;s been a great honor and a great
pleasure.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/11/28/myron-marston-and-andy-lindeman-are-rspecs-new-project-leads/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-2.12 is released</title>
		<link>http://blog.davidchelimsky.net/2012/11/12/rspec-212-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/11/12/rspec-212-is-released/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 04:37:04 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

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

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2949</guid>
		<description><![CDATA[rspec-2.12 is a minor release (per SemVer), which
includes numerous enhancements and bug fixes. It is fully backward compatible
with previous rspec-2 releases and is a recommended upgrade for all users.

Thanks to all who contributed. Special thanks to Myron Marston and Andy
Lindeman for their personal contributions to the code as well as a great job
shepherding pull requests [...]]]></description>
			<content:encoded><![CDATA[<p>rspec-2.12 is a minor release (per <a href="http://semver.org/">SemVer</a>), which
includes numerous enhancements and bug fixes. It is fully backward compatible
with previous rspec-2 releases and is a recommended upgrade for all users.</p>

<p>Thanks to all who contributed. Special thanks to Myron Marston and Andy
Lindeman for their personal contributions to the code as well as a great job
shepherding pull requests from several new contributors.</p>

<p>UPDATE: If you&#8217;re an rspec/rails/capybara user, be sure to read <a href="http://alindeman.github.com/2012/11/11/rspec-rails-and-capybara-2.0-what-you-need-to-know.html">Andy Lindeman&#8217;s blog post on Capybara-2.0 and rspec-rails</a>.</p>

<h2>Docs</h2>

<h3>RDoc</h3>

<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>

<h3>Cucumber features</h3>

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

<h2>Release notes</h2>

<h3>rspec-core-2.12.0</h3>

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

<p>Enhancements</p>

<ul>
<li>Add support for custom ordering strategies for groups and examples.
(Myron Marston)</li>
<li>JSON Formatter (Alex Chaffee)</li>
<li>Refactor rake task internals (Sam Phippen)</li>
<li>Refactor HtmlFormatter (Pete Hodgson)</li>
<li>Autotest supports a path to Ruby that contains spaces (dsisnero)</li>
<li>Provide a helpful warning when a shared example group is redefined.
(Mark Burns).</li>
<li><code>--default_path</code> can be specified as <code>--default-path</code>. <code>--line_number</code> can be
specified as <code>--line-number</code>. Hyphens are more idiomatic command line argument
separators (Sam Phippen).</li>
<li>A more useful error message is shown when an invalid command line option is
used (Jordi Polo).</li>
<li>Add <code>format_docstrings { |str| }</code> config option. It can be used to
apply formatting rules to example group and example docstrings.
(Alex Tan)</li>
<li>Add support for an <code>.rspec-local</code> options file. This is intended to
allow individual developers to set options in a git-ignored file that
override the common project options in <code>.rspec</code>. (Sam Phippen)</li>
<li>Support for mocha 0.13.0. (Andy Lindeman)</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Remove override of <code>ExampleGroup#ancestors</code>. This is a core ruby method that
RSpec shouldn&#8217;t override. Instead, define <code>ExampleGroup#parent_groups</code>. (Myron
Marston)</li>
<li>Limit monkey patching of shared example/context declaration methods
(<code>shared_examples_for</code>, etc.) to just the objects that need it rather than
every object in the system (Myron Marston).</li>
<li>Fix Metadata#fetch to support computed values (Sam Goldman).</li>
<li>Named subject can now be referred to from within subject block in a nested
group (tomykaira).</li>
<li>Fix <code>fail_fast</code> so that it properly exits when an error occurs in a
<code>before(:all) hook</code> (Bradley Schaefer).</li>
<li>Make the order spec files are loaded consistent, regardless of the
order of the files returned by the OS or the order passed at
the command line (Jo Liss and Sam Phippen).</li>
<li>Ensure instance variables from <code>before(:all)</code> are always exposed
from <code>after(:all)</code>, even if an error occurs in <code>before(:all)</code>
(Sam Phippen).</li>
<li><code>rspec --init</code> no longer generates an incorrect warning about <code>--configure</code>
being deprecated (Sam Phippen).</li>
<li>Fix pluralization of <code>1 seconds</code> (Odin Dutton)</li>
<li>Fix ANSICON url (Jarmo Pertman)</li>
<li>Use dup of Time so reporting isn&#8217;t clobbered by examples that modify Time
without properly restoring it. (David Chelimsky)</li>
</ul>

<p>Deprecations</p>

<ul>
<li><code>share_as</code> is no longer needed. <code>shared_context</code> and/or
<code>RSpec::SharedContext</code> provide better mechanisms (Sam Phippen).</li>
<li>Deprecate <code>RSpec.configuration</code> with a block (use <code>RSpec.configure</code>).</li>
</ul>

<h3>rspec-expectations-2.12.0</h3>

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

<p>Enhancements</p>

<ul>
<li>Colorize diffs if the <code>--color</code> option is configured. (Alex Coplan)</li>
<li>Include backtraces in unexpected errors handled by <code>raise_error</code>
matcher (Myron Marston)</li>
<li>Print a warning when users accidentally pass a non-string argument
as an expectation message (Sam Phippen)</li>
<li><code>=~</code> and <code>match_array</code> matchers output a more useful error message when
the actual value is not an array (or an object that responds to <code>#to_ary</code>)
(Sam Phippen)</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Fix <code>include</code> matcher so that <code>expect({}).to include(:a =&gt; nil)</code>
fails as it should (Sam Phippen).</li>
<li>Fix <code>be_an_instance_of</code> matcher so that <code>Class#to_s</code> is used in the
description rather than <code>Class#inspect</code>, since some classes (like
<code>ActiveRecord::Base</code>) define a long, verbose <code>#inspect</code>.
(Tom Stuart)</li>
</ul>

<h3>rspec-mocks-2.12.0</h3>

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

<p>Enhancements</p>

<ul>
<li><code>and_raise</code> can accept an exception class and message, more closely
matching <code>Kernel#raise</code> (e.g., <code>foo.stub(:bar).and_raise(RuntimeError, "message")</code>)
(Bas Vodde)</li>
<li>Add <code>and_call_original</code>, which will delegate the message to the
original method (Myron Marston).</li>
</ul>

<p>Deprecations:</p>

<ul>
<li>Add deprecation warning when using <code>and_return</code> with <code>should_not_receive</code>
(Neha Kumari)</li>
</ul>

<h3>rspec-rails-2.12.0</h3>

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

<p>Enhancements</p>

<ul>
<li>Support validation contexts when using <code>#errors_on</code> (Woody Peterson)</li>
<li>Include RequestExampleGroup in groups in spec/api</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Add <code>should</code> and <code>should_not</code> to <code>CollectionProxy</code> (Rails 3.1+) and
<code>AssociationProxy</code> (Rails 3.0).  (Myron Marston)</li>
<li><code>controller.controller_path</code> is set correctly for view specs in Rails 3.1+.
(Andy Lindeman)</li>
<li>Generated specs support module namespacing (e.g., in a Rails engine).
(Andy Lindeman)</li>
<li><code>render</code> properly infers the view to be rendered in Rails 3.0 and 3.1
(John Firebaugh)</li>
<li>AutoTest mappings involving config/ work correctly (Brent J. Nordquist)</li>
<li>Failures message for <code>be_new_record</code> are more useful (Andy Lindeman)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/11/12/rspec-212-is-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Agile Testing and BDD eXchange 2012 in NYC</title>
		<link>http://blog.davidchelimsky.net/2012/09/22/agile-testing-and-bdd-exchange-2012-in-nyc/</link>
		<comments>http://blog.davidchelimsky.net/2012/09/22/agile-testing-and-bdd-exchange-2012-in-nyc/#comments</comments>
		<pubDate>Sat, 22 Sep 2012 15:04:00 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2945</guid>
		<description><![CDATA[I&#8217;m excited to be presenting on Behavior-Driven Objects at the Agile Testing &#38; BDD eXchange in NYC on Monday, October 1st (details below). From the conference website:


One of the original ideas behind BDD was that testing should be about behavior at all levels. Effectively, all automated tests can be viewed as &#8220;functional tests&#8221; of entry [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m excited to be presenting on Behavior-Driven Objects at the Agile Testing &amp; BDD eXchange in NYC on Monday, October 1st (details below). From the <a href="http://skillsmatter.com/podcast/agile-scrum/david-chelimsky-talk-tbc">conference website</a>:</p>

<blockquote>
One of the original ideas behind BDD was that testing should be about behavior at all levels. Effectively, all automated tests can be viewed as &#8220;functional tests&#8221; of entry points, be they user facing or internal, crossing procedural boundaries or not. In this talk we&#8217;ll explore approaches to focusing on the behavior of objects, using language that also serves to document the expected behavior in ways useful to both technical and non-technical stakeholders.
</blockquote>

<p>The Agile Testing &amp; BDD eXchange is a one-day conference with talks, open-space discussions and focus on &#8216;quality time&#8217; between presenters and attendees. There is a nice blend of technical talks like <a href="http://skillsmatter.com/podcast/agile-testing/the-solid-principles-of-test-design">Uncle Bob Martin talking about how to apply SOLID principles to test design</a>, and more process oriented talks like <a href="http://skillsmatter.com/podcast/agile-testing/ellen-gottesdiener-talk-tbc">Ellen Gottesdiener&#8217;s talk on product definition through structured conversation</a>.</p>

<p>You can read the full program and purchase tickets at <a href="http://bit.ly/S0Ypb8">http://bit.ly/S0Ypb8</a> (be sure to use the promo-code &#8220;bddxnyc-community-discount&#8221;).</p>

<p>What: Agile Testing &amp; BDD eXchange NYC<br/>
When: October 1st 2012<br/>
Where: The Ace Hotel NYC<br/>
Twitter: #BDDXNYC</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/09/22/agile-testing-and-bdd-exchange-2012-in-nyc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rspec-2.11 is released!</title>
		<link>http://blog.davidchelimsky.net/2012/07/07/rspec-211-is-released/</link>
		<comments>http://blog.davidchelimsky.net/2012/07/07/rspec-211-is-released/#comments</comments>
		<pubDate>Sat, 07 Jul 2012 22:00:42 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[BDD]]></category>

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

		<guid isPermaLink="false">http://blog.davidchelimsky.net/?p=2941</guid>
		<description><![CDATA[rspec-2.11.0 is out and filled with a bunch of new features.  Big thanks to all
who contributed, especially Justin Ko, Andy
Lindeman (the newest addition to the RSpec core
team) and Myron Marston for their great job
addressing issues and shepherding pull requests.

Thanks also to Myron for all his work on two great new features: the new
expectation
syntax
and support [...]]]></description>
			<content:encoded><![CDATA[<p>rspec-2.11.0 is out and filled with a bunch of new features.  Big thanks to all
who contributed, especially <a href="http://twitter.com/justinko">Justin Ko</a>, <a href="http://alindeman.github.com/">Andy
Lindeman</a> (the newest addition to the RSpec core
team) and <a href="http://myronmars.to/n/dev-blog">Myron Marston</a> for their great job
addressing issues and shepherding pull requests.</p>

<p>Thanks also to Myron for all his work on two great new features: <a href="http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax">the new
expectation
syntax</a>
and <a href="http://myronmars.to/n/dev-blog/2012/06/constant-stubbing-in-rspec-2-11">support for stubbing
constants</a>.</p>

<h3>rspec-core-2.11.0</h3>

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

<p>Enhancements</p>

<ul>
<li>Support multiple <code>--example</code> options. (Daniel Doubrovkine @dblock)</li>
<li>Named subject e.g. <code>subject(:article) { Article.new }</code>

<ul>
<li>see <a href="http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/">http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/</a>
for background.</li>
<li>thanks to Bradley Schaefer for suggesting it and Avdi Grimm for almost
suggesting it.</li>
</ul></li>
<li><code>config.mock_with</code> and <code>config.expect_with</code> yield custom config object to a
block if given

<ul>
<li>aids decoupling from rspec-core&#8217;s configuation</li>
</ul></li>
<li><code>include_context</code> and <code>include_examples</code> support a block, which gets eval&#8217;d
in the current context (vs the nested context generated by <code>it_behaves_like</code>).</li>
<li>Add <code>config.order = 'random'</code> to the <code>spec_helper.rb</code> generated by <code>rspec
--init</code>.</li>
<li>Delay the loading of DRb (Myron Marston).</li>
<li>Limit monkey patching of <code>describe</code> onto just the objects that need it rather
than every object in the system (Myron Marston).</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Support alternative path separators. For example, on Windows, you can now do
this: <code>rspec spec\subdir</code>. (Jarmo Pertman @jarmo)</li>
<li>When an example raises an error and an after or around hook does as
well, print out the hook error. Previously, the error was silenced and
the user got no feedback about what happened. (Myron Marston)</li>
<li><code>--require</code> and <code>-I</code> are merged among different configuration sources (Andy
Lindeman)</li>
<li>Delegate to mocha methods instead of aliasing them in mocha adapter.</li>
</ul>

<h3>rspec-expectations-2.11.0</h3>

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

<p>Enhancements</p>

<ul>
<li>Expand <code>expect</code> syntax so that it supports expections on bare values
in addition to blocks (Myron Marston).</li>
<li>Add configuration options to control available expectation syntaxes
(Myron Marston):

<ul>
<li><code>RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :expect }</code></li>
<li><code>RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :should }</code></li>
<li><code>RSpec.configuration.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }</code></li>
<li><code>RSpec.configuration.add_should_and_should_not_to Delegator</code></li>
</ul></li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Allow only <code>Numeric</code> values to be the &#8220;actual&#8221; in the <code>be_within</code> matcher.
This prevents confusing error messages. (Su Zhang @zhangsu)</li>
<li>Define <code>should</code> and <code>should_not</code> on <code>BasicObject</code> rather than <code>Kernel</code>
on 1.9. This makes <code>should</code> and <code>should_not</code> work properly with
<code>BasicObject</code>-subclassed proxy objects like <code>Delegator</code>. (Myron
Marston)</li>
</ul>

<h3>rspec-mocks-2.11.0</h3>

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

<p>Enhancements</p>

<ul>
<li>expose ArgumentListMatcher as a formal API

<ul>
<li>supports use by 3rd party mock frameworks like Surrogate</li>
</ul></li>
<li>Add <code>stub_const</code> API to stub constants for the duration of an
example (Myron Marston).</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>Fix regression of edge case behavior. <code>double.should_receive(:foo) { a }</code>
was causing a NoMethodError when <code>double.stub(:foo).and_return(a, b)</code>
had been setup before (Myron Marston).</li>
<li>Infinite loop generated by using <code>any_instance</code> and <code>dup</code>. (Sidu Ponnappa @kaiwren)</li>
<li><code>double.should_receive(:foo).at_least(:once).and_return(a)</code> always returns a
even if <code>:foo</code> is already stubbed.</li>
<li>Prevent infinite loop when interpolating a null double into a string
as an integer (<code>"%i" % double.as_null_object</code>). (Myron Marston)</li>
<li>Fix <code>should_receive</code> so that null object behavior (e.g. returning
self) is preserved if no implementation is given (Myron Marston).</li>
<li>Fix <code>and_raise</code> so that it raises <code>RuntimeError</code> rather than
<code>Exception</code> by default, just like ruby does. (Andrew Marshall)</li>
</ul>

<h3>rspec-rails-2.11.0</h3>

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

<p>Enhancements</p>

<ul>
<li>The generated <code>spec/spec_helper.rb</code> sets <code>config.order = "random"</code> so that
specs run in random order by default.</li>
<li>rename <code>render_template</code> to <code>have_rendered</code> (and alias to <code>render_template</code>
for backward compatibility)</li>
</ul>

<p>Bug fixes</p>

<ul>
<li>&#8220;uninitialized constant&#8221; errors are avoided when using using gems like
<code>rspec-rails-uncommitted</code> that define <code>Rspec::Rails</code> before <code>rspec-rails</code>
loads (Andy Lindeman)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.davidchelimsky.net/2012/07/07/rspec-211-is-released/feed/</wfw:commentRss>
		</item>
		<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>
	</channel>
</rss>
