Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Forked from iain/user.rb
Created October 21, 2009 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchelimsky/215201 to your computer and use it in GitHub Desktop.
Save dchelimsky/215201 to your computer and use it in GitHub Desktop.
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# active :boolean
# created_at :datetime
# updated_at :datetime
#
class User < ActiveRecord::Base
named_scope :active, :conditions => { :active => true }
end
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User do
it "should get all active users" do
active = User.create!(:active => true)
inactive = User.create!(:active => false)
subject = User.active
subject.should be_all(&:active)
inverse = User.all - subject
inverse.none?(&:active).should be_true
inverse.any?(&:active).should be_false
# inverse.should be_none(&:active)
inverse.should_not be_any(&:active)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment