Sha256: fd870b25abb58f93f1be4ffd1118d813154dd175386b248f45e653c387797f1b
Contents?: true
Size: 1.06 KB
Versions: 14
Compression:
Stored size: 1.06 KB
Contents
RSpec::Matchers.define :invalidate do match do |actual| actual.save.should == false actual.errors[:base].should == ["Access denied"] end end RSpec::Matchers.define :validate do match do |actual| actual.class.transaction do actual.save.should == true raise ActiveRecord::Rollback end true end end RSpec::Matchers.define :destroy do match do |actual| actual.class.transaction do actual.destroy.should == actual raise ActiveRecord::Rollback end actual.class.where(id: actual.id).delete_all true end end RSpec::Matchers.define :survive do match do |actual| actual.class.transaction do actual.destroy.should == false raise ActiveRecord::Rollback end actual.class.where(id: actual.id).delete_all true end end def log! around(:each) do |e| ActiveRecord::Base.logger = Logger.new(STDOUT) e.run ActiveRecord::Base.logger = nil end end def assign!(model, fields) model.assign_attributes(fields) end def read_attribute(model, field) model.read_attribute(field) end
Version data entries
14 entries across 14 versions & 1 rubygems