Project

suit

0.0
No release in over 3 years
Low commit activity in last 3 years
A collection of commonly used rspec matchers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
~> 1.8.3
= 3.1.3
>= 0
~> 3.12

Runtime

>= 1.3.0
>= 2.99.0
 Project Readme

suit¶ ↑

A set of rspec scope matchers.

Matchers for common controller methods:¶ ↑

describe UsersController, "on GET to show with a valid id" do

 it { should require_login :index, :get }
 it { should require_role('admin', :index, :get) }
end

Matchers for common active record scopes:¶ ↑

  scope :by_title, order("title ASC")
  scope :by_name, order("name ASC")
  scope :by_newest, order("created_at DESC")
  scope :by_oldest, order("created_at ASC")
  scope :by_latest, order("updated_at DESC")
  scope :newer_than, lambda { |*args| where("created_at > ?", args.first || DateTime.now) }
  scope :older_than, lambda { |*args| where("created_at < ?", args.first || 1.day.ago.to_s(:db)) }
  scope :is_public, where(["is_public = ?", true])
  scope :created_by, lambda { |creator| where("creator_id = ? AND creator_type = ?", creator.id, creator.class.to_s) } }
  scope :sorted, order("sort ASC")
  scope :sorted_id, order("id ASC")

These matchers will test common scopes used in active record models:

  describe User do
    it { should scope_by_title }
    it { should scope_by_name }
    it { should scope_by_latest }
    it { should scope_by_newest }
    it { should scope_by_oldest }

    it { should scope_newer_than }
    it { should scope_older_than }

    it { should scope_is_public }

    it { should scope_created_by }

    it { should sanitize :title }
    it { should scope_sorted }
    it { should scope_sorted_id }
  end

Copyright © 2012 Tatemae.com. See LICENSE.txt for further details.