<?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>All Things (v8) &#187; Cucumber</title>
	<atom:link href="http://www.anthonyeden.com/category/ruby/cucumber-ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anthonyeden.com</link>
	<description>Technology Blog</description>
	<lastBuildDate>Sat, 19 Nov 2011 18:06:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Presentations in Stockholm</title>
		<link>http://www.anthonyeden.com/2011/03/presentations-in-stockholm/</link>
		<comments>http://www.anthonyeden.com/2011/03/presentations-in-stockholm/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 14:27:30 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=191</guid>
		<description><![CDATA[This month I had the pleasure of traveling up to Stockholm to speak at a couple of events there. First let me just say that Stockholm is an amazing city full of style, character and charm. From classic coffee houses to modern restaurants there is something for anyone. I highly recommend visiting if you have [...]]]></description>
			<content:encoded><![CDATA[<p>This month I had the pleasure of traveling up to Stockholm to speak at a couple of events there. First let me just say that Stockholm is an amazing city full of style, character and charm. From classic coffee houses to modern restaurants there is something for anyone. I highly recommend visiting if you have a chance &#8211; you won&#8217;t regret it.</p>
<p>While I was there I gave a talk called &#8220;Why Ruby, Why Now?&#8221; at the first dyncon as well as a talk titled Harnessing Cucumber at Valtech Labs. The first talk was an introduction to Ruby. I have been itching to give an introductory talk for a while and I&#8217;m glad this gave me the chance. The audience was a bit more knowledgeable about Ruby than I expected, so some of the items weren&#8217;t new to them, however I believe there was still enough in the talk to keep people interested. I also blazed through it since it was right before lunch so maybe people were enthralled merely by my lightning-fast presentation skills. <img src='http://www.anthonyeden.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  The presentation is available online on Github: <a href="https://github.com/aeden/presentation_why_ruby">https://github.com/aeden/presentation_why_ruby</a> and was created using Scott Chacon&#8217;s <a href="https://github.com/schacon/showoff">Show Off</a>.</p>
<p>The second talk I gave was an intermediate to advanced talk on Cucumber where I covered a lot of what I have learned about Cucumber over the last year of using it. Cucumber has become an important part of my test suites because it allows me to test the experience of using my software. This talk covered some of the various command-line switches and cucumber.yml configuration options in the first section and then moves onto testing APIs and CLIs. I&#8217;ve found that testing both of these interfaces to my applications has helped tremendously in improving the application and at the same time providing a safety net for refactoring, which is exactly what I want from Cucumber. This talk is available <a href="http://dl.dropbox.com/u/3308516/harnessing_cucumber.pdf">as a PDF</a> and was created using Keynote.</p>
<p>I appreciate the support from both of the audiences and the discussions that followed both talks and I look forward to the opportunity to visit Stockholm again in the not-to-distant future. Thanks as well to Peter Svensson for putting together dyncon and to Peter Lind for opening up the Valtech offices for my talk there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2011/03/presentations-in-stockholm/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Testing REST APIs with Cucumber and Rack::Test</title>
		<link>http://www.anthonyeden.com/2010/11/testing-rest-apis-with-cucumber-and-rack-test/</link>
		<comments>http://www.anthonyeden.com/2010/11/testing-rest-apis-with-cucumber-and-rack-test/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 21:44:22 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[DNSimple]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=173</guid>
		<description><![CDATA[Corey Haines has been staying here in South France with me for the last few days and we had been meaning to pair up on some coding tasks, but hadn&#8217;t been able to until today. I had in my mind already what I wanted to work on and he was happy to oblige. Our task [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://coreyhaines.com/">Corey Haines</a> has been staying here in South France with me for the last few days and we had been meaning to pair up on some coding tasks, but hadn&#8217;t been able to until today. I had in my mind already what I wanted to work on and he was happy to oblige. Our task was to set up some cucumber features that would describe the <a href="https://dnsimple.com/documentation/api">DNSimple REST API</a> properly, allowing all of the available end points to be tested. I had worked on this in the past trying to use Webrat, but since moving the DNSimple code to Rails 3 I&#8217;ve switched to Capybara none of the old code worked. Additionally the old code was only able to handle GET requests and never properly handled POST, PUT and DELETE, nor did it handle the various content types supported by the API.</p>
<p>This evening Corey and I sat down and started looking into how we could make the tests live again. First we attempted to use Capybara directly, but ran into issues when trying to set HTTP headers. The DNSimple API uses Basic HTTP Authentication and thus we needed to set the header for that. We also need to set the Content-Type and Accept headers to ensure that Rails handles the input and output correctly. After peeling back some layers of the Capybara onion we landed upon Rack::Test. When using Rack, Capybara delegates request and response handling down to <a href="http://github.com/brynary/rack-test">Rack::Test</a>. At this point we decided to see if we could use Rack::Test directly in our step definitions, and it worked like a charm.</p>
<p>Rack::Test has a module called Rack::Test::Methods that can be mixed into a class to provide it with methods for get, post, put, delete as well as last_request, last_response, header and more. We mixed Rack::Test::Methods into the Cucumber world at the top of our API steps file like so:</p>
<p><script src="http://gist.github.com/660319.js?file=gistfile1.rb"></script></p>
<p>Then our steps could simply call the Rack::Test methods directly. For example, here&#8217;s how to send the HTTP Basic Auth header:</p>
<p><script src="http://gist.github.com/660321.js?file=gistfile1.rb"></script></p>
<p>And to set content type and accept headers:</p>
<p><script src="http://gist.github.com/660323.js?file=gistfile1.rb"></script></p>
<p>And finally to actually send requests and test the responses. The entire api_steps.rb as it is right now looks like this:</p>
<p><script src="http://gist.github.com/660331.js?file=api_steps.rb"></script></p>
<p>And here is an example of a Cucumber feature that uses the API steps:</p>
<p><script src="http://gist.github.com/660337.js?file=list_domains.feature"></script></p>
<p>I doubt we&#8217;ve ended up with the ultimate final set of steps that can be used repeatedly for testing RESTful APIs, however I think it is an excellent start. I&#8217;m still on the fence about how to check the response body, specifically whether it is better to match the response body as a string or to actually parse it and write custom steps for each of the different types of objects, but time will tell.</p>
<p>As usual pairing with Corey resulted in some good code, a usable solution and something that I think others will benefit from as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2010/11/testing-rest-apis-with-cucumber-and-rack-test/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

