Sha256: 52b6262c27790bbe485e3469f9be40fed44ad92be5eb0a1b773ded53a03e4dc8

Contents?: true

Size: 610 Bytes

Versions: 10

Compression:

Stored size: 610 Bytes

Contents

def expected_policy_behavior(policy:, policy_args: [], input:, output: nil, errors: {}, environment: {}, ignore_for: [])
  output ||= input
  schema = Paradocs::Schema.new do
    input.map do |key, value|
      instruction = ignore_for.include?(key) ? -> { field(key) } : -> { field(key).policy(*([policy] + policy_args)) }

      instance_exec &instruction
    end
  end

  if block_given? || output.nil?
    expect { schema.resolve(input, environment) }.to yield
  else
    result = schema.resolve(input, environment)
    expect(result.output).to eq(output)
    expect(result.errors).to eq(errors)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
paradocs-1.1.6 spec/helpers.rb
paradocs-1.1.5 spec/helpers.rb
paradocs-1.1.4 spec/helpers.rb
paradocs-1.1.3 spec/helpers.rb
paradocs-1.1.2 spec/helpers.rb
paradocs-1.1.1 spec/helpers.rb
paradocs-1.1.0 spec/helpers.rb
paradocs-1.0.24 spec/helpers.rb
paradocs-1.0.23 spec/helpers.rb
paradocs-1.0.22 spec/helpers.rb