Sha256: bfa1abc423487e7f4861ccb0a963c8ffc1009ce653f10d542d0d5beae8603fc1
Contents?: true
Size: 1.12 KB
Versions: 14
Compression:
Stored size: 1.12 KB
Contents
RSpec::Matchers.define :invalidate do match do |actual| DB.transaction do expect{ actual.save }.to raise_error actual.errors.on(:base).should == ["Access denied"] raise Sequel::Rollback end true end end RSpec::Matchers.define :validate do match do |actual| DB.transaction do expect{ actual.save }.to_not raise_error raise Sequel::Rollback end true end end RSpec::Matchers.define :destroy do match do |actual| DB.transaction do expect{ actual.destroy.should }.to_not raise_error raise Sequel::Rollback end actual.class.where(id: actual.id).delete true end end RSpec::Matchers.define :survive do match do |actual| DB.transaction do expect{ actual.destroy.should }.to raise_error raise Sequel::Rollback end actual.class.where(id: actual.id).delete true end end def log! around(:each) do |e| DB.loggers << Logger.new(STDOUT) e.run DB.loggers = [] end end def assign!(model, fields) model.set_all(fields) end def read_attribute(model, field) model.instance_variable_get("@values")[field] end
Version data entries
14 entries across 14 versions & 1 rubygems