<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -86,11 +86,37 @@ module Spec
         case file_type
           when /spec$/ then
             spec(relative_path)
+          when &quot;controller&quot;
+            &lt;&lt;-CONTROLLER
+class #{class_from_path(relative_path)} &lt; ApplicationController
+end
+CONTROLLER
+          when &quot;model&quot;
+            &lt;&lt;-MODEL
+class #{class_from_path(relative_path)} &lt; ActiveRecord::Base
+end
+MODEL
+          when &quot;helper&quot;
+            &lt;&lt;-HELPER
+module #{class_from_path(relative_path)}
+end
+HELPER
+          when &quot;view&quot;
+            &quot;&quot;
           else
             klass(relative_path)
         end
       end
       
+      def class_from_path(path)
+        underscored = path.split('/').last.split('.rb').first
+        parts = underscored.split('_')
+        parts.inject(&quot;&quot;) do |word, part|
+          word &lt;&lt; part.capitalize
+          word
+        end
+      end
+      
       # Extracts the snippet text
       def snippet(snippet_name)
         snippet_file = File.expand_path(File.dirname(__FILE__) + &quot;/../../../../Snippets/#{snippet_name}&quot;)
@@ -106,9 +132,9 @@ require 'spec_helper'
 SPEC
       end
 
-      def klass(relative_path)
+      def klass(relative_path, content=nil)
         parts = relative_path.split('/')
-        lib_index = parts.index('lib')
+        lib_index = parts.index('lib') || 0
         parts = parts[lib_index+1..-1]
         lines = Array.new(parts.length*2)
         parts.each_with_index do |part, n|</diff>
      <filename>Support/lib/spec/mate/switch_command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -196,6 +196,31 @@ EOF
           SwitchCommand.new.content_for('controller spec', &quot;spec/controllers/mooky_controller_spec.rb&quot;).split(&quot;\n&quot;)[0].should == 
             &quot;require 'spec_helper'&quot;
         end
+        
+        it &quot;creates a controller if twinned from a controller spec&quot; do
+          SwitchCommand.new.content_for('controller', &quot;spec/controllers/mooky_controller.rb&quot;).should == &lt;&lt;-EXPECTED
+class MookyController &lt; ApplicationController
+end
+EXPECTED
+        end
+        
+        it &quot;creates a model if twinned from a model spec&quot; do
+          SwitchCommand.new.content_for('model', &quot;spec/models/mooky.rb&quot;).should == &lt;&lt;-EXPECTED
+class Mooky &lt; ActiveRecord::Base
+end
+EXPECTED
+        end
+        
+        it &quot;creates a helper if twinned from a helper spec&quot; do
+          SwitchCommand.new.content_for('helper', &quot;spec/helpers/mooky_helper.rb&quot;).should == &lt;&lt;-EXPECTED
+module MookyHelper
+end
+EXPECTED
+        end
+        
+        it &quot;creates an empty view if twinned from a view spec&quot; do
+          SwitchCommand.new.content_for('view', &quot;spec/views/mookies/index.html.erb_spec.rb&quot;).should == &quot;&quot;
+        end
       end
     end
   end</diff>
      <filename>Support/spec/spec/mate/switch_command_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8c91306e1e4046c99b90b9f698403c39a05137fa</id>
    </parent>
  </parents>
  <author>
    <name>David Chelimsky</name>
    <email>dchelimsky@gmail.com</email>
  </author>
  <url>http://github.com/dchelimsky/rspec-tmbundle/commit/b93a56c1f6b56c71e744d117e35c71552fddd172</url>
  <id>b93a56c1f6b56c71e744d117e35c71552fddd172</id>
  <committed-date>2009-09-30T04:18:47-07:00</committed-date>
  <authored-date>2009-09-30T04:18:47-07:00</authored-date>
  <message>Fixed bug that was crashing twin file generation

- also added better snippets for gen'd model, view, controller and
  helper classes</message>
  <tree>2bd29cde9f8eddd1b5c7d8e1c94035e52db630d1</tree>
  <committer>
    <name>David Chelimsky</name>
    <email>dchelimsky@gmail.com</email>
  </committer>
</commit>
