How to Run Each Test or Spec One by One

On my new project we had the problem that some specs failed when ran on their own, and some specs produces strange output (like “use object_id”), so I build a helper that runs each test on its own and could pinpoint the problem.

rake spec:one_by_one

it is now included in the single test rails plugin

Advertisements

Simple Meta Tags with MetaOnRails

Simple meta tag rules (from google webmaster tools):

  1. do not add useless meta tags
  2. add site-wide-unique meta tags
  3. add max 10 keywords
  4. in doubt add no meta tags, search engines will grab something

Obey or be penalized.

For simplicity use: MetaOnRails Rails plugin

Usage

#in your head (no not that head...)
=display_meta

#in your views, add unique keywords/description that matter
set_meta(
  :keywords=> [@movie.category, @movie.genre,@user.name]*' ',
  :description=>@movie.description
)

Output

<meta name="description" content="my description" />
<meta name="keywords" content="my,keyword" />

has_a_location – the Latitude Longitude – Rails Plugin

Easy handling of latitude/longitude information, build on top of acts_as_mappable (aka geokit).

has_a_location Installation instructions

Usage

class User < ActiveRecord::Base
  has_a_location
end

@user.location = [11.101,22.121]# latitude , longitude
@user.in_radius(100) #find in 100 miles radius

#this location will not be stored since it is the "default location"
@user.location = [0,0] 

show_map if @user.location

All options and Readme

DRY Validation Testing and easy edge-case Records

I just pushed my latest changes and additions for the old asser_invalid_attributes to github.

  • create single valid record
  • edge-case records without fixtures
  • valid attributes to test a post or fill a form

README

Install

script/plugin install git://github.com/grosser/valid_attributes.git

Usage
  • set of valid attributes:
    valid_attributes User
  • a valid Record(new):
    valid User
  • a valid saved Record:
    create_valid User
  • an edge-case User:
    valid User, :name=>’oh noo it is too long’