shoulda request params macro

So in a flash of inspiration on the airplane last week, I jotted down a new version of my shoulda params pattern. Put this pastie in test/shoulda_macros/request_params.rb

The general idea is this:


a_get_to(:index) do
  with_params( {:foo => 'bar'}, "valid params" ) do
    should_respond_with :success

    with_params( :more => 'nested stuff' ) do
      should "do something extra special" do
         assert true
      end
    end

  end
end


Here’s what it looks like in action, taken from the ScrumNinja.com code:

require File.dirname(__FILE__) + '/../test_helper'

class MainControllerTest < ActionController::TestCase
  @@message = "you guys rock!" 

  context "When not logged in" do
    setup do
      login_as( nil )
    end
    %w[ index tour contact api ].each do |action|
      a_get_to( action, params=false ) do
        should_respond_with :success
      end
    end

    a_get_to( :feedback, params=false ) do
      should_redirect_to "'/login'" 
    end    

    a_post_to( :contact, :message => @@message ) do
      should_send_email :to => "Mailer::GO_EMAIL", :body => %r{#@@message}
      should_redirect_to "'/'" 
    end
  end

  context "When logged in" do
    setup do
      login_as( @user = create_user )
    end
    a_post_to( :feedback, :message => @@message ) do
      should_send_email :to => "Mailer::GO_EMAIL", :body => %r{#@@message}
      should_respond_with :redirect
    end
  end

end


ScrumNinja Alpha Released

We are proud to announce the alpha of our very first product!

ScrumNinja: a hosted project management tool built from scratch with Scrum in mind.

Here is the message we sent to our announcement list:

Dear Scrum Enthusiast,

We are excited to announce the Alpha version of ScrumNinja. The best way to see the value of this tool is to commit to using it for a real project, even just a small one. ScrumNinja will always be free for one project and up to three users. For now, there are no limits to the number of users or projects. Please check out the quick start guide to get started:

http://scrumninja.com/guide

If you’d like to become an official tester and be considered for a $50 credit, please let us know. Official testers actively use the product to manage a real project, give us feedback and occasionally answer simple questionnaires.

Regards, Rodney and David
actionmailer ActionView ActiveRecord activesupport agile ajax alphadecimal audio autotest BDD blocks capistrano ssh ruby console controller css dashboard widget delegate dog puppy naming name DRM email obfuscation exceptions factories factories-and-workers factory pattern filemerge find and replace finder fink fixtures fun functional testing gem git google maps haml helper helpers imagemagick Intertrust irb javascript jquery jrails logo macro math meetup model openssl OS X patch Pioneer Electronics plugin polymorphism project management prototype.js rails rails gotcha rails,patch,validations railsconf rake rmagick RSA encryption ruby ruby on rails script scrum scrum lessons rails scrumninja shoulda subversion SyncTV TDD testing textmate tips tricks unique hashes unix shell validation view yaml zebra stripes