Sha256: 6a93289f72644386ccd35dd7c2ab86b92f1dfd53fc7298b76a1e3883265ac4aa
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true describe Grape::Validations::MultipleAttributesIterator do describe '#each' do subject(:iterator) { described_class.new(validator, scope, params) } let(:scope) { Grape::Validations::ParamsScope.new(api: Class.new(Grape::API)) } let(:validator) { double(attrs: %i[first second third]) } context 'when params is a hash' do let(:params) do { first: 'string', second: 'string' } end it 'yields the whole params hash without the list of attrs' do expect { |b| iterator.each(&b) }.to yield_with_args(params) end end context 'when params is an array' do let(:params) do [{ first: 'string1', second: 'string1' }, { first: 'string2', second: 'string2' }] end it 'yields each element of the array without the list of attrs' do expect { |b| iterator.each(&b) }.to yield_successive_args(params[0], params[1]) end end context 'when params is empty optional placeholder' do let(:params) { [Grape::DSL::Parameters::EmptyOptionalValue] } it 'does not yield it' do expect { |b| iterator.each(&b) }.to yield_successive_args end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-1.8.0 | spec/grape/validations/multiple_attributes_iterator_spec.rb |