<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pivotal Labs &#187; Brian Butz</title>
	<atom:link href="http://pivotallabs.com/author/bbutz/feed/" rel="self" type="application/rss+xml" />
	<link>http://pivotallabs.com</link>
	<description>Agility Developed</description>
	<lastBuildDate>Tue, 21 May 2013 02:39:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Less is more in Capybara 2.1</title>
		<link>http://pivotallabs.com/less-is-more-in-capybara-2-1/</link>
		<comments>http://pivotallabs.com/less-is-more-in-capybara-2-1/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 01:49:24 +0000</pubDate>
		<dc:creator>Brian Butz</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[acceptance-testing]]></category>
		<category><![CDATA[bloggerdome]]></category>
		<category><![CDATA[capybara]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=18605</guid>
		<description><![CDATA[<p>One of my favorite changes in Capybara 2.1 is ignoring all hidden elements by default. This could be viewed as a limiting of Capybara&#8217;s feature set, since you can no longer (easily) test certain elements on a page. I will argue that it steers you into writing tests that are more realistic, causing this limitation to actually enhance the quality of your acceptance tests. Let&#8217;s use the accordions in Twitter Bootstrap as a simple, contrived example of how ignoring hidden elements leads to better and more realistic tests. Let&#8217;s say we wanted to check for the content of the second accordion. Before, we could have done it like this: This won&#8217;t work in Capybara 2.1, since the second section of the accordion will be closed when the page initially loads. In Capybara 2.1, we need to actually click on the header of the accordion as the user would to make&#8230;</p><p>The post <a href="http://pivotallabs.com/less-is-more-in-capybara-2-1/">Less is more in Capybara 2.1</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>One of my favorite <a href="http://www.elabs.se/blog/60-introducing-capybara-2-1">changes in Capybara 2.1</a> is ignoring all hidden elements by default. This could be viewed as a limiting of Capybara&#8217;s feature set, since you can no longer (easily) test certain elements on a page. I will argue that it steers you into writing tests that are more realistic, causing this limitation to actually enhance the quality of your acceptance tests.</p>
<p><span id="more-18605"></span></p>
<p>Let&#8217;s use the <a href="http://twitter.github.io/bootstrap/javascript.html#collapse">accordions in Twitter Bootstrap</a> as a simple, contrived example of how ignoring hidden elements leads to better and more realistic tests.</p>
<script src="https://gist.github.com/5479130.js"></script><noscript><pre><code class="language-html html">&lt;div class=&quot;accordion&quot; id=&quot;accordion2&quot;&gt;
  &lt;div class=&quot;accordion-group&quot;&gt;
    &lt;div class=&quot;accordion-heading&quot;&gt;
      &lt;a class=&quot;accordion-toggle&quot; data-toggle=&quot;collapse&quot; data-parent=&quot;#accordion2&quot; href=&quot;#collapseOne&quot;&gt;
        Group 1
      &lt;/a&gt;
    &lt;/div&gt;
    &lt;div id=&quot;collapseOne&quot; class=&quot;accordion-body collapse&quot; style=&quot;height: 0px;&quot;&gt;
      &lt;div class=&quot;accordion-inner&quot;&gt;
        Peanut Butter &amp; Jelly
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;accordion-group&quot;&gt;
    &lt;div class=&quot;accordion-heading&quot;&gt;
      &lt;a class=&quot;accordion-toggle&quot; data-toggle=&quot;collapse&quot; data-parent=&quot;#accordion2&quot; href=&quot;#collapseTwo&quot;&gt;
        Group 2
      &lt;/a&gt;
    &lt;/div&gt;
    &lt;div id=&quot;collapseTwo&quot; class=&quot;accordion-body collapse&quot; style=&quot;height: 0px;&quot;&gt;
      &lt;div class=&quot;accordion-inner&quot;&gt;
        Ham &amp; Cheese
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;accordion-group&quot;&gt;
    &lt;div class=&quot;accordion-heading&quot;&gt;
      &lt;a class=&quot;accordion-toggle&quot; data-toggle=&quot;collapse&quot; data-parent=&quot;#accordion2&quot; href=&quot;#collapseThree&quot;&gt;
        Collapsible Group Item #3
      &lt;/a&gt;
    &lt;/div&gt;
    &lt;div id=&quot;collapseThree&quot; class=&quot;accordion-body in collapse&quot; style=&quot;height: auto;&quot;&gt;
      &lt;div class=&quot;accordion-inner&quot;&gt;
        Corned Beef &amp; Cabbage
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre></noscript>
<p>Let&#8217;s say we wanted to check for the content of the second accordion.  Before, we could have done it like this:</p>
<script src="https://gist.github.com/5479161.js"></script><noscript><pre><code class="language-ruby ruby">within(&quot;.accordion&quot;) do
  page.should have_content &quot;Ham &amp; Cheese&quot;
end</code></pre></noscript>
<p>This won&#8217;t work in Capybara 2.1, since the second section of the accordion will be closed when the page initially loads.  In Capybara 2.1, we need to actually click on the header of the accordion as the user would to make the content visible.</p>
<script src="https://gist.github.com/5479173.js"></script><noscript><pre><code class="language-ruby ruby">within(&quot;.accordion&quot;) do
  click_link &quot;Group 2&quot;
  page.should have_content &quot;Ham &amp; Cheese&quot;
end</code></pre></noscript>
<p>This is a simple example to show how Capybara has changed, but doesn&#8217;t really show any of the benefit of this change.  For that, let&#8217;s try and test something a bit more complex.</p>
<p>Let&#8217;s say we had a feature that allowed us to zoom in on a single word in a sentence into focus, for whatever reason.  Let&#8217;s use the classic: &#8220;The quick brown fox jumps over the lazy dog&#8221; as an example.  In Capybara 2.1, we can easily test this.</p>
<script src="https://gist.github.com/5479206.js"></script><noscript><pre><code class="language-ruby ruby">page.should have_content &quot;The quick brown fox jumps over the lazy dog&quot;

click &quot;fox&quot;

page.should have_content &quot;fox&quot;
page.should have_no_content &quot;jumps&quot;</code></pre></noscript>
<p>First we test that the whole sentence shows up, focus the word we care about, see that it&#8217;s still there, and make sure another word in the sentence isn&#8217;t showing up.  This pretty much exactly describes how the user is going to experience this feature.  In previous versions of Capybara, we would have had to test the lack of content either via a <code>visible: false</code> flag to the selector, or through making assertions on the DOM.</p>
<p>There&#8217;s definitely some times when you might want to make assertions on invisible elements, and you still can using the <code>:visible</code> option.  But, I think for the most part you can get by with this new set of limitations, especially if you start thinking about how your users are actually interacting with the page, and less about how your code is manipulating things under the hood.</p>
<p>The post <a href="http://pivotallabs.com/less-is-more-in-capybara-2-1/">Less is more in Capybara 2.1</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/less-is-more-in-capybara-2-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Presenter Sanity</title>
		<link>http://pivotallabs.com/presenter-sanity/</link>
		<comments>http://pivotallabs.com/presenter-sanity/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 23:30:08 +0000</pubDate>
		<dc:creator>Brian Butz</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[presenters]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=17925</guid>
		<description><![CDATA[<p>I&#8217;m not a huge fan of Rails view helpers, which is a post for a different day, but put simply I prefer to encapsulate presentation logic in a presenter object rather than mix it in globally across all templates. There&#8217;s a few ways to do this, the simplest being the Good Ol&#8217; Plain Ol&#8217; Ruby Object: class FooPresenter def description_for(foo) Date.today.tuesday? ? "50% off! #{foo.description}" : foo.description end end Usually, I&#8217;ll instantiate the presenter in a controller and then call it within the view: class FoosController def index @foos = Foo.all @foo_presenter = FooPresenter.new end end Everything is simple and feels where it should be, but we&#8217;ve gotten this at the cost of losing view helpers mixed in from Rails. One of the helpers I find particularly helpful is strip_tags. If we want access to strip_tags we can do as Rails does when mixing it into the view scope and&#8230;</p><p>The post <a href="http://pivotallabs.com/presenter-sanity/">Presenter Sanity</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m not a huge fan of Rails view helpers, which is a post for a different day, but put simply I prefer to encapsulate presentation logic in a presenter object rather than mix it in globally across all templates. There&#8217;s a few ways to do this, the simplest being the Good Ol&#8217; Plain Ol&#8217; Ruby Object:</p>
<pre><code>
  class FooPresenter
    def description_for(foo)
      Date.today.tuesday? ? "50% off! #{foo.description}" : foo.description
    end
  end
</code></pre>
<p>Usually, I&#8217;ll instantiate the presenter in a controller and then call it within the view:</p>
<pre><code>
  class FoosController
    def index
      @foos = Foo.all
      @foo_presenter = FooPresenter.new
    end
  end
</code></pre>
<pre><code>
  <% @foos.each do |foo| %>
    <%= foo.name %>
    <%= @foo_presenter.description_for(foo) %>
  <% end %>
</code></pre>
<p>Everything is simple and feels where it should be, but we&#8217;ve gotten this at the cost of losing view helpers mixed in from Rails.  One of the helpers I find particularly <em>help</em>ful is <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags" title="strip_tags" target="_blank">strip_tags</a>.  If we want access to strip_tags we can do as Rails does when mixing it into the view scope and include it in our presenter:</p>
<pre><code>
  class FooPresenter
    include ActionView::Helpers::SanitizeHelper
    def description_for(foo)
      description = strip_tags(foo.description)
      html = Date.today.tuesday? ? "<strong>50% off!</strong> #{description}" : description
      html.html_safe
    end
  end
</code></pre>
<p>This feels a bit wrong as well.  For one, we&#8217;ve increased the number of public methods on our presenter by at least 4, and only really needed one of them.  Two, we have little control over how we are stripping the tags, and so any unit tests we&#8217;ve written for our presenter must integrate and essentially test parts of Rails.  What we really want is something that can do what strip_tags is doing.  Luckily, and due Rails becoming more modular, we already something to do this for us in the Rails library <a href="https://github.com/rails/rails/tree/e91e4e8bbee12ce1496bf384c04da6be296b687a/actionpack/lib/action_controller/vendor/html-scanner" title="html-scanner" target="_blank">html-scanner</a>.  Under the hood, strip_tag is, unless configured differently, passing your string down to the sanitize method on an instance of an HTML::FullSanitizer object.  We can do something similar in our presenter:</p>
<pre><code>
  require 'html/sanitizer'
  class FooPresenter
    def initialize(sanitizer=HTML::FullSanitizer.new)
      @sanitizer = sanitizer
    end
    def description_for(foo)
      description = @sanitizer.sanitize(foo.description)
      html = Date.today.tuesday? ? "<strong>50% off!</strong> #{description}" : description
      html.html_safe
    end
  end
</code></pre>
<p>Now we have an object that is easy to test purely as a unit, and also has the ability to be extended with different sanitizers.</p>
<p>While this works well with strip_tags, unfortunately not every helper in Rails is as nicely decoupled.  The work being done in the <a href="https://github.com/rails/rails/blob/d82b5db059bd824d6699936b567359d70d427e2a/actionpack/lib/action_view/helpers/number_helper.rb#L135" title="number_to_currency" target="_blank">number_to_*</a> methods, for instance, are written completely in modules.  It may be nice at some point to pull these into corresponding objects, but a short term solution could be to just have an object that includes the module:</p>
<pre><code>
  class NumberCruncher
    include ActionView::Helpers::NumberHelper
  end

  > NumberCruncher.new.number_to_currency(1)
  => "$1.00"
</code></pre>
<p>The post <a href="http://pivotallabs.com/presenter-sanity/">Presenter Sanity</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/presenter-sanity/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>02/25/13: 7304.84 Days of Ruby</title>
		<link>http://pivotallabs.com/022513-7304-84-days-of-ruby/</link>
		<comments>http://pivotallabs.com/022513-7304-84-days-of-ruby/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 18:38:37 +0000</pubDate>
		<dc:creator>Brian Butz</dc:creator>
				<category><![CDATA[Labs]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=15609</guid>
		<description><![CDATA[<p>Interestings holepicker http://psionides.eu/2013/02/18/pick-holes-in-your-gemfiles/ Find gems with vulnerabilities</p><p>The post <a href="http://pivotallabs.com/022513-7304-84-days-of-ruby/">02/25/13: 7304.84 Days of Ruby</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Interestings</h2>
<h3>holepicker</h3>
<p><a href="http://psionides.eu/2013/02/18/pick-holes-in-your-gemfiles/">http://psionides.eu/2013/02/18/pick-holes-in-your-gemfiles/</a></p>
<p>Find gems with vulnerabilities</p>
<p>The post <a href="http://pivotallabs.com/022513-7304-84-days-of-ruby/">02/25/13: 7304.84 Days of Ruby</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/022513-7304-84-days-of-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SF Standup 11/04/11</title>
		<link>http://pivotallabs.com/sf-standup-11-04-11/</link>
		<comments>http://pivotallabs.com/sf-standup-11-04-11/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 14:39:00 +0000</pubDate>
		<dc:creator>Brian Butz</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/sf-standup-11-04-11/</guid>
		<description><![CDATA[<p><h2>Interesting Things</h2>

<ul>
<li><p>Lightning Talks are next week, but no talks have been submitted yet.  Unless talks are submitted, it's going to be a long hour of staring at the wall.</p></li>
<li><p>jQuery 1.7 has been released <a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/">http://blog.jquery.com/2011/11/03/jquery-1-7-released/</a> .  If you use Backbone.js you might want to update jQuery for the improved delegated events performance.</p></li>
</ul> <a href="http://pivotallabs.com/sf-standup-11-04-11/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/sf-standup-11-04-11/">SF Standup 11/04/11</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Interesting Things</h2>
<ul>
<li>
<p>Lightning Talks are next week, but no talks have been submitted yet.  Unless talks are submitted, it&#8217;s going to be a long hour of staring at the wall.</p>
</li>
<li>
<p>jQuery 1.7 has been released <a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/">http://blog.jquery.com/2011/11/03/jquery-1-7-released/</a> .  If you use Backbone.js you might want to update jQuery for the improved delegated events performance.</p>
</li>
</ul>
<p>The post <a href="http://pivotallabs.com/sf-standup-11-04-11/">SF Standup 11/04/11</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/sf-standup-11-04-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Standup 00110111 &#8211; AKA 55 day</title>
		<link>http://pivotallabs.com/standup-00110111-aka-55-day/</link>
		<comments>http://pivotallabs.com/standup-00110111-aka-55-day/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 15:06:00 +0000</pubDate>
		<dc:creator>Brian Butz</dc:creator>
				<category><![CDATA[Standup]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/standup-00110111-aka-55-day/</guid>
		<description><![CDATA[<p><h2>Interesting Things</h2>

<ul>
<li>The Postgres adapter for ActiveRecord will not use an offset unless you also provide a limit.</li>
<li>Tomorrow Occupy Oakland Is calling for a General Strike. The Port of Oakland, numerous schools, and many other institutions will be shut down, as all their employees will be marching in the streets. Come out in solidarity before, during, or after work. It's gonna be really fun.</li>
</ul> <a href="http://pivotallabs.com/standup-00110111-aka-55-day/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/standup-00110111-aka-55-day/">Standup 00110111 &#8211; AKA 55 day</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Interesting Things</h2>
<ul>
<li>The Postgres adapter for ActiveRecord will not use an offset unless you also provide a limit.</li>
<li>Tomorrow Occupy Oakland Is calling for a General Strike. The Port of Oakland, numerous schools, and many other institutions will be shut down, as all their employees will be marching in the streets. Come out in solidarity before, during, or after work. It&#8217;s gonna be really fun.</li>
</ul>
<p>The post <a href="http://pivotallabs.com/standup-00110111-aka-55-day/">Standup 00110111 &#8211; AKA 55 day</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/standup-00110111-aka-55-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Standup 07/20/2011: I Know What Bowling Is</title>
		<link>http://pivotallabs.com/standup-07-20-2011-i-know-what-bowling-is/</link>
		<comments>http://pivotallabs.com/standup-07-20-2011-i-know-what-bowling-is/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 16:22:00 +0000</pubDate>
		<dc:creator>Brian Butz</dc:creator>
				<category><![CDATA[Labs]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/standup-07-20-2011-i-know-what-bowling-is/</guid>
		<description><![CDATA[<p><h2>Ask for Help</h2>

<blockquote>
    <p><em>"Rubymine can't call git ls-files in gemspec"</em></p>
</blockquote>

<p>This should have been fixed a while ago in the developer image.</p>

<blockquote>
    <p><em>"Anyone built ruby 1.9 from source?  I'm not sure what options to configure it with."</em></p>
</blockquote>

<p>Check to see what options RVM is using when it builds 1.9.</p>

<h2>Interesting Things</h2>

<ul>
<li>nil</li>
</ul>

<h2>David Stevenson</h2>

<ul>
<li>I'm running a blog using ruby 1.8 off a router.</li>
</ul> <a href="http://pivotallabs.com/standup-07-20-2011-i-know-what-bowling-is/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/standup-07-20-2011-i-know-what-bowling-is/">Standup 07/20/2011: I Know What Bowling Is</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask for Help</h2>
<blockquote>
<p><em>&#8220;Rubymine can&#8217;t call git ls-files in gemspec&#8221;</em></p>
</blockquote>
<p>This should have been fixed a while ago in the developer image.</p>
<blockquote>
<p><em>&#8220;Anyone built ruby 1.9 from source?  I&#8217;m not sure what options to configure it with.&#8221;</em></p>
</blockquote>
<p>Check to see what options RVM is using when it builds 1.9.</p>
<h2>Interesting Things</h2>
<ul>
<li>nil</li>
</ul>
<h2>David Stevenson</h2>
<ul>
<li>I&#8217;m running a blog using ruby 1.8 off a router.</li>
</ul>
<p>The post <a href="http://pivotallabs.com/standup-07-20-2011-i-know-what-bowling-is/">Standup 07/20/2011: I Know What Bowling Is</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/standup-07-20-2011-i-know-what-bowling-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using apc
Database Caching using apc
Object Caching 815/884 objects using apc

 Served from: pivotallabs.com @ 2013-05-20 23:09:31 by W3 Total Cache -->