<?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; tdd</title>
	<atom:link href="http://pivotallabs.com/tag/tdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://pivotallabs.com</link>
	<description>Agility Developed</description>
	<lastBuildDate>Tue, 21 May 2013 16:50:52 +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>Designing an API in Hell</title>
		<link>http://pivotallabs.com/designing-an-api-in-hell/</link>
		<comments>http://pivotallabs.com/designing-an-api-in-hell/#comments</comments>
		<pubDate>Sun, 19 May 2013 18:16:18 +0000</pubDate>
		<dc:creator>Andrew Bruce</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[bloggerdome]]></category>
		<category><![CDATA[minitest]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=19329</guid>
		<description><![CDATA[<p>Minitest, Ruby&#8217;s built-in testing library, has some great out-of-the-box features. One of these is test parallelization. Parallel testing is often added after a suite gets slow enough to hurt. That can be achieved using the parallel_tests gem, which takes advantage of today&#8217;s multi-core processors, or using custom solutions for dividing chunks of a suite across several machines. Arguably, test speed should be dealt with by making code design changes, but that&#8217;s another story: what interests me most about minitest&#8217;s parallelization is the constraints it places upon the design of stateful systems when TDDing from scratch. You can turn on parallelization for a particular test case: describe Server do parallelize_me! end or for all tests: require 'minitest/hell' As the name implies, the latter approach turns up the test pain level to 11, but it&#8217;s the kind of pain that can have positive effects. For &#8216;fun&#8217;, I started to use minitest&#8217;s parallelization&#8230;</p><p>The post <a href="http://pivotallabs.com/designing-an-api-in-hell/">Designing an API in Hell</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="https://github.com/seattlerb/minitest">Minitest</a>, Ruby&#8217;s built-in testing library, has some great out-of-the-box features. One of these is <a href="http://blog.zenspider.com/blog/2012/12/minitest-parallelization-and-you.html">test parallelization</a>. Parallel testing is often added after a suite gets slow enough to hurt. That can be achieved using the <a href="https://github.com/grosser/parallel_tests">parallel_tests gem</a>, which takes advantage of today&#8217;s multi-core processors, or using custom solutions for dividing chunks of a suite across several machines. Arguably, test speed should be dealt with by making code design changes, but that&#8217;s another story: what interests me most about minitest&#8217;s parallelization is the constraints it places upon the design of stateful systems when TDDing from scratch.</p>
<p>You can turn on parallelization for a particular test case:</p>
<pre><code class="language-ruby">describe Server do
  parallelize_me!
end
</code></pre>
<p>or for all tests:</p>
<pre><code>require 'minitest/hell'
</code></pre>
<p>As the name implies, the latter approach turns up the test pain level to 11, but it&#8217;s the kind of pain that can have positive effects. For &#8216;fun&#8217;, I started to use minitest&#8217;s parallelization on <a href="https://github.com/camelpunch/plumb">a side project</a>, which has a stateful API backed by a relational database. Here are some of the decisions that were forced out by using parallel test examples.</p>
<h2>Commitment to fast tests</h2>
<p>I thought that running tests in parallel from the start of a project would make me lazy, causing me to neglect slow tests because they&#8217;d be running at the same time as others. Surprisingly, the opposite happened: the need to constantly rerun the whole suite to iron out nondeterministic conflicts encouraged me to fix slow tests early. I ended up being able to run the entire suite several times within a matter of seconds in order to check the tests&#8217; ability to run in parallel.</p>
<p>Side note: this is an early-stage project, with a very low quantity of tests! It will be interesting to see how test speed increases as the volume of tests increases.</p>
<h2>Avoiding test duplication</h2>
<p>Since the unique constraints of my database could be hit by tests with the same fixture data running at the same time, I was encouraged to use more intention revealing test data for each example, avoiding foo and bar, which commonly litter a suite and make tests harder to read.</p>
<p>For IDs, I used Ruby&#8217;s <a href="http://rubydoc.info/stdlib/securerandom/SecureRandom">SecureRandom</a> library, which provides GUID and hex generation. I sometimes used hex generation when the user-supplied unique display name of something didn&#8217;t matter to the test.</p>
<h2>Client-side ID generation</h2>
<p>Although not strictly forced out from parallel tests, parallel testing got me thinking about how best to interact with the backend, which has a single database being served by multiple concurrent requests (just like any web server).</p>
<p>Using GUIDs instead of autoincrementing IDs can be a smart decision to make if you can (i.e. you don&#8217;t need human-friendly URLs), because it means your database server doesn&#8217;t need to worry as much about ensuring uniqueness, since the GUID algorithm <a href="http://stackoverflow.com/questions/2977593/is-it-safe-to-assume-a-guid-will-always-be-unique#answer-2977648">effectively guarantees it</a>.</p>
<p>TDDing my API from scratch, without external requirements, encouraged me to use GUIDs to simplify the design and to avoid bottlenecks at the database layer. POST requests canonically return the new URL of the resource you&#8217;re creating in the Location header of the response. So to test that a thing really got persisted I&#8217;d need to:</p>
<ol>
<li>POST to /items with a representation of the resource</li>
<li>Grab the Location header of the response to get the new URL</li>
<li>GET /items/:newid and ensure the response body matched the representation I sent</li>
</ol>
<p>This seemed a very laborious process for storing some data. Much less work is:</p>
<ol>
<li>PUT to /items/:newid</li>
<li>GET /items/:newid and ensure the response body matched the representation I sent</li>
</ol>
<p>Since GUIDs can be treated as unique, it didn&#8217;t make much sense for the server to generate them.</p>
<p>Positive effect: the app would now cope with a distributed database system on the back-end, despite starting out on a technology that&#8217;s thought of as difficult to scale horizontally (SQLite).</p>
<h2>Avoiding database resets</h2>
<p>It&#8217;s common practice to wipe the whole database when starting a new example, or to run each example in a transaction and roll it back when each example finishes. I wanted real black-box tests, so I didn&#8217;t want to use transactions. Yet, deleting the whole database at the start of an example didn&#8217;t play nice with minitest&#8217;s parallelization, since data that one example required would be deleted by another.</p>
<p>The usual approach when using parallel_tests is to create a database for each process. However, since minitest doesn&#8217;t manage databases (nor should it) I chose to keep a single database and find a different solution.</p>
<p>I chose to sandbox all of the tests by creating new entities each time, and only checking for output that indicated that particular entity had been worked on. The <a href="https://github.com/camelpunch/plumb">product I&#8217;m working on</a> is a Continuous Integration server, so I&#8217;d be creating CI projects (you might also know them as jobs) and expecting them to appear in an XML feed. The tests had to be OK with other data being present, since the other tests could be working too.</p>
<p>This approach precluded tests that checked that the number of records had increased by one, because in an otherwise acceptable &#8220;green&#8221; test situation they&#8217;d occasionally increase by more than one (another test added a record too), stay the same (another test deleted a record) or decrease (more than one had been deleted).</p>
<h2>Constraints are fun</h2>
<p>While I wouldn&#8217;t recommend going rogue like this on a client project, playing with constraints like truly parallel tests can get you thinking about your normal testing procedure. Some of the above decisions allowed for a much faster test execution time, and always having the assumption that other processes could be working on the database forced out some interesting techniques. Some of the techniques I had to avoid due to parallelization would normally necessitate different workarounds with their own drawbacks. For example, if you always assume the count of an ActiveRecord class will go up, you require exclusive use of the database. If instead you scope your queries to a parent entity, this restriction would be removed.</p>
<p>Hell isn&#8217;t so bad after all.</p>
<p>The post <a href="http://pivotallabs.com/designing-an-api-in-hell/">Designing an API in Hell</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/designing-an-api-in-hell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smelling with your ears: TDD techniques to influence your design</title>
		<link>http://pivotallabs.com/smelling-with-ears-tdd-influence-design/</link>
		<comments>http://pivotallabs.com/smelling-with-ears-tdd-influence-design/#comments</comments>
		<pubDate>Mon, 13 May 2013 01:08:52 +0000</pubDate>
		<dc:creator>Andrew Bruce</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[bloggerdome]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[smells]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=18971</guid>
		<description><![CDATA[<p>Test Driven Development can be a hard sell. The first pitch is often designed to entice the buyer with safety features, like: &#8220;How will you ensure that those bugs don&#8217;t creep back in?&#8221; &#8220;Wouldn&#8217;t it be nice to know that one change doesn&#8217;t break another?&#8221; In conversations between practiced test drivers, though, design topics tend to pop up: &#8220;What is this test telling us about the design of our code?&#8221; &#8220;Why is this test boring to write?&#8221; &#8220;Why is this test so slow?&#8221; Then there are really exciting questions, when getting close to a design breakthrough, like: &#8220;Is this test telling us we&#8217;re lacking polymorphism in our design?&#8221; &#8220;I&#8217;m tired of constructing this thing. How can we group this set of arguments into an object with a name?&#8221; One distinguishing factor between these types of questions is the level of trust in TDD. Someone with little trust might be predisposed&#8230;</p><p>The post <a href="http://pivotallabs.com/smelling-with-ears-tdd-influence-design/">Smelling with your ears: TDD techniques to influence your design</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Test Driven Development can be a hard sell. The first pitch is often designed to entice the buyer with safety features, like:</p>
<ul>
<li>&#8220;How will you ensure that those bugs don&#8217;t creep back in?&#8221;</li>
<li>&#8220;Wouldn&#8217;t it be nice to know that one change doesn&#8217;t break another?&#8221;</li>
</ul>
<p>In conversations between practiced test drivers, though, design topics tend to pop up:</p>
<ul>
<li>&#8220;What is this test telling us about the design of our code?&#8221;</li>
<li>&#8220;Why is this test boring to write?&#8221;</li>
<li>&#8220;Why is this test so slow?&#8221;</li>
</ul>
<p>Then there are really exciting questions, when getting close to a design breakthrough, like:</p>
<ul>
<li>&#8220;Is this test telling us we&#8217;re lacking polymorphism in our design?&#8221;</li>
<li>&#8220;I&#8217;m tired of constructing this thing. How can we group this set of arguments into an object with a name?&#8221;</li>
</ul>
<p>One distinguishing factor between these types of questions is the level of trust in TDD. Someone with little trust might be predisposed to abandon testing before implementation, instead choosing to test afterwards, or not at all. To such a person yet to be sold on the benefits of TDD, the safety questions make more immediate sense, while design questions are often met with blank stares. However, the safety concerns are easily brushed off: it&#8217;s a prototype. My team is so smart we don&#8217;t need tests. We need to move fast, so we&#8217;ll worry about tests later.</p>
<p>Explaining the basic advantages of TDD doesn&#8217;t always work as a sales pitch, because those explanations don&#8217;t reveal why testing can be difficult, much less why testing sometimes <em>ought</em> to be difficult. Take someone who has never let the design of their code be influenced by tests: they dislike testing for being difficult or boring. Encountering resistance in the TDD process, they choose to forgo the safety advantages of testing, and the design advantages haven&#8217;t been made clear. </p>
<p>As you may have gathered, I&#8217;m more excited by the design aspect of TDD and related tools than by the safety aspect. I&#8217;d like to think that if we sold how TDD can improve the design of code that&#8217;s yet to be written, we&#8217;d have an easier time tricking our friends into writing code with regression protection.</p>
<h2>Learning to listen</h2>
<p>There is much talk about &#8220;listening to the tests&#8221; among TDD practitioners. The listening analogy is apt. Like listening with our ears, the ability to understand what a test tells us about code quality can improve with practice. It&#8217;s a subtle concept to grasp, and one I frequently find is not well understood by otherwise experienced developers. This is unfortunate, because it&#8217;s a crucial part of getting rapid feedback on the quality of production code. By quality, I&#8217;m referring primarily to the ability to cope with changing requirements, as opposed to good coverage of features and edge-cases. </p>
<p>If you can&#8217;t hear what your tests are trying to say, there are tools for cranking up the volume. Below are a couple of my favorites. They&#8217;re not intended as hard-and-fast rules, but as exercises to try out when you&#8217;re frustrated with a test or wondering why it&#8217;s getting difficult to test something. </p>
<p>If you haven&#8217;t already, you should read about <a href="http://xunitpatterns.com/Test%20Smells.html">known test smells and their solutions</a>, because we can apparently smell with our TDD ears. </p>
<h2>Use your testing framework&#8217;s convenience helpers sparingly</h2>
<p>In the RSpec world, this often comes down to writing readable examples without using &#8216;subject&#8217;, &#8216;let&#8217; or &#8216;before&#8217;. It turns out that straightforward assignment is usually OK.</p>
<p>As <a href="http://robots.thoughtbot.com/post/34709581001/lets-not">this Thoughtbot post</a> argues, the let helper effectively introduces Mystery Guests (implicit, hidden fixtures), and overuse results in slow and fragile tests.</p>
<p>I like to avoid lets, subjects and other test helpers for another reason: if I can&#8217;t stand to repeat myself in examples, I think about how the code that uses my code will feel. A boring, repetitive test setup might be telling me that my code has too many dependencies. If I&#8217;m frantically stuffing things into the database and stubbing out web service requests just to allow myself to construct an object, perhaps the object&#8217;s scope is too broad.</p>
<p>If you come across a test that is apparently repetitive, consider tidying the implementation of the system under test before the test itself. You may find that the noise in the test can be dramatically reduced with some production code tweaks.</p>
<h2>Avoid stubbing methods to return values</h2>
<p>I owe this one to <a href="http://gmoeck.github.io/">Greg Moeck</a>, who introduced something like it at the <a href="http://www.meetup.com/pivotal-labs-sf/">San Francisco eXtreme Tuesday Club</a>.</p>
<p>First, a reminder of the definition of stubs versus mocks (to paraphrase Gerard Meszaros):</p>
<ol>
<li>A stub is a test double that allows you to control the indirect inputs of the system under test.</li>
<li>A mock is a test double that allows you to test the indirect outputs of the system under test.</li>
</ol>
<p>If you return a value from a stubbed method, you force your production code to depend on a blocking, synchronous call. If you could otherwise send a message and not expect an immediate response, you permit your design to (now or in the future) be asynchronous.</p>
<p>Further to that, if you instead use a mock to expect an output to the collaborator you were previously stubbing, you can more cleanly divide your testing into inputs and outputs of the system under test. It&#8217;s the difference between:</p>
<pre><code class="language-ruby">it "ensures user is authentic before performing the action" do
  user = stub('user')
  authenticator = stub('authenticator')
  authenticator.stub(:authentic_user?).with(user) { true }
  action = Action.new(user)
  action.perform
  expect(action).to be_complete
end
</code></pre>
<p>and:</p>
<pre><code class="language-ruby">it "ensures the user is authentic when action is requested" do
  user = stub('user')
  authenticator = mock('authenticator') # assume the player of this role knows who to tell when authentication succeeds or fails
  authenticator.should_receive(:authenticate_user).with(user)
  action = Action.new(user)
  action.perform
end

it "performs an action once a user has been authenticated" do
  action = Action.new(stub('unauthenticated user'))
  authenticated_user = stub('user')
  action.user_successfully_authenticated(user)
  expect(action).to be_complete
end
</code></pre>
<p>The code that passes the second set of examples is in better shape for when you need to queue requests to the authenticator and complete the action asynchronously. It uses a <a href="http://pragprog.com/articles/tell-dont-ask">&#8220;tell, don&#8217;t ask&#8221;</a> style. The fact that an explicit message is sent to the system under test (&#8216;user_successfully_authenticated&#8217;) makes it clear to the reader that the request for authentication and the triggering of the action are separate bits of work. It&#8217;s someone else&#8217;s business whether I get told about the successful authentication, and how many steps are taken before I&#8217;m told.</p>
<p>There are several more techniques I&#8217;d like to tell you about, but this post is getting a bit long in the tooth. Maybe next time. Happy listening!</p>
<p>The post <a href="http://pivotallabs.com/smelling-with-ears-tdd-influence-design/">Smelling with your ears: TDD techniques to influence your design</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/smelling-with-ears-tdd-influence-design/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Winning a Rumble</title>
		<link>http://pivotallabs.com/winning-a-rumble/</link>
		<comments>http://pivotallabs.com/winning-a-rumble/#comments</comments>
		<pubDate>Sat, 11 May 2013 19:18:34 +0000</pubDate>
		<dc:creator>Luan Santos</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[bloggerdome]]></category>
		<category><![CDATA[mvp]]></category>
		<category><![CDATA[rumble]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=19043</guid>
		<description><![CDATA[<p>Last year before I joined Pivotal Labs me and my friend Raphael Costa participated in a brazilian Rumble, inspired by Rails Rumble ran by the folks from Startup DEV. It was a very interesting experience and I learned a lot from it. We won first prize, and I want to tell how we did that, and why I would change some things if it was a real project supposed to live more than 48 hours. First, if you don&#8217;t know what a rumble is, a rumble is a developer&#8217;s competition where you have a very limited time to develop an app, your result is evaluated by some folks and the best app (according to their criteria) wins. In the case of Rails Rumble or Startup DEV rumble we had 48 hours over a weekend. The plan The plan can and should be draw before you start the rumble. When the clock&#8230;</p><p>The post <a href="http://pivotallabs.com/winning-a-rumble/">Winning a Rumble</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Last year before I joined Pivotal Labs me and my friend <a href="https://github.com/raphaelcosta">Raphael Costa</a> participated in a brazilian <a href="http://startupdev.com.br/rumble/en/projects">Rumble</a>, inspired by <a href="http://railsrumble.com/">Rails Rumble</a> ran by the folks from <a href="http://startupdev.com.br/en/">Startup DEV</a>. It was a very interesting experience and I learned a lot from it. We won first prize, and I want to tell how we did that, and why I would change some things if it was a real project supposed to live more than 48 hours.</p>
<p>First, if you don&#8217;t know what a rumble is, a rumble is a developer&#8217;s competition where you have a very limited time to develop an app, your result is evaluated by some folks and the best app (according to their criteria) wins. In the case of Rails Rumble or Startup DEV rumble we had 48 hours over a weekend.</p>
<h2>The plan</h2>
<p>The plan can and should be draw before you start the rumble. When the clock starts ticking you have to laser focus in implementing everything you can.</p>
<p>First thing you need is an idea, it doesn&#8217;t need to be revolutionary it just needs to be implementable and easy. If it&#8217;s revolutionary, bonus points for you. Once you have an idea you have to describe in detail what is the featureset you are looking for.</p>
<p>When you have you featureset, you have to remove everything, EVERYTHING that is not absolutely required for your <a href="http://en.wikipedia.org/wiki/Minimum_viable_product">MVP</a>, sort the features you removed in nice-to-have order in case you have spare time at the end.</p>
<p>Draw your mockups on paper and have them ready and attached to each story you selected as part of your MVP, if you have a designer, great, make him draw more detailed wireframes, if you don&#8217;t then you&#8217;ll have to use the tools the world provide you, such as bootstrap or foundation or whatever you prefer, do not waste time in things you are not expert in.</p>
<p>Split tasks based on capacity, in our team we were two developers, I had more experience with dev-ops (and we had to deploy our app to a VPS that was provided by the organization) he had more experience with UI/UX design, so I barely thought about how the app should look, and he barely used ssh.</p>
<h2>Applying the plan</h2>
<p>The basic procedure is: pick a story, assign it to you, implement it as quick and simple as you can, deliver it asap, move on.</p>
<p>Stay in sync, you have to know what&#8217;s happening with the other folks in your team, if your team is larger than 2, it gets more and more dangerous. You do not want to spend time resolving complicated merge conflicts so make sure the tasks are well parallelizable and that no one is stepping in no one&#8217;s toes. We had quick check-in (2 minutes, standup style) every 2 hours.</p>
<p>We knew what we were capable of, so we didn&#8217;t try to do anything other than that. If you never implemented a payment gateway, don&#8217;t try to do so in a 48 hour project, you will waste time and you won&#8217;t be able to finish. We knew how to TDD and we had paired before, but these were things that we were not used to do, processes not clear in our minds, we would have to learn it on the go and we would fail if we tried. When you try something new you will certainly spend time figuring things out. So because of that we didn&#8217;t even try, we did not test, we did not pair.</p>
<p>Commit often, commit every time, on every change. This avoids complicated merge conflicts and saves you a lot of times. Write decent SHORT commit messages so you team can understand what is that that you did just by parsing the message quickly. Pull often, see the log, <code>git log --graph --oneline</code> was the command we used to quickly parse messages, alias it to something simple, like gl, for example. Once you finish a feature, deploy it. Make sure everything works properly in your deployed environment.</p>
<p>We finished everything and more with about 2 hours to spare, in this 2 hours we looked for bugs, found some and fixed them. This spare time is essential specially if you are not TDDing, you will find problems.</p>
<h2>What would I do differently</h2>
<p>First of all, if you want your app to continue after the 48 hours you have to TDD, on the next day after the competition we looked at the code and it was only OK, it wasn&#8217;t bad or anything, but it was very hard to trust it and make changes because without any tests you have no confidence on doing it. The solution for us would be rewrite the app TDDing or backfill, and backfilling is very painful.</p>
<p>Skiping the tests is very risky, you may break everything without knowing, and that would make you fail, we took that risk and it worked for us. I wouldn&#8217;t do that again, I would TDD next time even if that means reducing the scope even more, it&#8217;s too hard to develop a real app without it.</p>
<p>Pair programming and TDD are things that make you very productive on the longer run, on a 48 hour crazy competition it might not be the best thing to do if you&#8217;re there to win and your team is only composed of two people. If you have a really small and simple featureset and your team has experience you can get away without it and it would be faster on this 48 hour streak. It is very likely that you will have to rewrite your app after tho.</p>
<p>I would pair if I had a team of 4, a single pair may not be the best for a 48 hour thing, you kinda need the parallelism on this short project. The ideal setup would be two pairs tho. More than 2 parallel developer stations would probably be a bad thing.</p>
<h2>In conclusion</h2>
<p>Participating is fun, we had a lot of fun, there were several good projects on the competition and it was awesome. If you ever have the opportunity to participate in one of these you should, it&#8217;s very tiring but it is worth it at least once. If you&#8217;re interested our project is still online at <a href="http://agrupe.se/">agrupe.se</a> (it&#8217;s in portuguese, sorry, <a href="http://translate.google.com/translate?sl=pt&amp;tl=en&amp;js=n&amp;prev=_t&amp;hl=en&amp;ie=UTF-8&amp;eotf=1&amp;u=http%3A%2F%2Fagrupe.se%2F&amp;act=url">google translate</a>).</p>
<p>The post <a href="http://pivotallabs.com/winning-a-rumble/">Winning a Rumble</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/winning-a-rumble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vipe, a Vim command pipe</title>
		<link>http://pivotallabs.com/vipe-a-vim-command-pipe/</link>
		<comments>http://pivotallabs.com/vipe-a-vim-command-pipe/#comments</comments>
		<pubDate>Sat, 04 May 2013 04:16:36 +0000</pubDate>
		<dc:creator>Luan Santos</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[bloggerdome]]></category>
		<category><![CDATA[outside-in]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=18733</guid>
		<description><![CDATA[<p>When I&#8217;m doing outside-in TDD (and that is basically whenever I&#8217;m coding) I often process things as a stack. I write an acceptance level test, run it. It fails (hopefully), so I write a lower level test, let&#8217;s say, a controller test. It fails. I might need go further and write a model unit test. When I finish the inner TDD loop (say, unit on a model) I want to &#8220;pop the stack&#8221; and run the controller one, having that done, I want to run the acceptance test again. Often times the inner part of the loop takes long enough that you might forget what exactly what you were doing before, lose track of the files you had and ask your pair &#8220;what was the feature again?&#8221;. This is a general problem and I think every editor can have a tool to solve this. I couldn&#8217;t find it for the&#8230;</p><p>The post <a href="http://pivotallabs.com/vipe-a-vim-command-pipe/">Vipe, a Vim command pipe</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>When I&#8217;m doing outside-in TDD (and that is basically whenever I&#8217;m coding) I often process things as a stack. I write an acceptance level test, run it. It fails (hopefully), so I write a lower level test, let&#8217;s say, a controller test. It fails. I might need go further and write a model unit test.</p>
<p>When I finish the inner TDD loop (say, unit on a model) I want to &#8220;pop the stack&#8221; and run the controller one, having that done, I want to run the acceptance test again. Often times the inner part of the loop takes long enough that you might forget what exactly what you were doing before, lose track of the files you had and ask your pair &#8220;what was the feature again?&#8221;.</p>
<p>This is a general problem and I think every editor can have a tool to solve this. I couldn&#8217;t find it for the editors I use on a daily basis (Vim, Sublime Text or RubyMine, depending on who I&#8217;m pairing with). So I got something that we use here at Pivotal and implemented my solution on top of it for Vim.</p>
<p>The solution we have here was created to solve yet another problem, how to run tests from Vim asynchronously, that means, without blocking your editor. Most development environments have this functionality and I think it’s quite useful specially when pairing.</p>
<p>There are <a href="https://www.destroyallsoftware.com/screencasts/catalog/running-tests-asynchronously">several ways to accomplish it</a> in Vim, and we have been doing this using a unix pipe <a href="https://github.com/camelpunch/test_server">thanks to my coworker and good friend, Andrew Bruce</a>.</p>
<p>The reason why I like this setup very much for pairing is because it raises the visibility of the test results, I like them always on screen so both can see it all the time regardless of how fast you can visually parse it, it looks somewhat like this:</p>
<p><img class="alignnone size-medium wp-image-18734" alt="Screen Shot 2013-05-02 at 1.17.12 PM" src="http://pivotallabs.com/wordpress/wp-content/uploads/2013/05/Screen-Shot-2013-05-02-at-1.17.12-PM.png?48a6bc"/></p>
<p>So you have you code in a window and your test results always visible. As a bonus, if you are on OS X and using iTerm2 you can <code>⌘ + Click</code> a filename:line number to open the file in MacVim (Preferences -&gt; Profiles -&gt; Advanced, Open With Editor&#8230;, MacVim).</p>
<p>This is all very good and helps a lot. But I wanted a bit more, the first thing I noticed is that I kept wanting to run arbitrary commands that our “test_server” don’t support.</p>
<p>My fork of Andrew&#8217;s idea, <a href="https://github.com/luan/vipe">vipe</a>, is a more generic command pipe, that runs anything. With that I am able to send commands to the terminal and maybe map a key to it. For example <code>:nmap ,t :Vipe ruby &lt;c-r&gt;%&lt;cr&gt;</code> for simply running a ruby script with <code>,t</code>. To do that I removed all the ruby/rspec/rails specific functionality from the original version and <a href="https://github.com/luan/vimfiles/blob/master/lib/functions.vim#L92">moved that into my personal vim config</a>.</p>
<p>And then I implemented my most wanted <a href="https://github.com/luan/vipe/blob/master/plugin/vipe.vim#L32">stack of commands</a> in Vipe. Running a command will automatically push it into the stack, you can simply run <code>:VipePop</code> and it will run the previous command, as simple as that. Similarly <code>:VipeRerun</code> reruns the last command.</p>
<p>And that’s about it, Vipe is a command runner for vim that has a command stack and allow you to run any arbitrary command you want, I haven’t spend so much time perfecting and I think there is space for improvement. I hope you find it useful.</p>
<p>The post <a href="http://pivotallabs.com/vipe-a-vim-command-pipe/">Vipe, a Vim command pipe</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/vipe-a-vim-command-pipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fighting test pollution with an RSpec custom ordering strategy</title>
		<link>http://pivotallabs.com/find-test-pollution-rspec/</link>
		<comments>http://pivotallabs.com/find-test-pollution-rspec/#comments</comments>
		<pubDate>Thu, 25 Apr 2013 06:02:49 +0000</pubDate>
		<dc:creator>Andrew Bruce</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[bloggerdome]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[minitest]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test pollution]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=18500</guid>
		<description><![CDATA[<p>Test pollution manifests itself as seemingly false negatives or false positives in a test suite. It occurs when some shared state is unintentionally modified, or unintentionally read and used in a test. When test pollution builds up, it can mean that a project&#8217;s build fails unpredictably, which can stop a whole team from shipping code regularly. This is an expensive way to not build software. Here&#8217;s an example of test pollution. You can save and run it with Ruby if you like. You shouldn&#8217;t need anything but a recent version of Ruby. If you run it several times, it will sometimes fail and sometimes pass: Why is it so unreliable? MiniTest orders tests randomly by default. When the first test runs before the second test, the test case fails, because the first test has the effect of setting the @logged_in instance variable to true, and the second test is effectively&#8230;</p><p>The post <a href="http://pivotallabs.com/find-test-pollution-rspec/">Fighting test pollution with an RSpec custom ordering strategy</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Test pollution manifests itself as seemingly false negatives or false positives in a test suite. It occurs when some shared state is unintentionally modified, or unintentionally read and used in a test.</p>
<p>When test pollution builds up, it can mean that a project&#8217;s build fails unpredictably, which can stop a whole team from shipping code regularly. This is an expensive way to not build software.<br />
<span id="more-18500"></span><br />
Here&#8217;s an example of test pollution. You can save and run it with Ruby if you like. You shouldn&#8217;t need anything but a recent version of Ruby. If you run it several times, it will sometimes fail and sometimes pass:</p>
<script src="https://gist.github.com/5449597.js?file=test_pollution.rb"></script><noscript><pre><code class="language-ruby ruby">require 'minitest/autorun'

class User
  def self.login(username, password)
    if username == 'fred' &amp;&amp; password == '123'
      @logged_in = true
    end
  end

  def self.logged_in?
    @logged_in == true
  end
end

class UserTest &lt; MiniTest::Unit::TestCase
  def test_logs_in_if_correct_credentials_used
    User.login('fred', '123')
    assert User.logged_in?
  end

  def test_doesnt_log_in_if_incorrect_credentials_used
    User.login('bill', '321')
    refute User.logged_in?, &quot;User was logged in, but expected not to be&quot;
  end
end
</code></pre></noscript>
<p>Why is it so unreliable? MiniTest orders tests randomly by default. When the first test runs before the second test, the test case fails, because the first test has the effect of setting the @logged_in instance variable to true, and the second test is effectively expecting the value of @logged_in to be false. The code under test has <em>global state</em>: the class instance variable, @logged_in.</p>
<p>The problem with the first test is that it&#8217;s a bad citizen: it sets global state and doesn&#8217;t clean itself up. The problem with the second test is that it&#8217;s presumptuous: it relies on global state being something in particular. As an aside: the code is terrible, and the flakiness of these tests should prompt you to change it, but I used a contrived example for the purpose of demonstration.</p>
<h2>Fighting pollution with existing tools</h2>
<p>I mentioned that MiniTest orders tests randomly by default. This is a Good Thing: it&#8217;s a deliberate ploy to flush out test pollution. If you ran the above code and it failed, it would give you a &#8216;seed&#8217; number to pass in to the test, so that you could consistently run the test in the failing order. From there, you could hopefully work out why the particular order of tests failed. Both RSpec and MiniTest allow you to run tests in a random order, and both allow you to re-use the order from a previous failed run.</p>
<p>These aspects of MiniTest and RSpec are useful. They allow you to fix the order, so that you can find the dirty polluters of your test suite. This is often a quest to find two items: a polluter and a polluted test. Often you&#8217;ll find more than two, or a strange combination of tests that, when run in a particular order, cause a failed build.</p>
<p>On larger projects, these tools aren&#8217;t enough. Large codebases tend to have correspondingly large, slow test suites. Finding a source of test pollution in such beasts can involve looking at a lot of code, and can take a very long time.</p>
<h2>Why can&#8217;t we automate this?</h2>
<p>We&#8217;ve seen above that tests are reorderable chunks of code. So, you&#8217;d think that digging through reams of code just to reduce a pass/fail situation down to two examples would be an automatable process. You&#8217;d be right, but it&#8217;s not as straightforward as it ought to be.</p>
<p>When <a href="http://pivotallabs.com/team/?as=colin+o&#038;submit=%3F">my pair</a> and I first set out to write a tool to reduce tests down to their polluting / polluted components we thought we could get RSpec to output a list of files. We could then just feed the list of files back into RSpec in the order in which they failed, and use a <a href="http://en.wikipedia.org/wiki/Binary_search">binary search</a> to find the offending files.</p>
<p>Unfortunately, it&#8217;s not that easy. RSpec isn&#8217;t file-centric, but groups-and-examples-centric. For the uninitiated, an RSpec test is composed of groups and examples:</p>
<script src="https://gist.github.com/5449597.js?file=rspec.rb"></script><noscript><pre><code class="language-ruby ruby">describe &quot;some group&quot; do
  example &quot;example 1&quot; do
    expect(@triangle).to have(2).sides
  end
  
  describe &quot;some sub group&quot; do
    it &quot;has another example, using the 'it' alias&quot; do
      expect(@circle).to be_square
    end
  end
  
  example &quot;example 2&quot; do
    expect(@square).to have(3).sides
  end
end</code></pre></noscript>
<p>Once test files are processed, they&#8217;re loaded into memory and randomized regardless of file (but keeping group hierarchy intact). <a href="https://github.com/rspec/rspec-core/blob/ec10d7889192150ed40a04647cbfe70cfd2be5f0/lib/rspec/core/configuration.rb#L937-942">RSpec&#8217;s randomization algorithm</a> is pretty simplistic:</p>
<ol>
<li>Programmer: Hey RSpec, run the suite with this seed: 123</li>
<li>RSpec: I found a set of sibling groups. What should I do?</li>
<li>Randomizer: &#8216;Randomize&#8217; them according to the number of items in the set, with this seed: 123</li>
<li>RSpec: OK, I&#8217;ve got a set of sibling examples inside one of the groups. What should I do?</li>
<li>Randomizer: &#8216;Randomize&#8217; them according to the number of items in the set, with this seed: 123</li>
</ol>
<p>And so on. This approach is great so long as you don&#8217;t want to reduce the problem set. If you do reduce the set of examples that RSpec is running, the order is lost, because the number of items in the list changes.</p>
<h2>Enter The Scrubber</h2>
<p>I&#8217;d ideally like to tell a computer to go and find my test pollution. I&#8217;m some of the way there. So far, I&#8217;ve managed to create a semi-automatic solution: get RSpec to output the order of a test run to a human-readable file, so that it can be edited and fed back into RSpec to order the next run.</p>
<p><a href="https://github.com/camelpunch/scrubber">Scrubber</a> is a project I started last week that allows you to persist RSpec run orders, edit them, and replay them. It relies on a <a href="http://blog.davidchelimsky.net/2012/11/12/rspec-212-is-released/">relatively new feature of RSpec</a> that allows you to define custom ordering strategies. These strategies are just blocks of code that take as an input the list of groups or examples in a particular section of your suite, and return the groups or examples you want, in the order you want them.</p>
<p>The main stumbling block when writing the utility has been deriving a unique ID from each example or example group. The ID needs to be human readable and also reproducible across runs. So far I have a simplistic solution that just dumps the group or example description, and file location. This isn&#8217;t very unique, especially considering that RSpec has no restriction on having groups or examples with duplicate descriptions.</p>
<p>In future, I hope to use a more robust ID, perhaps a checksum of the example/group&#8217;s metadata. Again, this isn&#8217;t straightforward as some of the metadata are Proc objects. Perhaps the RSpec team would be interested in persistable suite runs as a core feature?</p>
<p>Anyway, <a href="https://github.com/camelpunch/scrubber/blob/master/examples/example.rb">here&#8217;s an example of Scrubber in use</a>. If you&#8217;re interested, I suggest you <a href="https://github.com/camelpunch/scrubber">clone the repo</a> and have a play with the example to see how editing a file might work. It&#8217;s very rough around the edges right now, but serves as a proof of concept. Hopefully I&#8217;ll get enough time, or contributors, to make this into something more automated and user-friendly.</p>
<p>The post <a href="http://pivotallabs.com/find-test-pollution-rspec/">Fighting test pollution with an RSpec custom ordering strategy</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/find-test-pollution-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Executable Documentation</title>
		<link>http://pivotallabs.com/executable-documentation/</link>
		<comments>http://pivotallabs.com/executable-documentation/#comments</comments>
		<pubDate>Sun, 03 Jun 2012 18:38:00 +0000</pubDate>
		<dc:creator>Will Read</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA["soft" ware]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/executable-documentation/</guid>
		<description><![CDATA[<p><p>I try to avoid writing static documentation. It gets old and out of date as soon as the next person comes along because it is logically far away from the code it describes, so event the best intended developers won't always be aware of the documentation dependencies. Since working at Pivotal I've enjoyed writing tests first with RSpec, which results in one form of executable documentation to describe behavior to other developers working in the code base. But what about when you need to express behavior to people outside of your code base? Maybe your stakeholders have a company requirement of documentation, maybe you're trying to entice third party developers to use your new HTTP API, or maybe you just want people to install your gem, what then? Your audience matters, and there's a variety of tools out there to use depending on your needs.</p> <a href="http://pivotallabs.com/executable-documentation/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/executable-documentation/">Executable Documentation</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I try to avoid writing static documentation. It gets old and out of date as soon as the next person comes along because it is logically far away from the code it describes, so event the best intended developers won&#8217;t always be aware of the documentation dependencies. Since working at Pivotal I&#8217;ve enjoyed writing tests first with RSpec, which results in one form of executable documentation to describe behavior to other developers working in the code base. But what about when you need to express behavior to people outside of your code base? Maybe your stakeholders have a company requirement of documentation, maybe you&#8217;re trying to entice third party developers to use your new HTTP API, or maybe you just want people to install your gem, what then? Your audience matters, and there&#8217;s a variety of tools out there to use depending on your needs.</p>
<h2>Human Readable</h2>
<p>Cucumber is one tool that can be used to fill this need. It&#8217;s designed to be a DSL for creating DSLs to describe your application. It has a nice attribute that it is very human readable. You can then use tools like <a href="https://www.relishapp.com/">Relish</a> to publish docs from your Cucumber suite. The drawback is that you put a lot of effort in to expressing what you want in English, which is great if you&#8217;re really showing this to non-technical people, but it can be an over optimization if your readers have some technical context.</p>
<h2>Dev Readable</h2>
<p>In the case where your audience is an outside developer, something like <a href="https://github.com/zipmark/rspec_api_documentation">rspec_api_documentation</a> might be more appropriate. It layers on a DSL to your familiar RSpec DSL that lends itself to HTTP APIs. This is great because your RSpec tests become more expressive without the overhead of defining the DSL yourself. From there, you run a rake task to generate HTML. Your spec runs will fail if your docs get out of sync, which should be never if you have CI. The web is an easy venue to consume this kind of information, but the tool doesn&#8217;t let you editorialize much beyond the description of the resource and the parameters. </p>
<h2>The Best of Both Worlds</h2>
<p>One of our open source projects here at Pivotal Labs is Jasmine, a JavaScript testing framework that runs in the browser. Unlike Rspec where you need to have ruby installed and a database set up and so on, everyone has a browser. Check out the <a href="http://pivotal.github.com/jasmine/">jasmine docs</a> and scroll to the bottom. That&#8217;s right, the examples are tests, the comments are close to the tests so when the test fails you know to update the text as well, and now someone has a working example of how to use Jasmine all in one. The page itself is generated using <a href="http://rtomayko.github.com/rocco/">Rocco</a>, a Ruby port of <a href="http://jashkenas.github.com/docco/">Docco</a>.With the combination of docs generated from tests, and tests that run in the browser you get this perfect blend of readable, easy to maintain documentation that is available to your entire audience. </p>
<p>Sometimes you have to provide documentation, but that doesn&#8217;t mean it has to be outdated. By creating executable documentation you can have confidence that the code and docs are staying in sync. Consider your audience carefully when choosing how you will document your software and know that there are more than a handful of options available, one of which will probably suit your task well. </p>
<p>The post <a href="http://pivotallabs.com/executable-documentation/">Executable Documentation</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/executable-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing mass assignment with RSpec-Shoulda</title>
		<link>http://pivotallabs.com/testing-mass-assignment-with-rspec-shoulda/</link>
		<comments>http://pivotallabs.com/testing-mass-assignment-with-rspec-shoulda/#comments</comments>
		<pubDate>Mon, 28 May 2012 15:20:00 +0000</pubDate>
		<dc:creator>Mark Rushakoff</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/testing-mass-assignment-with-rspec-shoulda/</guid>
		<description><![CDATA[<p><p>If you're new to Rails, or if you've been using Rails 2 for a long time, you might not be aware that Shoulda offers an <code>allow_mass_assignment_of</code> matcher that works just like it sounds.  Here's the example from <a href="https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb">the source code</a>:</p>

<pre><code>it { should_not allow_mass_assignment_of&#40;:password&#41; }
it { should allow_mass_assignment_of&#40;:first_name&#41; }
</code></pre>

<p>Having explicit tests for whether fields should  be mass-assignable is probably safer than letting developers arbitrarily add or remove fields from the <code>attr_accessible</code> declarations -- at least when they break a test they'll have to think twice about it.</p> <a href="http://pivotallabs.com/testing-mass-assignment-with-rspec-shoulda/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/testing-mass-assignment-with-rspec-shoulda/">Testing mass assignment with RSpec-Shoulda</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re new to Rails, or if you&#8217;ve been using Rails 2 for a long time, you might not be aware that Shoulda offers an <code>allow_mass_assignment_of</code> matcher that works just like it sounds.  Here&#8217;s the example from <a href="https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb">the source code</a>:</p>
<pre><code>it { should_not allow_mass_assignment_of&#40;:password&#41; }
it { should allow_mass_assignment_of&#40;:first_name&#41; }
</code></pre>
<p>Having explicit tests for whether fields should  be mass-assignable is probably safer than letting developers arbitrarily add or remove fields from the <code>attr_accessible</code> declarations &#8212; at least when they break a test they&#8217;ll have to think twice about it.</p>
<p>The post <a href="http://pivotallabs.com/testing-mass-assignment-with-rspec-shoulda/">Testing mass assignment with RSpec-Shoulda</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/testing-mass-assignment-with-rspec-shoulda/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pivotal: Why It Works</title>
		<link>http://pivotallabs.com/pivotal-why-it-works/</link>
		<comments>http://pivotallabs.com/pivotal-why-it-works/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 03:23:00 +0000</pubDate>
		<dc:creator>Will Read</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA["soft" ware]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[breakfast]]></category>
		<category><![CDATA[pairing]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/pivotal-why-it-works/</guid>
		<description><![CDATA[<p><p>My name is Will, I'm 30 years old, and I'm a Pivot. In my three year tenure here at Pivotal Labs, I've found that it may be easy to see the parts that make us successful consultants, but that forrest is hard to see for all the trees. Everything from breakfast to keybindings plays a part in making us one of the top software consultancies and the greatest place I have ever worked. </p> <a href="http://pivotallabs.com/pivotal-why-it-works/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/pivotal-why-it-works/">Pivotal: Why It Works</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>My name is Will, I&#8217;m 30 years old, and I&#8217;m a Pivot. In my three year tenure here at Pivotal Labs, I&#8217;ve found that it may be easy to see the parts that make us successful consultants, but that forrest is hard to see for all the trees. Everything from breakfast to keybindings plays a part in making us one of the top software consultancies and the greatest place I have ever worked. </p>
<p>My story starts with breakfast and ends with trust. Each piece plays in to another, and the result is an environment where teams are autonomous, culture and knowledge spread quickly and organically, and communication is never a secondary priority. Our clients see the results in the way which we interact with them to deliver exactly what they need. My coworkers feel it when they realize they control their own destiny and have all the power to make their situation better. You hear it when you listen to pivots like myself or others who appear at conferences across the globe. What we have here is special.</p>
<h1>Breakfast &#8211; The Most Important Meal of the Day</h1>
<p>We have breakfast prepared for us by an outstanding catering staff. It is delicious and you should be jealous if only because it means that there&#8217;s one less thing I have to do in the morning. It isn&#8217;t just food though, and it isn&#8217;t a ploy to eek out more hours from pivots like other companies that might provide dinner in hopes that you don&#8217;t leave till midnight. No, breakfast is much deeper than eggs and bacon &#8211; it&#8217;s a time to cross pollinate, to talk to the pivots who aren&#8217;t on your team to share in things both work and non-work related. It also gets us to the office at the same time, which makes it easy to pair together for eight hours, then we all go home together at six, and breakfast leads us right in to our all company standup.</p>
<h1>Standup &#8211; You&#8217;re Not Alone</h1>
<p>Yes, the whole body of developers participate in the biggest, most high value standup you&#8217;ve ever seen. At pivotal you&#8217;re never alone, and company standup is just one of the ways we assure that is always true. When you have hired the best &#40;more on that later&#41;, why wouldn&#8217;t you want them all to be on every team all the time? Since mitosis of humans hasn&#8217;t left science fiction yet, we have to settle for osmosis. We go over who is new or visiting the office, who needs help, and what interesting stuff has come up that might be relevant to other teams. You can read our standup notes right here at <a href="https://pivotallabs.com/blabs">pivotallabs.com/blabs</a>. Culture starts here too. Company jokes develop over time as we all gripe about the bumpy release process a particular tool is going through. Company standup also makes it clear that it is okay to not know things. Let me say that again: It is okay to not know something. </p>
<p>Another pivot, Davis Frank, shared an analogy that resonated, but since my Bruce Lee knowledge leaves most wanting, I have adapted it to a much geekier Star Trek take. Being a pivot is akin to being a senior officer on the bridge of the Enterprise. We hire people who will speak up and collaborate, people who will work to make exploration sustainable. We all come to Pivotal Labs with our own expertise like Jordi with his engineering skills, and Beverly the medical doctor, but the very nature of working with startups and our other clients means that we are always going &#8220;where no one has gone before&#8221; with respect to code, and sometimes the ship&#8217;s councilor has to hot wire a tricorder. There is no manual on how to build Twitter or Groupon. Pivotal never gave me the answers to those problems, that&#8217;s not how we work. Instead, Pivotal, like Star Fleet, exposed me to a lot of problems all the time and gave me the resources and teams to help me solve them as I encountered them. </p>
<h1>Pair Programming &#8211; The Trust Builder You&#8217;re Already Doing</h1>
<p>After company standup and our own team standup, we pair program. That means two people, one computer, all day. It isn&#8217;t half as radical as it may seem at first glance. Has anyone at your standups ever asked for help? Did someone then go over and sit with that person at one computer? I suspect they did. Do you do code reviews? Then aren&#8217;t you really asking your team to share coding knowledge and culture? Think about it. This is what pairing is all about, we&#8217;re just set up to do it a lot more often. And getting back to trust, pairing turns a potentially threatening code review process in to a co-ownership process.</p>
<p>Pairing builds trust in all directions. It builds trust between the pair and the client accepting the user stories because I know that two people have thought about this problem. I also know that any cultural nuances that one pivot has picked up are being shared inline with the other pivot. Pairing builds trust between devs. If you talk about code with someone for eight hours a day you can&#8217;t help but understand how he approaches problems. That said, you may not always agree, but at least you understand, and you can have much deeper, more meaningful collaborations when that understanding is in place. Pairing develops trust between the team and the individual because I know that if a feature fails, I am not alone in the failure, and if the feature succeeds, I will have good company to celebrate the success. </p>
<p>Talking about code for an entire work day is hard, I won&#8217;t pull any punches there. Think about the last time you were in a long white boarding session. I might have been needed, and possibly energizing, but I bet you also needed to decompress for at least fifteen minutes after. Pairing is like that, so we find other ways to communicate that also happen to feed in to the trust: Test Driving. Write tests first; that way, as your pair, I know what we&#8217;re about to work on for the next five to twenty minutes. Writing tests first is a great way to enhance your pair&#8217;s understanding of how you&#8217;re thinking about a problem and the potential solution. Once you have the test, it has the added benefit of speaking to future devs who might work on this code and communicate what it was meant to do so they can make an informed decision whether you&#8217;re available or not. Speaking of which, since we rotate between projects, someone not being there is more than just a possibility, it&#8217;s just a matter of time.</p>
<h1>Rotate your Pivots Every Six Months or 10,000 Spec Runs</h1>
<p>The average pivot is on a project for 3-6 months, some stay longer, some are shorter if their leadership is needed elsewhere, but in general you can count on seeing a good number of projects in three years&#8217; time. On one project you might make a JSON API, and on the next you&#8217;re up to your eyeballs in JavaScript, HAML, and CSS. Then it might be off to help a company scale and tune performance. We swap people around and expect them to be adding value on a new project day one. We do that by standardizing on a few things about our workstations. For starters, every computer is basically the same minus the project code itself. Our ops team has done a great job of having an updatable workstation image that is under test so they know when it breaks. After many holy wars, we&#8217;ve also come to an arrangement about which IDE and keybindings to use. The choices may not always be &#8220;the best&#8221; when getting down to specifics, but it is one less hurdle to jump when you find yourself on a new project with new faces, new clients, and new domain &#8211; at least your computer feels like the home you just left. It also means I don&#8217;t have to think about how to set up a machine when starting a new project, the collective knowledge of Pivotal workstation config is captured in our machine image.</p>
<p>Rotation is a razor sharp double edged sword. Your average dev working for a product company might switch teams once in three years. Meanwhile at Pivotal Labs, I&#8217;m seeing new problems and new solutions at a rate 3-6 times that. It means that I can demonstrate loyalty by staying at one company, but the experience of working for ten companies in that same timeframe. Rotation makes our best pivots that much better. The downside of course is that someone who demonstrates loyalty but possesses the experience that is characteristic of a  senior pivot soon finds himself being invited to take on lucrative and dazzling roles elsewhere. I can&#8217;t begin to explain the sadness and frustration I feel when a pivot leaves the company, but we also can&#8217;t afford not to train up our employees. It is the same high quality that makes pivots hirable that brings in the steady stream of clients to Pivotal Labs. If we stunted or slowed that growth any way, it would weaken our offering in a way that would undermine much of what is good about Pivotal Labs.</p>
<h1>Hire the Best</h1>
<p>We are unwavering when it comes to hiring. When you come in for an interview, you write code on real product because that&#8217;s what we&#8217;re expecting you to do when you&#8217;re here everyday, not solve brain teasers at some white board. We want to know if you can communicate, and we want to know if you can learn and adapt. Pivotal throws pivots in to uncharted waters a lot and we expect pivots to swim. They always do because we hire great swimmers. Hiring great people means we don&#8217;t have to spend a lot of time with formal training, or managing, because people are good citizens within the company. Also, hiring great people who raise the average and are put in a place where they pair and rotate means that the average really does go up for everyone. This has an awesome effect on morale, and serves to give us all the confidence that we need to takle new problems. Having the best means that teams can be autonomous and we can trust them to interact directly with the client eight hours a day. We don&#8217;t have any need for the &#8220;heros&#8221; or the &#8220;ninjas&#8221; who can strap on headphones and have a caffeine-induced flow session. We hire largely for technical aptitude and ability to communicate which is not most developers. When you&#8217;ve hired the best for this business, delivering features comes naturally.</p>
<h1>Focusing Priorities with Pivotal Tracker</h1>
<p>The real magic of Pivotal Labs that you might not notice at first is Pivotal Tracker. It may look like an ordinary project tracking system, but it does two things very well that most software fails to do: 1&#41; Tracker forces clients to prioritize the work we do for them, and 2&#41; it serves as a central communication piece. The former is very important to the success of the project. I&#8217;d like to think that because of all the other things we do, we produce more features period, but that&#8217;s not the whole picture. Because everything is prioritized, we produce the right features, or at least the features the client wants the most. It is hard for a client to be dissatisfied when we&#8217;re always working on the most important thing. We know it is the most important thing because we&#8217;ve talked about it. Tracker is the main talking point in our short, weekly meeting so we know that our client wants these features first, we talk about any technical needs we have on our side, and discuss the story details beyond what is typed in Tracker. Remember how I said it all plays in together? Well since we all sit together, and we all trust each other, it greatly reduces the need to spec out every last detail &#8211; most of the time we have enough context to make well informed decisions, or we can turn around and ask our client for clarification, or baring that we deliver a story and get some great feedback in the form of a rejected story. At Pivotal, you&#8217;d have to work really hard to not deliver what the customer wanted.</p>
<h1>Feedback &#8211; Always, Everywhere</h1>
<p>Being an Agile shop means we&#8217;re always gathering feedback and looking for ways to do our job better. Each project is different, so we have regular retrospectives to help us surface and adapt to those differences. This exercise is focused on getting better, and depends on honesty and therefore builds trust in a team. This goes hand-in-hand with hiring the best, because the best speak up and the best aren&#8217;t afraid to say something scary or controversial. The best lay their ego aside in order to improve a team, project, or a company. I strongly believe that, if left alone, the right people with retrospectives would arrive at a process that looks a lot like Pivotal Labs does today &#8211; in fact I would argue that&#8217;s what happened when the idea of Agile was first put to paper by Beck, Fowler and the rest of the Agile work group. Get and give feedback, act on that feedback, that&#8217;s the core. Action however, doesn&#8217;t always lead to success at first try.</p>
<h1>If at First&#8230;</h1>
<p>In fact, taking action leads to failure a bunch. Since the set of problems, both human and technical is huge and enormously complicated, it is reasonable to assume that most guesses at actions would end in failure. But guess what, we fail, get feedback, take action, and over time, those actions lead to successful actions. Often times the success is very different than it was originally pictured. We also have the benefit of having that experience that can now be applied to a future project. Pivotal Labs is good about making it safe to fail. Read that again, it is safe to fail here. Why? Because we start with the best, then we give them a lot of experience, and we trust them to make the best decision given the information and experience they have. And because we&#8217;ve hired for it, teams own their failures, and they&#8217;re intrinsically motivated to do better. No one has to sit over their shoulder and tell them it went wrong. They know, and as a matter of pride they&#8217;ll fix it. Most importantly, they have the skill set and the resources to fix it. </p>
<h1>Greater Than the Sum of its Parts</h1>
<p>By now you should be hearing it in your head, that it all feeds in to itself. The whole thing works because it is complete. Each part, start time, pairing, test driving, hiring, clear priorities, and feedback contribute more to the system than just its stand-alone value. The pieces are all obvious, but how they interrelate and build trust across the organization is what makes Pivotal an outstanding company. My name is Will, and this is why I&#8217;m a pivot. </p>
<p>If you&#8217;re looking for developers, and you want to get the most important things done, I hope you&#8217;ll consider becoming one of our clients, we do web and mobile work and you can drop us a line at <a href="mailto:sales@pivotallabs.com">sales@pivotallabs.com</a>. If this resonated with you and you&#8217;re looking for a job as a developer, please send  your resume to <a href="http://pivotallabs.com/jobs">pivotallabs.com/jobs</a>. </p>
<p>The post <a href="http://pivotallabs.com/pivotal-why-it-works/">Pivotal: Why It Works</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/pivotal-why-it-works/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Standup 11/17/2011 &#8211; Cloudy Cloud</title>
		<link>http://pivotallabs.com/standup-11-17-2011-cloudy-cloud/</link>
		<comments>http://pivotallabs.com/standup-11-17-2011-cloudy-cloud/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 17:37:00 +0000</pubDate>
		<dc:creator>Glenn Jahnke</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/standup-11-17-2011-cloudy-cloud/</guid>
		<description><![CDATA[<p><h1>Interestings</h1>

<h2>Travis CI: Javascript Testing in the Cloud</h2>

<p>Jasmine gem test suites are now being run on Travis CI which is an open, distributed build system for the open source community.</p>

<p>Check out <a href="http://travis-ci.org/">Travis CI</a>.</p>

<h2>Fix Git Author</h2>

<p>As Pivots move to different machines frequently when we pair switch, its often a problem that we forget to switch the author when we commit to Git. Here's how you can fix the author of a commit &#40;before you've pushed to remote&#41;.</p>

<ol>
<li>change your git author</li>
<li>git commit --amend --reset-author -C HEAD</li>
</ol>

<p>This changes the author of commit to whomever is configured in the git config, and uses the same message you previously used &#40;the -C HEAD part&#41;.</p>

<h2>TDDium Cloud Test Runner</h2>

<p><a href="https://www.tddium.com/">TDDium</a> is an easy-to-use, secure, hosted testing environment that takes the tedium out of building high quality Ruby web applications using Test Driven Development and Continuous Integration.</p> <a href="http://pivotallabs.com/standup-11-17-2011-cloudy-cloud/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/standup-11-17-2011-cloudy-cloud/">Standup 11/17/2011 &#8211; Cloudy Cloud</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h1>Interestings</h1>
<h2>Travis CI: Javascript Testing in the Cloud</h2>
<p>Jasmine gem test suites are now being run on Travis CI which is an open, distributed build system for the open source community.</p>
<p>Check out <a href="http://travis-ci.org/">Travis CI</a>.</p>
<h2>Fix Git Author</h2>
<p>As Pivots move to different machines frequently when we pair switch, its often a problem that we forget to switch the author when we commit to Git. Here&#8217;s how you can fix the author of a commit &#40;before you&#8217;ve pushed to remote&#41;.</p>
<ol>
<li>change your git author</li>
<li>git commit &#8211;amend &#8211;reset-author -C HEAD</li>
</ol>
<p>This changes the author of commit to whomever is configured in the git config, and uses the same message you previously used &#40;the -C HEAD part&#41;.</p>
<h2>TDDium Cloud Test Runner</h2>
<p><a href="https://www.tddium.com/">TDDium</a> is an easy-to-use, secure, hosted testing environment that takes the tedium out of building high quality Ruby web applications using Test Driven Development and Continuous Integration.</p>
<p>The post <a href="http://pivotallabs.com/standup-11-17-2011-cloudy-cloud/">Standup 11/17/2011 &#8211; Cloudy Cloud</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/standup-11-17-2011-cloudy-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interacting with popup windows in Cucumber/Selenium</title>
		<link>http://pivotallabs.com/integration-testing-oauth-with-vcr-and-webmock/</link>
		<comments>http://pivotallabs.com/integration-testing-oauth-with-vcr-and-webmock/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 04:00:00 +0000</pubDate>
		<dc:creator>Pivotal Labs</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/integration-testing-oauth-with-vcr-and-webmock/</guid>
		<description><![CDATA[<p><p>OAuth providers like LinkedIn often pop-up in a new browser window rather than in Javascript so that the user entering their credentials can see the location bar to be sure they are not being phished by the website requesting their credentials. This is great for security, but not so great for Cucumber testing.</p>

<h3>features/signup.feature</h3>

<pre><code>Scenario: Sign Up with LinkedIn
  When I go to the home page
  And I follow "Sign Up"
  And I grant LinkedIn access
  Then I should be on the new user page
</code></pre>

<p>My application has a hyperlink that opens the OAuth login on the OAuth provider's website in a new window. Let's presume the simple matter of wiring this up is already coded in my view.</p>

<p>Testing this with Cucumber requires telling the Selenium web driver to interact with the new popup window. We can do this using page.driver.browser.window_handles to find the newest window handle and scoping out actions to that window.</p>

<h3>features/support/signup_steps.rb</h3>

<pre><code>When /^I grant LinkedIn access$/ do
  begin
    main, popup = page.driver.browser.window_handles
    within_window&#40;popup&#41; do
      fill_in&#40;"Email", :with =&#62; "newlee@pivotallabs.com"&#41;
      fill_in&#40;"Password", :with =&#62; "password"&#41;
      click_on&#40;"Ok, I'll Allow It"&#41;
    end
  rescue
  end
end
</code></pre>

<p>And that's it!</p>

<p>Keep in mind that if you use this test as-is, you will be hitting LinkedIn on the real Internet. This is great if you want a test that will always verify the real API, but not so good for CI, since it is Internet connection-dependent and slow. Consider using something like <a href="https://github.com/myronmarston/vcr">VCR</a> or <a href="https://github.com/wycats/artifice">Artifice</a> to stub out your service calls.</p> <a href="http://pivotallabs.com/integration-testing-oauth-with-vcr-and-webmock/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/integration-testing-oauth-with-vcr-and-webmock/">Interacting with popup windows in Cucumber/Selenium</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>OAuth providers like LinkedIn often pop-up in a new browser window rather than in Javascript so that the user entering their credentials can see the location bar to be sure they are not being phished by the website requesting their credentials. This is great for security, but not so great for Cucumber testing.</p>
<h3>features/signup.feature</h3>
<pre><code>Scenario: Sign Up with LinkedIn
  When I go to the home page
  And I follow "Sign Up"
  And I grant LinkedIn access
  Then I should be on the new user page
</code></pre>
<p>My application has a hyperlink that opens the OAuth login on the OAuth provider&#8217;s website in a new window. Let&#8217;s presume the simple matter of wiring this up is already coded in my view.</p>
<p>Testing this with Cucumber requires telling the Selenium web driver to interact with the new popup window. We can do this using page.driver.browser.window_handles to find the newest window handle and scoping out actions to that window.</p>
<h3>features/support/signup_steps.rb</h3>
<pre><code>When /^I grant LinkedIn access$/ do
  begin
    main, popup = page.driver.browser.window_handles
    within_window&#40;popup&#41; do
      fill_in&#40;"Email", :with =&gt; "newlee@pivotallabs.com"&#41;
      fill_in&#40;"Password", :with =&gt; "password"&#41;
      click_on&#40;"Ok, I'll Allow It"&#41;
    end
  rescue
  end
end
</code></pre>
<p>And that&#8217;s it!</p>
<p>Keep in mind that if you use this test as-is, you will be hitting LinkedIn on the real Internet. This is great if you want a test that will always verify the real API, but not so good for CI, since it is Internet connection-dependent and slow. Consider using something like <a href="https://github.com/myronmarston/vcr">VCR</a> or <a href="https://github.com/wycats/artifice">Artifice</a> to stub out your service calls.</p>
<p>The post <a href="http://pivotallabs.com/integration-testing-oauth-with-vcr-and-webmock/">Interacting with popup windows in Cucumber/Selenium</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/integration-testing-oauth-with-vcr-and-webmock/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 3/9 queries in 0.026 seconds using apc
Object Caching 1204/1222 objects using apc

 Served from: pivotallabs.com @ 2013-05-21 14:57:11 by W3 Total Cache -->