Sha256: b3627c10a5f578998bc4d8bd4d6c21ddbcf17ab8ce614f6430e9d06f3fed3405
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
Contents
require_relative '../spec_helper' class CodeIdentifierTest < Lanes::TestCase class CodeIdentifierTestModel class_attribute :blocks attr_accessor :code include Lanes::Concerns::CodeIdentifier def self.before_validation( opts={}, &block ) self.blocks||=[] self.blocks.push( block ) end def self.validates( *opts ) end def run_validations self.class.blocks.each{ |b| self.instance_eval(&b) } end def [](name) :name == name ? 'A Long String of Nonsense' : '' end has_code_identifier :from => :name end def test_that_it_uppercases ci = CodeIdentifierTestModel.new ci.code='test' ci.run_validations assert_equal 'TEST', ci.code end def test_that_it_generates ci = CodeIdentifierTestModel.new ci.run_validations assert ci.code.present?, "Code wasn't auto-generated" assert_equal 'ALOSTOFNON', ci.code end end
Version data entries
4 entries across 4 versions & 1 rubygems