<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: Tag sake</title>
    <link>http://blog.kineticweb.com/articles/tag/sake</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>Automagical RSpec: Sake Spec for your Scripts</title>
      <description>&lt;p&gt;I&amp;#8217;ve been trying to attempt at spec&amp;#8217;ing every single tiny lil script and bit of code I write a long the way. This means I needed a quick, cross directory/app/project script that would run specs from the current directory.&lt;/p&gt;


	&lt;p&gt;I love Rake, and I love Sake even more.. and Sake was born to do this sort of system-wide task&amp;#8230; so lets get to the code!&lt;/p&gt;


	&lt;p&gt;Throw this in your ~/.sake and smoke it:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_shell "&gt;desc 'runs specs in the current project, with its own SpecHelper setup'
task 'spec' do
  require 'rake'
  require 'spec/rake/spectask'

  module SpecBase
    def self.included(klass)
      Object.class_eval do
        require 'rubygems'
        require 'spec'
        Spec::Runner.configure { |config| config.mock_with(:mocha) }
      end
    end
  end

  Spec::Rake::SpecTask.new(&amp;quot;spec&amp;quot;) do |t|
    t.spec_opts  = [&amp;quot;--format&amp;quot;, &amp;quot;specdoc&amp;quot;, &amp;quot;--colour&amp;quot;]
    t.spec_files = Dir[&amp;quot;spec/**/*_spec.rb&amp;quot;, &amp;quot;./*_spec.rb&amp;quot;].sort
    include SpecBase
  end
end&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;As the description string states, this task encapsulates spec_helper.rb and runs any _spec.rb files in the current directory. This makes it very quick for writing specs for small scripts.&lt;/p&gt;


	&lt;p&gt;Of course, I try to maintain a convention of naming my spec&amp;#8217;s just like in Spec::Rails. So if I&amp;#8217;m writing a eat_bacon.rb script, I use eat_bacon_spec.rb as the spec file.&lt;/p&gt;


	&lt;p&gt;Also note: I&amp;#8217;m loading Mocha up there, so make sure to take that out if you don&amp;#8217;t need it.&lt;/p&gt;


	&lt;p&gt;Enjoy, with Sake!&lt;/p&gt;</description>
      <pubDate>Wed, 16 Apr 2008 21:18:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:80b44ade-e540-4673-978a-e85bf302bd7a</guid>
      <author>Justin Reagor</author>
      <link>http://blog.kineticweb.com/articles/2008/04/16/automagical-rspec-sake-spec-for-your-scripts</link>
      <category>rspec</category>
      <category>sake</category>
      <category>tasks</category>
    </item>
  </channel>
</rss>
