<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/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>Robby on Rails: Tag plugins</title>
    <link>http://www.robbyonrails.com/articles/tag/plugins</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>thoughts.sort_by{|t| t[:topic]}.collect </description>
    <item>
      <title>DRY(a): Year After Year</title>
      <description>&lt;p&gt;I&amp;#8217;m guilty of it. Many of you are likely guilty of it&amp;#8230; and I know that several customers of our &lt;a href="http://www.robbyonrails.com/articles/2007/06/17/audit-your-rails-development-team"&gt;Rails Code Audit and Review service&lt;/a&gt; are guilty of it.&lt;/p&gt;


	&lt;p&gt;How many times have you realized (after a few months has passed) that your Copyright date/year on your web site was no longer current?&lt;/p&gt;


	&lt;p&gt;How many of you had the same problem last year? The year before?&lt;/p&gt;


	&lt;p&gt;Let me share some advice with you all&amp;#8230; &lt;span class="caps"&gt;DRY&lt;/span&gt; (a)!&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Don&amp;#8217;t Repeat Yourself (again)!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;This is really a simple problem to fix but when we&amp;#8217;re busy tackling bigger problems&amp;#8230; little things like this slip by. Don&amp;#8217;t worry, you&amp;#8217;re not the only one who was reminded by a colleague three months into the year that you forgot to update this.&lt;/p&gt;


	&lt;p&gt;On client projects, we have a handful of helpers that we drop into the application. We&amp;#8217;re starting to extract more of these into plugins and will be releasing those as time permits. It just happened that I found myself looking at yet-another Rails code base this afternoon that was showing 2007 in the footer. An easily forgivable offense.. but if you&amp;#8217;re going to go in there and change it (again), &lt;em&gt;take a moment to do the right thing&lt;/em&gt;. ;-)&lt;/p&gt;


	&lt;p&gt;Our solution at &lt;a href="http://planetargon.com"&gt;Planet Argon&lt;/a&gt; on client projects is to create a basic view helper that renders the current year. This allows us to do the following.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  &amp;lt;div id="footer"&amp;gt;
    &amp;amp;copy; Copyright &amp;lt;%= current_year -%&amp;gt;. All Rights Reserved.
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The helper code looks like:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  # add to application_helper.rb
  module ApplicationHelper
    def current_year
      Time.now.strftime('%Y')
    end
  end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Voila. Not rocket science.. is it?&lt;/p&gt;


	&lt;p&gt;Guess what? I&amp;#8217;m getting really tired of adding this to every Rails project that I touch. So, I bottled this little gem into a new Rails plugin that we&amp;#8217;ll just add to future projects.&lt;/p&gt;


	&lt;h2&gt;Introducing Year after Year&lt;/h2&gt;


	&lt;p&gt;This is really the smallest plugin that I could put together (and it includes specs!)&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;What does it provide you?&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;YearAfterYear will provide you a helper that will render the current year (dynamically)! That&amp;#8217;s right&amp;#8230; just add the plugin to your Rails application and you too can enjoy New Years 2009 without having to have a deployment ready with a one line change from 2008 to 2009!&lt;/p&gt;


	&lt;p&gt;To use.. add the following to any view from within Ruby on Rails.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  &amp;lt;%= current_year -%&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

	&lt;h3&gt;Installation&lt;/h3&gt;


	&lt;p&gt;As I&amp;#8217;m using git, you&amp;#8217;ll need to grab this and put it into &lt;code&gt;vendor/plugins&lt;/code&gt;. That&amp;#8217;s it!&lt;/p&gt;


	&lt;p&gt;You can grab it on &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;!&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://github.com/robbyrussell/year_after_year/"&gt;http://github.com/robbyrussell/year_after_year/&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Bugs / Feature Requests &lt;a href="http://planetargon.lighthouseapp.com/projects/5187-open-source-projects/tickets"&gt;here&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Happy New Years (8+ months early)!&lt;/p&gt;


	&lt;p&gt;Just a friendly reminder to not forget the small stuff&amp;#8230; because your visitors will notice! ;-)&lt;/p&gt;


	&lt;h3&gt;Updates&amp;#8230;&lt;/h3&gt;


	&lt;p&gt;I got a few requests for this to also provide a range of years for people who like to do: &lt;strong&gt;2005-2007&lt;/strong&gt;. So this is now provided as well.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;year_range(start_year)&lt;/code&gt;&lt;/p&gt;


Example:
&lt;pre&gt;&lt;code&gt;
  &amp;lt;%= year_range(2005) %&amp;gt; # =&amp;gt; 2005-2008
&lt;/code&gt;&lt;/pre&gt;
</description>
      <pubDate>Mon, 24 Mar 2008 22:05:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:4228a063-facc-4a13-bdb0-342c0fab415e</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2008/03/24/dry-a-year-after-year</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>Programming</category>
      <category>PLANET ARGON</category>
      <category>sarcasm</category>
      <category>plugin</category>
      <category>rails</category>
      <category>rubyonrails</category>
      <category>years</category>
      <category>copyrights</category>
      <category>joke</category>
      <category>plugins</category>
    </item>
    <item>
      <title>Master/Slave Databases with Ruby on Rails</title>
      <description>&lt;p&gt;Not terribly long ago, I &lt;a href="http://www.robbyonrails.com/articles/2007/10/05/multiple-database-connections-in-ruby-on-rails"&gt;announced Active Delegate&lt;/a&gt;, which was a really lightweight plugin that I developed to allow models to talk to multiple databases for specific methods. The plugin worked great for really simple situations, like individual models.. but when it came time to test with associations it fell apart. I haven&amp;#8217;t had a chance to work on any updates and knew that it was going to take more work to get it going.&lt;/p&gt;


	&lt;p&gt;Earlier this week, we helped one of our bigger clients launch their new web site&lt;sup&gt;&lt;a href="#fn1"&gt;1&lt;/a&gt;&lt;/sup&gt;. For the deployment, we needed to send all writes to a master database and a reads to slaves (initial deployment is talking to almost 10 slaves spread around the globe!). We needed something to get integrated quickly and decided to ditch Active Delegate for the time being and began looking at the following options.&lt;/p&gt;


	&lt;p&gt;I spoke with Rick Olson&lt;sup&gt;&lt;a href="#fn2"&gt;2&lt;/a&gt;&lt;/sup&gt; and he pointed me to a new plugin that he hasn&amp;#8217;t really released yet. So, I&amp;#8217;m going to do him a favor and announce it for him. Of course&amp;#8230; I got his permission first&amp;#8230; ;-)&lt;/p&gt;


	&lt;h2&gt;Announcing Masochism!&lt;/h2&gt;


	&lt;p&gt;Masochism&lt;sup&gt;&lt;a href="#fn3"&gt;3&lt;/a&gt;&lt;/sup&gt; is a new plugin for Ruby on Rails that allows you to delegate all writes to a master database and reads to a slave database. The configuration process is just a few lines in your environment file and the plugin takes care of the rest.&lt;/p&gt;


	&lt;h3&gt;Installing Masochism&lt;/h3&gt;


	&lt;p&gt;With &lt;a href="http://piston.rubyforge.org/usage.html"&gt;piston&lt;/a&gt;, you can import Masochism with:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  $ cd vendor/plugins
  $ piston import http://ar-code.svn.engineyard.com/plugins/masochism/
&lt;/code&gt;&lt;/pre&gt;

	&lt;ul&gt;
	&lt;li&gt;To learn more about piston, read &lt;a href="http://www.robbyonrails.com/articles/2007/01/16/every-second-counts-with-a-piston-in-your-trunk"&gt;Every Second Counts with a Piston in your trunk&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;You can also install it with the old-fashioned way:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  $ ./script/plugin install -x http://ar-code.svn.engineyard.com/plugins/masochism/
&lt;/code&gt;&lt;/pre&gt;

	&lt;h3&gt;Configuring Masochism&lt;/h3&gt;


	&lt;p&gt;The first thing that you&amp;#8217;ll need to do is add another database connection in &lt;code&gt;config/database.yml&lt;/code&gt; for &lt;code&gt;master_database&lt;/code&gt;. By default, Masochism expects you to have a production database, which will be the read-only/slave database. The &lt;code&gt;master_database&lt;/code&gt; will be the connection details for your (you guessed it&amp;#8230;) master database.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
# config/database.yml  
production:
  database: masochism_slave_database
  adapter: postgresql
  host: slavedb1.hostname.tld
  ...

master_database:
  database: masochism_master_database
  adapter: postgresql
  host: masterdb.hostname.tld
  ...
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The idea here is that replication will be handled elsewhere and your application can reap the benefits of talking to the slave database for all of it&amp;#8217;s read-only operations and let the master database(s) spend their time writing data.&lt;/p&gt;


	&lt;p&gt;The next step is to set this up in your environment file. In our scenario, this was &lt;code&gt;config/environments/production.rb&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
# Add this to config/environments/production.rb
config.after_initialize do 
  ActiveReload::ConnectionProxy.setup!    
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Voila, you should be good to go now. As I mentioned, we&amp;#8217;ve only been using this for this past week and we&amp;#8217;ve had to address a few problems that the initial version of the plugin didn&amp;#8217;t address. One of our developers, &lt;a href="http://andy.delcambre.com/"&gt;Andy Delcambre&lt;/a&gt;, just posted an article to show how we had a problem with &lt;a href="http://andy.delcambre.com/2007/11/15/masochistic-connection-proxy-with-observers"&gt;using ActiveRecord observers and masochism&lt;/a&gt;, which we&amp;#8217;re sending over a patch for now.&lt;/p&gt;


	&lt;p&gt;As we continue to monitor how this solution works, we&amp;#8217;ll report any findings on our blog. In the meantime, I&amp;#8217;d be interested in knowing what you&amp;#8217;re using to solve this problem. :-)&lt;/p&gt;


	&lt;p id="fn1"&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;a href="http://contiki.com"&gt;Contiki&lt;/a&gt;, a cool travel company we&amp;#8217;re working with&lt;/p&gt;


	&lt;p id="fn2"&gt;&lt;sup&gt;2&lt;/sup&gt; Rick just moved to Portland&amp;#8230; welcome to stump town!&lt;/p&gt;


	&lt;p id="fn3"&gt;&lt;sup&gt;3&lt;/sup&gt; &lt;a href="http://ar-code.svn.engineyard.com/plugins/masochism/README"&gt;The Masochism plugin &lt;span class="caps"&gt;README&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>Thu, 15 Nov 2007 16:02:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:3420b2e3-a80c-43c9-a136-a58040069607</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2007/11/15/master-slave-databases-with-ruby-on-rails</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>Programming</category>
      <category>PLANET ARGON</category>
      <category>plugins</category>
      <category>masochism</category>
      <category>database</category>
      <category>mysql</category>
      <category>postgresql</category>
      <category>client</category>
      <category>development</category>
      <category>activerecord</category>
      <category>replication</category>
      <category>deployment</category>
    </item>
    <item>
      <title>Multiple Database Connections in Ruby on Rails</title>
      <description>&lt;p&gt;We have a client that already has some database replication going on in their deployment and needed to have most of their Ruby on Rails application pull from slave servers, but the few writes would go to the master, which would then end up in their slaves.&lt;/p&gt;


	&lt;p&gt;So, I was able to quickly extend ActiveRecord with just &lt;em&gt;two&lt;/em&gt; methods to achieve this. Anyhow, earlier today, someone in #caboose asked if there was any solutions to this and it prompted me to finally package this up into a quick and dirty Rails plugin.&lt;/p&gt;


	&lt;p&gt;Introducing&amp;#8230; &lt;strong&gt;Active Delegate&lt;/strong&gt;!&lt;/p&gt;


	&lt;p&gt;To install, do the following:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
cd vendor/plugins;
piston import http://svn.planetargon.org/rails/plugins/active_delegate
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Next, you&amp;#8217;ll need to create another database entry in your &lt;code&gt;database.yml&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
login: &amp;#38;login
  adapter: postgresql
  host: localhost
  port: 5432

development:
  database: rubyurl_development
  &amp;lt;&amp;lt;: *login

test:
  database: rubyurl_test
  &amp;lt;&amp;lt;: *login

production:
  database: rubyurl_servant
  &amp;lt;&amp;lt;: *login

# NOTICE THE NEXT ENTRY/KEY
master_database:
  database: rubyurl_master
  &amp;lt;&amp;lt;: *login
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;At this point, your Rails application won&amp;#8217;t talk to the &lt;code&gt;master_database&lt;/code&gt;, because nothing is being told to connect to it. So, the current solution with Active Delegate is to create an ActiveRecord model that will act as a connection handler.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  # app/models/master_database.rb
  class MasterDatabase &amp;lt; ActiveRecord::Base
    handles_connection_for :master_database # &amp;lt;-- this matches the key from our database.yml
  end  
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Now, in the model(s) that we&amp;#8217;ll want to have talk to this database, we&amp;#8217;ll do add the following.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  # app/models/animal.rb
  class Animal &amp;lt; ActiveRecord::Base
     delegates_connection_to :master_database, :on =&amp;gt; [:create, :save, :destroy]
  end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Now, when your application performs a &lt;code&gt;create&lt;/code&gt;, &lt;code&gt;save&lt;/code&gt;, or &lt;code&gt;destroy&lt;/code&gt;, it&amp;#8217;ll talk to the master database and your &lt;code&gt;find&lt;/code&gt; calls will retrieve data from your servant database.&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s late on a Friday afternoon and I felt compelled to toss this up for everyone. I think that this could be improved quite a bit, but it&amp;#8217;s working great for the original problem that needed to be solved.&lt;/p&gt;


	&lt;p&gt;If you have feedback and/or bugs, please &lt;a href="http://planetargon.lighthouseapp.com/projects/5187-open-source-projects/"&gt;send us tickets&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Fri, 05 Oct 2007 17:54:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:69a8625d-e24b-4f4e-aa58-d69a67784698</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2007/10/05/multiple-database-connections-in-ruby-on-rails</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>PostgreSQL</category>
      <category>PLANET ARGON</category>
      <category>databases</category>
      <category>replication</category>
      <category>activerecord</category>
      <category>plugins</category>
      <category>planetargon</category>
      <category>code</category>
    </item>
    <item>
      <title>Be Careful that you don't Stub your Big Toe</title>
      <description>&lt;p&gt;In a project that I&amp;#8217;m currently working on, we&amp;#8217;re handling recurring payments for subscribers. I&amp;#8217;ve decided to play with a different payment service &lt;span class="caps"&gt;API&lt;/span&gt; on this project (&lt;a href="http://www.trustcommerce.com/"&gt;TrustCommerce&lt;/a&gt;), which supposedly has one of the easier systems to handle recurring payments as well as one-time charges to the same credit cards. They store all the credit card data so that our delivered product to the client is &lt;a href="http://usa.visa.com/merchants/risk_management/cisp.html"&gt;&lt;span class="caps"&gt;CISP&lt;/span&gt;-compliant&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I came across the &lt;a href="http://www.agilewebdevelopment.com/plugins/trustcommerce_subscription"&gt;TrustCommerce Subscription&lt;/a&gt; plugin for Rails, which does just everything that I need to do in this first product release&amp;#8230; as well as things that aren&amp;#8217;t requirements just yet.&lt;/p&gt;


	&lt;p&gt;Well, I got my test account from TrustCommerce and was working on some RSpecs to test my new subscription and noticed that it was failing. After some snooping around the error responses, I realized that&amp;#8230; test accounts don&amp;#8217;t give you the ability to test the &lt;a href="http://www.trustcommerce.com/citadel.php"&gt;Citadel&lt;/a&gt; features of TrustCommerce. It&amp;#8217;ll be another week or so before finish getting our account setup, so what am I to do? I really want to finish writing these specs and move on to the other portions that are dependent upon this working.&lt;/p&gt;


	&lt;p&gt;Suppose that you were going to perform something like this in an AR callback.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class BillingDetail &amp;lt; ActiveRecord::Base

  # validations    

  before_create :store_credit_card_data_with_trust_commerce

  private 

    def store_credit_card_data_with_trust_commerce
      # some of this is still test data... prettyu much copied from the README
      # TODO: refactor... but keep me out of controllers!
      response = TrustCommerceGateway::Subscription.create(
          :cc =&amp;gt;  self.credit_card_number, 
          :exp =&amp;gt; '0412', 
          :name =&amp;gt; self.customer_name,
          :amount =&amp;gt; 1,
          :cycle =&amp;gt; '1y',
          :demo =&amp;gt; 'y'
        )

      if response['status'] == 'approved'
          self.billing_id = response['billingid']
        else
        # handle failure
        end
    end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;h2&gt;Enter Mock Objects&lt;/h2&gt;


	&lt;p&gt;Since I am unable to succesfully use the &lt;code&gt;TrustCommerceGateway::Subscription.create&lt;/code&gt; method until I get our real account, I needed a simple way to emulate the interaction with the web service.&lt;/p&gt;


	&lt;p&gt;This can be done by using a Mock object, which RSpec provides for you.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
TrustCommerceGateway::Subscription.stub!(:create).and_return( {expected response} )
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Let&amp;#8217;s look at the following spec file (much of it removed to protect the innocent).&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
module ValidBillingDetail
  def valid_attributes
    { # a hash of valid key/values for this model }
  end

  def approved_trust_commerce_subscription
    { 'status' =&amp;gt; 'approved', 'billingid' =&amp;gt; '1093423' } 
  end
end

context "A new billing detail" do
  include ValidBillingDetail

  setup do
    TrustCommerceGateway::Subscription.stub!(:create).and_return( approved_trust_commerce_subscription )
  end

  # bunch of other specs

  specify "should store new billing info with 3rd party API and store the billingid" do
    @billing_detail = BillingDetail.create( valid_attributes )
    @billing_detail.billing_id.should_not_be nil
  end
end  
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;ll notice a few things. First, you&amp;#8217;ll see that I&amp;#8217;ve stubbed the &lt;code&gt;create&lt;/code&gt; method and when it is called in the method in my model, it&amp;#8217;ll return the hash that I&amp;#8217;ve specified.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;TrustCommerceGateway::Subscription.stub!(:create).and_return( approved_trust_commerce_subscription )&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;In the spec, you will see that I am checking that that the &lt;code&gt;.billing_id.should_not_be nil&lt;/code&gt;. If you look back in the method in the model above, you will notice that an approved subscription returns a &lt;code&gt;billing_id&lt;/code&gt;, which is set when the transaction is successful.&lt;/p&gt;


	&lt;p&gt;This is working out great for me and because the documentation is fairly easy to follow, I&amp;#8217;m going to be able to mock much of the behavior that I&amp;#8217;ll be using in the application, without needing to even connect to their &lt;span class="caps"&gt;API&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re using RSpec, I highly encourage you to read more about &lt;a href="http://rspec.rubyforge.org/documentation/mocks/mocks.html"&gt;mocks objects&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Tue, 13 Feb 2007 01:09:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:6e9733fb-1d6b-42a8-a0ad-29948aacd45c</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2007/02/13/be-careful-that-you-dont-stub-your-big-toe</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>Programming</category>
      <category>rspec</category>
      <category>bdd</category>
      <category>mocks</category>
      <category>stubs</category>
      <category>trustcommerce</category>
      <category>plugins</category>
      <category>testing</category>
    </item>
    <item>
      <title>Testing Cookies in Ruby on Rails</title>
      <description>&lt;p&gt;Over the weekend, &lt;a href="http://blog.brightredglow.com/"&gt;Brian Ford&lt;/a&gt; released a useful plugin for testing your &lt;a href="http://www.rubyonrails.org"&gt;Ruby on Rails&lt;/a&gt; applications called, &lt;a href="http://blog.brightredglow.com/articles/2006/08/27/assert_cookie-for-ooey-gooey-fun"&gt;assert_cookie&lt;/a&gt;.&lt;/p&gt;


	&lt;h2&gt;Brian likes his cookies&amp;#8230;&lt;/h2&gt;


&lt;center&gt;
&lt;img src="http://www.robbyonrails.com/files/cookie-monster.jpg" alt="" /&gt; 
&lt;/center&gt;

	&lt;blockquote&gt;
		&lt;p&gt;&lt;em&gt;&amp;#8220;I love cookies. There are, of course, tons of varieties and I’m no connoisseur but I love the soft chocolate chip right out of the oven, hot and gooey. But, if you’re like me, you don’t want your Rails code to be gooey.&amp;#8221;&lt;/em&gt; -Brian Ford&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;To use &lt;strong&gt;assert_cookie&lt;/strong&gt;, follow these steps.&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Install via, &lt;code&gt;script/plugin install http://svn.planetargon.org/rails/plugins/assert_cookie&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Fill your tests with some cookies&lt;/li&gt;
		&lt;li&gt;Test your cookies!&lt;/li&gt;
	&lt;/ol&gt;


Here are a few examples that Brian posted.
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;  &lt;span class="ident"&gt;assert_cookie&lt;/span&gt; &lt;span class="symbol"&gt;:pass&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; 
      &lt;span class="symbol"&gt;:value&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ident"&gt;lambda&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="constant"&gt;UUID&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;parse&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;valid?&lt;/span&gt; &lt;span class="punct"&gt;}&lt;/span&gt;
  &lt;span class="ident"&gt;assert_cookie&lt;/span&gt; &lt;span class="symbol"&gt;:yellow&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:value&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;sunny&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;days&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt;
  &lt;span class="ident"&gt;assert_cookie&lt;/span&gt; &lt;span class="symbol"&gt;:delight&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:value&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;yum&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="ident"&gt;assert_cookie&lt;/span&gt; &lt;span class="symbol"&gt;:secret&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:path&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ident"&gt;lambda&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;path&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="ident"&gt;path&lt;/span&gt; &lt;span class="punct"&gt;=~&lt;/span&gt; &lt;span class="punct"&gt;/&lt;/span&gt;&lt;span class="regex"&gt;secret&lt;/span&gt;&lt;span class="punct"&gt;/&lt;/span&gt; &lt;span class="punct"&gt;},&lt;/span&gt; 
      &lt;span class="symbol"&gt;:secure&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="constant"&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;For more information on other plugins and tools that &lt;a href="http://www.planetargon.com"&gt;&lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt;&lt;/a&gt; is releasing under open source licenses, visit &lt;a href="http://www.planetargon.org"&gt;www.planetargon.org&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Also, be sure to &lt;a href="http://feeds.feedburner.com/defeulerxcosxisinxend"&gt;subscribe to Brian Ford&amp;#8217;s feed&lt;/a&gt; as he says he&amp;#8217;ll be announcing more plugins and tips soon. :-)&lt;/p&gt;


	&lt;p&gt;Have Fun!&lt;/p&gt;
</description>
      <pubDate>Mon, 28 Aug 2006 08:27:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ba154b0e-9877-434d-9fd1-b60ea4a43f93</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2006/08/28/testing-cookies-in-ruby-on-rails</link>
      <category>cookies</category>
      <category>testing</category>
      <category>plugins</category>
      <category>planetargon</category>
      <category>brian</category>
      <category>rails</category>
      <category>monster</category>
    </item>
    <item>
      <title>RAILS PLUGIN: Resource Hacks</title>
      <description>&lt;p&gt;Jeremy Voorhis and Andrew Grim released a new plugin for Ruby on Rails called, &lt;a href="http://www.planetargon.org/trac/wiki/ResourceHacks"&gt;resource hacks&lt;/a&gt; , which can be found in the &lt;a href="http://www.planetargon.com/"&gt;&lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt;&lt;/a&gt; open source repository located at &lt;a href="http://www.planetargon.org"&gt;www.planetargon.org&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Take a moment to &lt;a href="http://www.jvoorhis.com/articles/2006/08/01/announcing-resource_hacks"&gt;read Jeremy&amp;#8217;s announcement&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Enjoy and &lt;a href="http://digg.com/programming/Rails_Plugins_Resource_Hacks"&gt;digg it&lt;/a&gt;. :-)&lt;/p&gt;
</description>
      <pubDate>Thu, 03 Aug 2006 10:17:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:69987012-664a-4dfa-ae18-593460f728a8</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2006/08/03/rails-plugin-resource-hacks</link>
      <category>Ruby on Rails</category>
      <category>Programming</category>
      <category>planetargon</category>
      <category>rails</category>
      <category>plugins</category>
    </item>
  </channel>
</rss>
