Sha256: dca36777bd5c7c913d492d0cd75498cf8c267e0253f761d2a961ddbc34af5637

Contents?: true

Size: 619 Bytes

Versions: 1

Compression:

Stored size: 619 Bytes

Contents

# encoding: utf-8

# Mocks a valid policy object
#
# @return [Policy::Base::Node]
def valid_policy
  policy = Policy::Base::Node.new
  allow(policy).to receive(:valid?)   { true  }
  allow(policy).to receive(:invalid?) { false }
  policy
end

# Mocks an invalid policy object
#
# @return [Policy::Base::Node]
def invalid_policy(error: "error")
  policy = Policy::Base::Node.new

  add_errors = lambda do
    policy.errors.clear
    policy.errors.add(:base, error)
  end

  allow(policy).to receive(:valid?)   { add_errors.call && false }
  allow(policy).to receive(:invalid?) { add_errors.call && true  }

  policy
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
policy-2.0.0 spec/support/composer.rb