<?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: Automagical RSpec: Sake Spec for your Scripts</title>
    <link>http://blog.kineticweb.com/articles/2008/04/16/automagical-rspec-sake-spec-for-your-scripts</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>
    <item>
      <title>"Automagical RSpec: Sake Spec for your Scripts" by Sebastian</title>
      <description>O my god, what happend to my line breaks?</description>
      <pubDate>Wed, 14 May 2008 05:21:53 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:b15d55c5-5d6b-4e7f-9f71-8c3d158bb8fb</guid>
      <link>http://blog.kineticweb.com/articles/2008/04/16/automagical-rspec-sake-spec-for-your-scripts#comment-255</link>
    </item>
    <item>
      <title>"Automagical RSpec: Sake Spec for your Scripts" by Sebastian</title>
      <description>Great tip.

Is it possible to combine that with autotest?

Calling "autotest" calls just "spec YOUR_SPEC_FILES" and not your sake task.

I have the problem with autotest that it just gives the correct output if I change the spec-files. Changing the code-files does not give the correct output by autotest.

Example
-------------------
Directory: CustomerTest
customer.rb
spec/customer_spec.rb

I call "autotest" in "CustomerTest". Output:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec  spec/customer_spec.rb
...

Finished in 0.005555 seconds

3 examples, 0 failures

-------

Do I change the spec file -- Output:

[...]
3 examples, 0 failures

-------

Do I change the code file -- Output:


/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S /Library/Ruby/Gems/1.8/gems/rspec-1.1.3/bin/spec

It does not call the spec file


Any hints?</description>
      <pubDate>Wed, 14 May 2008 05:21:30 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:bae9a721-b69b-43bf-acee-8b534792c9ba</guid>
      <link>http://blog.kineticweb.com/articles/2008/04/16/automagical-rspec-sake-spec-for-your-scripts#comment-254</link>
    </item>
    <item>
      <title>"Automagical RSpec: Sake Spec for your Scripts" by Anny</title>
      <description>I have wanted one of these forever! THANKS for the great work</description>
      <pubDate>Sun, 20 Apr 2008 04:21:31 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:c0a3d53e-775e-4d24-8818-b1d3dd42d313</guid>
      <link>http://blog.kineticweb.com/articles/2008/04/16/automagical-rspec-sake-spec-for-your-scripts#comment-253</link>
    </item>
  </channel>
</rss>
