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

Version Path
protector-0.5.3 spec/spec_helpers/adapters/sequel.rb
protector-0.5.2 spec/spec_helpers/adapters/sequel.rb
protector-0.5.1 spec/spec_helpers/adapters/sequel.rb
protector-0.4.1 spec/spec_helpers/adapters/sequel.rb
protector-0.4.0 spec/spec_helpers/adapters/sequel.rb
protector-0.3.3 spec/spec_helpers/adapters/sequel.rb
protector-0.3.2 spec/spec_helpers/adapters/sequel.rb
protector-0.3.1 spec/spec_helpers/adapters/sequel.rb
protector-0.3.0 spec/spec_helpers/adapters/sequel.rb
protector-0.3.0.beta.2 spec/spec_helpers/adapters/sequel.rb
protector-0.2.4 spec/spec_helpers/adapters/sequel.rb
protector-0.2.3 spec/spec_helpers/adapters/sequel.rb
protector-0.2.2 spec/spec_helpers/adapters/sequel.rb
protector-0.2.1 spec/spec_helpers/adapters/sequel.rb