class ActiveRecordTest::BaseTestCase
Public Class Methods
new()
click to toggle source
Calls superclass method
# File test/unit/integrations/active_record_test.rb, line 53 def initialize super @notifications = [] end
Public Instance Methods
default_test()
click to toggle source
# File test/unit/integrations/active_record_test.rb, line 27 def default_test end
Protected Instance Methods
new_model(create_table = :foo, &block)
click to toggle source
Creates a new ActiveRecord model (and the associated table)
# File test/unit/integrations/active_record_test.rb, line 32 def new_model(create_table = :foo, &block) table_name = create_table || :foo model = Class.new(ActiveRecord::Base) do connection.create_table(table_name, :force => true) {|t| t.string(:state)} if create_table set_table_name(table_name.to_s) (class << self; self; end).class_eval do define_method(:name) { "ActiveRecordTest::#{table_name.to_s.capitalize}" } end end model.class_eval(&block) if block_given? model.reset_column_information if create_table model end
new_observer(model, &block)
click to toggle source
Creates a new ActiveRecord observer
# File test/unit/integrations/active_record_test.rb, line 49 def new_observer(model, &block) observer = Class.new(ActiveRecord::Observer) do attr_accessor :notifications def initialize super @notifications = [] end end (class << observer; self; end).class_eval do define_method(:name) do "#{model.name}Observer" end end observer.observe(model) observer.class_eval(&block) if block_given? observer end