<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: docs code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 14:23:36 GMT</pubDate>
    <description>DZone Snippets: docs code</description>
    <item>
      <title>Rake Task for BDD Docs</title>
      <link>http://snippets.dzone.com/posts/show/2508</link>
      <description>From http://www.reevoo.com/blogs/bengriffiths/2005/06/24/a-test-by-any-other-name/:&lt;br /&gt;&lt;br /&gt;We find that the pattern &#8216;test_should_***_on_***&#8217; a useful way of naming tests &#8211; it&#8217;s an idea stolen from JBehave . If this test were to fail, I&#8217;m reminded that I should (!) ask myself the question &#8216;should the class I&#8217;m testing do this?&#8217; before I go on a bug-hunt. The other advantage is that I can use my test classes to generate some simple documentation for my classes. Here&#8217;s a rake target that can do just that:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;desc "Generate agiledox-like documentation for tests"&lt;br /&gt;task :agiledox do&lt;br /&gt;  tests = FileList['test/**/*_test.rb']&lt;br /&gt;  tests.each do |file|&lt;br /&gt;    m = %r".*/([^/].*)_test.rb".match(file)&lt;br /&gt;    puts m[1]+" should:\n"&lt;br /&gt;    test_definitions = File::readlines(file).select {|line| line =~ /.*def test.*/}&lt;br /&gt;    test_definitions.each do |definition|&lt;br /&gt;      m = %r"test_(should_)?(.*)".match(definition)&lt;br /&gt;      puts " - "+m[2].gsub(/_/," ")&lt;br /&gt;    end&lt;br /&gt;  puts "\n"&lt;br /&gt; end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;An example from our codebase, typing rake agiledox generates:&lt;br /&gt;&lt;br /&gt;security_controller should:&lt;br /&gt; - redirect to page stored in session on successful login&lt;br /&gt; - store user object in session on successful login&lt;br /&gt; - redirect to page stored in session after signup&lt;br /&gt; - store user object in session after signup&lt;br /&gt; - reject signup when passwords do not match&lt;br /&gt; - reject signup when login too short&lt;br /&gt; - report both errors if passwords dont match and username too short&lt;br /&gt; - not store user in session if password not correct on signup&lt;br /&gt; - remain on login page if password not correct on signup&lt;br /&gt; - remove user from session on log out</description>
      <pubDate>Thu, 31 Aug 2006 19:00:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2508</guid>
      <author>MattScilipoti (Matt Scilipoti)</author>
    </item>
    <item>
      <title>Quick aliases for common searches in firefox</title>
      <link>http://snippets.dzone.com/posts/show/1327</link>
      <description>Often I end up doing searches on a specfic site using google alot. For instance, the api for rubyonrails documentation.&lt;br /&gt;Instead of using my previous tip *each* time  http://www.bigbold.com/snippets/posts/show/1325 :&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;site:api.rubyonrails.com submit_tag&lt;br /&gt;&lt;/code&gt; &lt;br /&gt;&lt;br /&gt;I made a keyword bookmark inside firefox. &lt;br /&gt;Basically, create a new bookmark in firefox and make the url &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;http://www.google.com/search?hl=en&amp;q=site%3Aapi.rubyonrails.com+%s&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Give this a short name like api or ror&lt;br /&gt;then in your search bar you can type &lt;br /&gt;api submit_tag and watch the results float in.&lt;br /&gt;&lt;br /&gt;Other useful searches i've found are,&lt;br /&gt;&lt;br /&gt;the Ruby on Rails mailling list:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;http://www.google.com/search?hl=en&amp;q=site%3Ahttp%3A%2F%2Fwrath.rubyonrails.org%2Fpipermail%2Frails%2F+%s&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The PostgreSQL 8.1 Documentation:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;http://www.google.com/search?hl=en&amp;lr=&amp;q=site%3Ahttp%3A%2F%2Fwww.postgresql.org%2Fdocs%2F8.1%2Finteractive%2F+%s&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 01 Feb 2006 02:50:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1327</guid>
      <author>nihilist (David)</author>
    </item>
  </channel>
</rss>
