<?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>Rails on the Run &#187; failure</title>
	<atom:link href="http://railsontherun.com/tag/failure/feed/" rel="self" type="application/rss+xml" />
	<link>http://railsontherun.com</link>
	<description>Rails experiments by Matt Aimonetti</description>
	<lastBuildDate>Tue, 23 Feb 2010 07:28:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Oops, DrNic Did it again</title>
		<link>http://railsontherun.com/2007/04/26/myconfplan-com/</link>
		<comments>http://railsontherun.com/2007/04/26/myconfplan-com/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 10:33:00 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[DrNic]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[myconfplan.com]]></category>
		<category><![CDATA[railsconf]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[spec]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://railsontherun.com/2007/04/26/myconfplan-com</guid>
		<description><![CDATA[DrNic the most famous Australian Rails developer surprisingly doesn&#8217;t spend most of his time working on Rails read interview That&#8217;s maybe why he recently became so active in the Rails community ( see Magic Multi-Connections, Magic Models, map_by_methods, Gem Generator etc..) Today he released something very helpful for the Rails Community, not another Gem or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://drnicwilliams.com/">DrNic</a> the most famous Australian Rails developer surprisingly doesn&#8217;t spend most of his time working on Rails  <a href="http://www.akitaonrails.com/pages/drnic">read interview</a><br />
That&#8217;s maybe why he recently became so active in the Rails community ( see <a href="http://www.loudthinking.com/arc/000610.html">Magic Multi-Connections</a>, Magic Models, map_by_methods, Gem Generator etc..)</p>
<p>Today he released something very helpful for the Rails Community, not another Gem or another cool plugin to extend Rails but a <a href="http://myconfplan.com">web application</a> to help you planning your conferences. We already had other tools such as <a href="http://railsconf2007.conferencemeetup.com/p/276-matt-aimonetti">conference meetup</a> but it&#8217;s the first time that we get a product helping you to plan a conference by scheduling the sessions you want to attend.</p>
<p><img src="http://farm1.static.flickr.com/169/473390616_12c7596617.jpg?v=0" alt="screenshot"/></p>
<p><a href="http://flickr.com/photos/railsontherun/473389852/in/photostream/">screenshot of the entire schedule</a></p>
<p>I had a quick chat with DrNic about his latest creation and here is what he said:</p>
<p>&#8220;its been fun building just how I thought session selection might look + feel<br />
web2.0 = permissive voyeurism I think!&#8221;</p>
<p>I share the same vision than Nic on session selection and I really enjoyed booking my Rails sessions and seeing what other people selected. (I guess that&#8217;s my voyeur side, don&#8217;t you like web2.0?)</p>
<p>If you wanna see what I planned on attending, checkout my schedule: <a href="http://myconfplan.com/conferences/RailsConf2007/users/matt">my schedule</a></p>
<p>Thanks Nic for the good work and too bad you are not presenting anything at the RailsConf (move your bum to come up with a <em>better</em> submission next year!)</p>
]]></content:encoded>
			<wfw:commentRss>http://railsontherun.com/2007/04/26/myconfplan-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restful Rails and Flash</title>
		<link>http://railsontherun.com/2007/04/09/rails-and-flash/</link>
		<comments>http://railsontherun.com/2007/04/09/rails-and-flash/#comments</comments>
		<pubDate>Mon, 09 Apr 2007 07:41:00 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[actionScript]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[scaffhold_resource]]></category>
		<category><![CDATA[spec]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://railsontherun.com/2007/04/19/rails-and-flash</guid>
		<description><![CDATA[With the recent Buzz around Adobe Apollo I figured out that since I recently switched to Mac and that I didn&#8217;t try the latest Flex upgrade, I should try Flex 2.01 for Mac. I really like what Adobe did with Flex, Unit testing, better accessibility, etc&#8230; but one thing I regret, it&#8217;s getting closer and [...]]]></description>
			<content:encoded><![CDATA[<p>With the recent Buzz around <a href="http://labs.adobe.com/wiki/index.php/Apollo">Adobe Apollo</a> I figured out that since I recently switched to Mac and that I didn&#8217;t try the latest Flex upgrade, I should try <a href="http://www.adobe.com/products/flex/">Flex 2.01</a> for Mac. </p>
<p>I really like what Adobe did with Flex, Unit testing, better accessibility, etc&#8230; but one thing I regret, it&#8217;s getting closer and closer to Java and <a href="http://flexblog.faratasystems.com/?p=115">AS3 syntax</a> is a pain to use when you got used to Ruby. </p>
<p>Anyway, what I really wanted to do was to have Flash quickly access my Restful Rails app. The adobe guys came up with a <a href="http://code.google.com/p/rubyonrails-ria-sdk-by-adobe/">RoR Ria SDK</a> but well&#8230;.   it only covers Flex and requires FlashPlayer 9.<br />
I also found some great <a href="http://blog.vixiom.com/2006/08/23/flash-remoting-for-rails-tutorial/">tutorials</a> on how to use the efficient  <a href="http://osflash.org/documentation/amf">AMF messaging protocol</a> with Rails using the <a href="http://www.themidnightcoders.com/weborb/rubyonrails/index.htm">WebOrb for Rails plugins</a></p>
<p>All that was really nice and I had fun, but it was an overkill for what I wanted to do. Let me show you how in less than 5 minutes how you can access you Rails Model from Flash and add some new item directly from Flash.</p>
<p>Create your new Rails app and use the script/generate scaffold_resource command to generate your Event Model.</p>
<pre><code>script/generate scaffold_resource Event
</code></pre>
<p>It should create all that for you:</p>
<pre><code>exists  app/models/
  exists  app/controllers/
  exists  app/helpers/
  create  app/views/events
  exists  test/functional/
  exists  test/unit/
  create  app/views/events/index.rhtml
  create  app/views/events/show.rhtml
  create  app/views/events/new.rhtml
  create  app/views/events/edit.rhtml
  create  app/views/layouts/events.rhtml
  identical  public/stylesheets/scaffold.css
  create  app/models/event.rb
  create  app/controllers/events_controller.rb
  create  test/functional/events_controller_test.rb
  create  app/helpers/events_helper.rb
  create  test/unit/event_test.rb
  create  test/fixtures/events.yml
  exists  db/migrate
  create  db/migrate/001_create_events.rb
  route  map.resources :events
</code></pre>
<p>let&#8217;s edit the migration file:<br />
db/migrate/001<em>create</em>events.rb</p>
<pre><code>class CreateEvents &lt; ActiveRecord::Migration
  def self.up
    create_table :events do |t|
      t.column :title, :string
      t.column :description, :string
      t.column :location, :string
        t.column :starts_at, :datetime
        t.column :ends_at, :datetime
    end
  end

  def self.down
    drop_table :events
  end
end
</code></pre>
<p>And let&#8217;s add some fixtures:<br />
test/fixtures/events.yml</p>
<pre><code>meeting:
  id: 1
  title: Meeting
  description: Boring meeting with the whole staff
  location: conference room
  starts_at: 2007-11-02 09:00:00
  ends_at: 2007-11-02 10:30:00
Joe_bday:
  id: 2
  title: Joe Bday Party
  description: Come and celebrate Joe's Birthday
  location: Lapin Agile Pub
  starts_at: 2007-09-07 20:00:00
  ends_at: 2007-09-07 23:30:00
</code></pre>
<p>Ok, now simply migrate your database,load the fixtures and start the webrick:</p>
<pre><code>rake db:migrate
rake db:fixtures:load
script/server
</code></pre>
<p>Great, we are done with Rails.  </p>
<p>Let&#8217;s launch Flash</p>
<p>Create a new Flash document and create a new .As fie in TextMate (or your favorite editor). We&#8217;ll write a quick ActionScript class to access Rails.</p>
<pre><code>class Restfulflash{
    public var gateway:String;

    function Resftfulflash(gateway:String){
        this.set_gateway(gateway);
    }
    public function set_gateway(gateway:String){
        this.gateway = gateway;
        trace("gateway set to:"+gateway);
    }

    public function get(model, callback){
        var railsReply:XML = new XML();
        railsReply.ignoreWhite = true;
        railsReply.onLoad = function(success:Boolean){
            if (success) {
                    trace ('Rails responded: '+railsReply);
                    callback.text = railsReply;
            } else {
                    trace ('Error while waiting for Rails to reply');
               callback.text = 'error';
            }
        }
        var railsRequest:XML = new XML();
        railsRequest.contentType="application/xml";
        railsRequest.sendAndLoad(this.gateway+model, railsReply);
        delete railsRequest;
    }

    public function create(model, newItem){
        railsRequest.onLoad = function(success){
                trace("Item creation success: " + success);
                trace(this);
        };
        var railsRequest:XML = new XML();
        railsRequest.parseXML(newItem);
        railsRequest.contentType="application/xml";
        railsRequest.sendAndLoad(this.gateway+model+'/create/', railsRequest,'POST');
        delete railsRequest;
    }
}
</code></pre>
<p>Save this file in the same directory as your .fla file  </p>
<p>In your fla file add:</p>
<pre><code>// Create a XML object to hold the events from our Rails app
rails_events = new XML();

// Prepare the connection to Rails (it would be nicer to do that in 1 step, but to make things clearer i decided to do it in 2)
var rails:Restfulflash = new Restfulflash();
rails.set_gateway("http://localhost:3000/");

// Get the events from rails and load the result in the rails_event XML object.
rails.get('events', rails_events);
trace(rails_events);

// Let's create a new event
newEvent = new XML('&lt;event&gt;&lt;description&gt;Spend some time with Grandma before its too late&lt;/description&gt;&lt;ends-at type="datetime"&gt;2007-11-02T18:30:00-07:00&lt;/ends-at&gt;&lt;id type="integer"&gt;1&lt;/id&gt;&lt;location&gt;Paris, France&lt;/location&gt;&lt;starts-at type="datetime"&gt;2007-11-02T16:00:00-07:00&lt;/starts-at&gt;&lt;title&gt;Visit Grandma&lt;/title&gt;&lt;/event&gt;&amp;#8217;)
rails.create(&amp;#8216;events&amp;#8217;, newEvent);

// Verify  that the event was added
rails.get(&amp;#8216;events&amp;#8217;, rails_events);
trace(rails_events);
</code></pre>
<p>There you go, you have all the events provided to you by Rails nicely prepared in an easy to parse XML object. You can bind the results to a Datagrid or display the info the way you want it. Ohh and by the way, we just added a new Event to the database&#8230; easy, isn&#8217;t it?  The code is a bit dirty but it&#8217;s still a good example why you need to use REST and how easy it is to get Flash to talk with Rails. (I strongly encourage that you also look at the very good WebOrb plugin for Rails)</p>
]]></content:encoded>
			<wfw:commentRss>http://railsontherun.com/2007/04/09/rails-and-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Migrating a legacy app to Rails Part II</title>
		<link>http://railsontherun.com/2007/04/02/migrating-legacy-app-part-2/</link>
		<comments>http://railsontherun.com/2007/04/02/migrating-legacy-app-part-2/#comments</comments>
		<pubDate>Mon, 02 Apr 2007 18:31:00 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[activeRecord]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[legacy]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[spec]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://railsontherun.com/2007/05/22/migrating-legacy-app-part-2</guid>
		<description><![CDATA[In part I I quickly explained what I had to do, my limitations and a potential solution to connect to a legacy database. In this post I&#8217;ll try to go through setting up a plugin for migration and start using RSpec for developing the migration plugin. What we want is to migrate sites using the [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.railsontherun.com/2007/3/30/migrating-legacy-app-part-1">part I</a> I quickly explained what I had to do, my limitations and a potential solution to connect to a legacy database.</p>
<p>In this post I&#8217;ll try to go through setting up a plugin for migration and start using <a href="http://rspec.rubyforge.org/">RSpec</a> for developing the migration plugin.</p>
<p>What we want is to migrate sites using the legacy application to our new Rails application. That means that new users won&#8217;t be be migrated. It therefore makes sense not to add the migrating logic to the main application but to create a plugin. (if you are not familiar with Rails plugins check this <a href="http://nubyonrails.com/articles/2006/05/04/the-complete-guide-to-rails-plugins-part-i">blog post from Geoffrey Grosenbach about plugins</a>)</p>
<p>Let&#8217;s create our plugin</p>
<pre><code>./script/generate plugin legacy_migration</code></pre>
<p>Rails should have generated something like that:</p>
<pre><code>legacy_migration
|-- init.rb
|-- install.rb
|-- uninstall.rb
|-- Rakefile
|-- README
|-- lib/
|   |-- legacy_migration.rb
|-- tasks/
|   |-- legacy_migration_tasks.rake
|-- test
|   |-- legacy_migration_test.rb</code></pre>
<p>Since we are going to use RSpec, we can remove the test folder and create a spec folder. In our spec folder, let&#8217;s add some subfolders to organize our files. Let&#8217;s create a fixtures folder to hold, a helpers folder, a migrate folder (we&#8217;ll use that to migrate our legacy database) and finally, a models folder.</p>
<p>Our plugin folder should look more or less like that:</p>
<pre><code>legacy_migration
|-- init.rb
|-- install.rb
|-- uninstall.rb
|-- Rakefile
|-- README
|-- lib/
|   |-- legacy_migration.rb
|-- tasks/
|   |-- legacy_migration_tasks.rake
|-- spec
|   |-- fixtures
|   |-- helpers
|   |-- migrate
|   |-- models</code></pre>
<p>Great, let&#8217;s get started and let&#8217;s create our first spec. We should probably start by migrating users so I&#8217;ll create a new spec in the spec/models folder called legacy_user_spec.rb and add the following code:</p>
<pre><code>require File.dirname(<i>FILE</i>) + '/../helpers/legacy_user_helper'
require File.dirname(<i>FILE</i>) + '/../helpers/spec_helper'</code></pre>
<pre><code>describe "a connection to the legacy application" do
  setup do
    @connection_status = LEGACY.connect
  end
end</code></pre>
<pre><code>it "should be connected to the legacy database" do
  @connection_status.current_database.should == ActiveRecord::Base.configurations<a href="'database'">'legacy'</a>

end</code></pre>
<p>Note that I&#8217;m using RSpec trunk/edge and I use &#8220;describe&#8221; instead of &#8220;context&#8221; and &#8220;it&#8221; instead of &#8220;specify&#8221;. For more information on how to run RSpec edge with TextMate read <a href="http://www.railsontherun.com/2007/3/30/rspec-textmate-bundle-edge">this previous post</a>.</p>
<p>If we look at the code above, we start by requiring 2 helpers, a general helper called spec_helper and a helper just for this spec called legacy_user_helper (we will obviously need to create them otherwise our spec will failed).</p>
<p>Then we start our first spec by describing a connection to the legacy application and we specify that it should be connected to the legacy database.</p>
<p>Here is our setup code:</p>
<pre><code>setup do
  @connection_status = LEGACY.connect
end</code></pre>
<p>What I want is to retrieve a connection status after I connect to our legacy application. To manage the connection to the legacy application we will create a <span class="caps">LEGACY</span> module. We will need to connect to many legacy applications/sites and our module should help us doing that.</p>
<p>Then we can read that our spec checks that we are connected to the legacy database.</p>
<pre><code>it "should be connected to the legacy database" do
  @connection_status.current_database.should == ActiveRecord::Base.configurations<a href="'database'">'legacy'</a>
end</code></pre>
<p>That means we want to compare the connection status to the &#8216;legacy&#8217; environment defined in the database.yml file.</p>
<p>We now need to get this spec to pass.</p>
<p>Let&#8217;s get started by adding a legacy environment to our database.yml and creating our <span class="caps">LEGACY</span> module in our legacy_migration.rb file.</p>
<p>Add the following to your database.yml</p>
<pre><code>legacy:
  adapter: mysql
  database: legacy
  username: root
  password:
  host: localhost</code></pre>
<p>Now, let&#8217;s create the <span class="caps">LEGACY</span> module in our legacy_migration.rb file</p>
<pre><code>
module LEGACY

  # Connect to a Legacy database.
  # Usage:
  # Manual connection: LEGACY.connect(:database => 'legacy-database', :adapter => 'mysql', :username => 'root', :password => '', :host => 'localhost')
  # Auto connection to the database.yml defined legacy DB: LEGACY.connect
  # Connection to any database available in database.yml LEGACY.connect('legacy_test')
  # Connect a class to a specific database: LEGACY.connect(LegacyInstaller, ActiveRecord::Base.configurations['legacy_installer'])
  def self.connect(spec = nil, opt_env = nil)
    case spec
      # Automatically connect to the legacy environment database defined in the database.yml
    when nil
      raise 'Legacy Database not defined' unless defined? ActiveRecord::Base.configurations['legacy']
      LegacyActiveRecord.establish_connection(ActiveRecord::Base.configurations['legacy'])
      # Return the connections status
      LegacyActiveRecord.connection
      # A connection's name from the database.yml can be passed
    when Symbol, String
      if configuration = ActiveRecord::Base.configurations[spec.to_s]
        LegacyActiveRecord.establish_connection(configuration)
      else
        raise "#{spec} database is not configured"
      end
      # Connect a Model to a specific Database
    when Class
      raise 'Environment connection not provided or nil' unless defined? opt_env || opt_env['database'] == nil
      if spec.connection.current_database == opt_env['database']
        spec.connection
      else
        spec.establish_connection(opt_env)
      end
      # An array can be passed to establish the connection
    else
      spec = spec.symbolize_keys
      unless spec.key?(:adapter) then raise "database configuration does not specify adapter" end
        adapter_method = "#{spec[:adapter]}_connection"
        LegacyActiveRecord.establish_connection(spec)
      end
    end
  end</code></pre>
<p>There we go, we have a really cool connect function, we can easily connect to the default legacy environment defined in the database.yml file, we can specify the connection settings, connect to another environment database and even connect one specific class/model to a specific environment. (that will useful since we have many databases). If we wanted to follow the <span class="caps">TDD</span> rules, I shouldn&#8217;t have written so much code&#8230; as a matter of fact, when I worked on this project I did not, but since I don&#8217;t have much time, I won&#8217;t go through the re-factoring steps.</p>
<p>One thing you might have noticed is that we establish a connection between LegacyActiveRecord and the legacy database. (instead of connecting ActiveRecord to the legacy database).</p>
<pre><code>LegacyActiveRecord.establish_connection(ActiveRecord::Base.configurations['legacy'])</code></pre>
<p>The problem is that we didn&#8217;t create the LegacyActiveRecord model yet. Let&#8217;s do that right away. Let&#8217;s add a new folder called models in our lib folder. In the models folder, let&#8217;s create a legacy_active_record.rb file and add the following code:</p>
<pre><code>class LegacyActiveRecord &lt; ActiveRecord::Base
  self.abstract_class = true
end</code></pre>
<p>Cool, now let&#8217;s have fun with our new module, fire the console (./script/console) and try <span class="caps">LEGACY</span>.connect<br />
Here is what we get back:</p>
<pre><code>
    &gt;&gt; <span class="caps">LEGACY</span>.connect
    =&gt; #<activeRecord::ConnectionAdapters::MysqlAdapter:0x32a09d8 @runtime=0.000155925750732422, @config={:password=>nil, :database=&gt;&#8221;legacy&#8221;, :allow_concurrency=&gt;false, :host=&gt;&#8221;localhost&#8221;, :username=&gt;&#8221;root&#8221;, :adapter=&gt;&#8221;mysql&#8221;}, @connection_options=[&#8220;localhost&#8221;, &#8220;root&#8221;, &#8221;&#8221;, &#8220;legacy&#8221;, nil, nil], [...]

</code></pre>
<p>let&#8217;s try to get the database we connected to:</p>
<pre><code>&gt;&gt;LEGACY.connect.current_database
    =&gt; &#8220;legacy&#8221;

</code></pre>
<p>Awesome, we can now get our LegacyActiveRecord model to connect to our legacy database and return the connections status. Let&#8217;s run our specs&#8230;&#8230;&#8230;.. they pass.</p>
<p>Sweet, we setup our migration plugin, got our first spec written, added the code needed to get the spec to pass, I think we are done with <span class="caps">PART 2</span> <img src='http://railsontherun.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://railsontherun.com/2007/04/02/migrating-legacy-app-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RSpec Textmate bundle and RSpec edge</title>
		<link>http://railsontherun.com/2007/03/30/rspec-textmate-bundle-edge/</link>
		<comments>http://railsontherun.com/2007/03/30/rspec-textmate-bundle-edge/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 04:21:00 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[rspec textmate]]></category>
		<category><![CDATA[spec]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://railsontherun.com/2007/04/12/rspec-textmate-bundle-edge</guid>
		<description><![CDATA[UPDATE: Aslak Hellesoy just mentioned in a comment that the trunk version of RSpec bundle for TextMate ( svn://rubyforge.org/var/svn/rspec/trunk ) doesn&#8217;t require the RSpec Gem installed anymore. To install the bundle: cd ~/Library/Application\ Support/TextMate/Bundles/ svn co svn://rubyforge.org/var/svn/rspec/branches/0.9-dev/RSpec.tmbundle I recently discovered RSpec, well, not really, but I finally got to start using RSpec. For those who [...]]]></description>
			<content:encoded><![CDATA[<h2>UPDATE:</h2>
<p><a href='http://blog.aslakhellesoy.com/' target='blank'> Aslak Hellesoy</a> just mentioned in a comment that the trunk version of RSpec bundle for TextMate ( svn://rubyforge.org/var/svn/rspec/trunk ) doesn&#8217;t require the RSpec Gem installed anymore.<br />
<br/><br/></p>
<p>To install the bundle:</p>
<pre><code>
cd ~/Library/Application\ Support/TextMate/Bundles/
 svn co svn://rubyforge.org/var/svn/rspec/branches/0.9-dev/RSpec.tmbundle
</code></pre>
<p><br/></p>
<hr />
<br/><br/><br/></p>
<p>I recently discovered RSpec, well, not really, but I finally got to start using<br />
RSpec.<br/><br />
For those who don&#8217;t know<br />
<a href="http://rspec.rubyforge.org/" target="blank_" title="RSpec">RSpec</a> ,<br />
RSpec is a BDD testing framework, or in better words: RSpec is a Behaviour<br />
Definition Framework well suited for practicing Behaviour Driven Development<br />
(BDD) in Ruby.<br/><br />
<br/><br />
If you don&#8217;t know what is BDD, then just check out<br />
<a href="http://behaviour-driven.org/" target="blank_" title="http://behaviour-driven.org/">http://behaviour-driven.org/</a>, in few words, it&#8217;s TDD (Test Driven Development in better)<br/><br />
<br/><br />
Anyway, I&#8217;m working on a Rails project where we use the trunk/edge version RSpec<br />
plugin. I&#8217;m using my favorite editor:<br />
<a href="http://macromates.com/" target="blank_" title="TextMate">TextMate</a><br />
and I noticed that the RSpec team created a<br />
<a href="http://rspec.rubyforge.org/tools/extensions/editors/textmate.html" target="blank_" title="cool bundle for textmate">cool<br />
bundle for textmate</a>.<br/><br />
<br/><br />
I was quite excited until I tried running a spec and realized that the task<br />
failed giving some errors about some missing methods&#8230; Well, the thing is we<br />
replaced &#8220;context &#8230; do&#8221; by &#8220;describe &#8230; do&#8221; and &#8220;specify &#8230; do&#8221; by &#8220;it &#8230;<br />
do&#8221; see<br />
<a href="http://blog.davidchelimsky.net/articles/2007/03/11/describe-it-with-rspec" title="David's post">David&#8217;s<br />
post</a> about this specific change in trunk:<br/><br />
<br/><br />
The Textmate bundle uses the ruby gem instead of the plugin and since I&#8217;m trying<br />
to use methods only defined in trunk the bundle simply dies on me every time I<br />
try to run my specs.<br/><br />
<br/><br />
The only solution for me was to run a trunk version of the RSpec gem, here is<br />
what to do:<br/><br />
<br/><br />
<span style="FONT-STYLE:italic">Check out RSpec trunk from:<br />
svn://rubyforge.org/var/svn/rspec/trunk</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">Check out RSpec trunk into its own project, or<br />
if you&#8217;re interested in</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">using/learning RSpec for a particular Rails<br />
project, consider using</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">svn:externals to check out RSpec trunk into your<br />
[RailsRoot]/vendor</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">directory:</span><br style="FONT-STYLE:italic"/><br />
<br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">svn propset svn:externals &#8220;rspec<br />
svn://rubyforge.org/var/svn/rspec/trunk&#8221;</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">vendor</span><br style="FONT-STYLE:italic"/><br />
<br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">then update to grab the latest code from RSpec<br />
trunk:</span><br style="FONT-STYLE:italic"/><br />
<br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">svn update<br />
vendor</span><br style="FONT-STYLE:italic"/><br />
<br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">Next, build the gem.&nbsp; You have to be<br />
standing in vendor/rspec if you&#8217;re</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">using svn:externals (as described above) or the<br />
root of RSpec if you checked</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">it out as its own<br />
project.</span><br style="FONT-STYLE:italic"/><br />
<br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">rake gem</span><br style="FONT-STYLE:italic"/><br />
<br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">then install<br />
it:</span><br style="FONT-STYLE:italic"/><br />
<br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">gem install pkg/rspec-X.X.X.gem (where X.X.X is<br />
the version number reported</span><br style="FONT-STYLE:italic"/><br />
<span style="FONT-STYLE:italic">in the output from &#8220;rake gem&#8221;)</span><br/><br />
<br/><br />
&#8212;- from<br />
<a href="http://rubyforge.org/pipermail/rspec-users/2006-November/000135.html" target="blank_" title="http://rubyforge.org/pipermail/rspec-users/2006-November/000135.html">http://rubyforge.org/pipermail/rspec-users/2006-November/000135.html</a><br/><br />
<br/><br />
That&#8217;s it, now I can run my specs directly from Textmate the same way I was<br />
doing with Unit Test.<br/><br />
<br/><br />
( on a different post I&#8217;ll explain why I couldn&#8217;t simply run rake:spec )<br/><br />
<br/><br />
<br/><br />
<br/><br />
<br/><br />
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://railsontherun.com/2007/03/30/rspec-textmate-bundle-edge/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

