public
Description: ActiveRecord macro that helps encrypt passwords and generate api tokens before_save.
Homepage:
Clone URL: git://github.com/matthewtodd/has_digest.git
commit  2a41691cd06bd4a8621e3054e6973e7b688f020f
tree    9f207ccd1173460463a74bd27c859ece68e6046d
parent  c9793a8134933b4ecd328ebf0228e39db6d2ee1a
has_digest / test / test_helper.rb
100644 29 lines (24 sloc) 0.805 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'mocha'
require 'active_record'
require File.join(File.dirname(__FILE__), '..', 'lib', 'has_digest.rb')
 
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
 
def model_with_attributes(*attributes, &block)
  ActiveRecord::Base.connection.create_table :models, :force => true do |table|
    attributes.each do |attribute|
      table.string attribute
    end
  end
 
  ActiveRecord::Base.send(:include, HasDigest)
  Object.send(:remove_const, 'Model') rescue nil
  Object.const_set('Model', Class.new(ActiveRecord::Base))
  Model.class_eval(&block) if block_given?
 
  return Model
end
 
class Test::Unit::TestCase
  def assert_unique(collection)
    assert_same_elements collection.uniq, collection
  end
end