matthewtodd / has_digest
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (4)
- Wiki (1)
- Graphs
-
Tree:
695012b
has_digest / shoulda_macros / has_digest.rb
| 812e36da » | matthewtodd | 2008-11-07 | 1 | module HasDigest | |
| 2 | module Shoulda | ||||
| 4405ecbf » | matthewtodd | 2008-11-07 | 3 | # Asserts that the necessary database columns exist to support | |
| 4 | # <tt>has_digest :name</tt> and that the necessary callback methods have | ||||
| 5 | # been created. | ||||
| 695012b3 » | matthewtodd | 2008-11-07 | 6 | def should_have_digest(name, options = {}) | |
| 812e36da » | matthewtodd | 2008-11-07 | 7 | context "Class #{model_class.name} with digest #{name}" do | |
| 77e5f5aa » | matthewtodd | 2008-11-07 | 8 | should_have_db_column name, :type => :string # TODO :limit => 40 | |
| 812e36da » | matthewtodd | 2008-11-07 | 9 | should_have_instance_methods "digest_#{name}" | |
| 695012b3 » | matthewtodd | 2008-11-07 | 10 | ||
| 11 | dependencies = options[:depends] | ||||
| 12 | dependencies = [dependencies] unless dependencies.respond_to?(:each) | ||||
| 13 | dependencies.compact! | ||||
| 14 | |||||
| 15 | dependencies.each do |dependency| | ||||
| 16 | should_have_instance_methods "#{dependency}", "#{dependency}=" | ||||
| 17 | end | ||||
| 812e36da » | matthewtodd | 2008-11-07 | 18 | end | |
| 19 | end | ||||
| 20 | end | ||||
| 21 | end | ||||
| 22 | |||||
| 23 | Test::Unit::TestCase.extend(HasDigest::Shoulda) | ||||
