spec/grape/validations_spec.rb in grape-1.0.1 vs spec/grape/validations_spec.rb in grape-1.0.2

- old
+ new

@@ -61,11 +61,11 @@ end end it 'adds entity documentation to declared params' do define_optional_using - expect(subject.route_setting(:declared_params)).to eq([:field_a, :field_b]) + expect(subject.route_setting(:declared_params)).to eq(%i[field_a field_b]) end it 'works when field_a and field_b are not present' do get '/optional' expect(last_response.status).to eq(200) @@ -137,11 +137,11 @@ end end it 'adds entity documentation to declared params' do define_requires_all - expect(subject.route_setting(:declared_params)).to eq([:required_field, :optional_field]) + expect(subject.route_setting(:declared_params)).to eq(%i[required_field optional_field]) end it 'errors when required_field is not present' do get '/required' expect(last_response.status).to eq(400) @@ -172,11 +172,11 @@ end end it 'adds entity documentation to declared params' do define_requires_none - expect(subject.route_setting(:declared_params)).to eq([:required_field, :optional_field]) + expect(subject.route_setting(:declared_params)).to eq(%i[required_field optional_field]) end it 'errors when required_field is not present' do get '/required' expect(last_response.status).to eq(400) @@ -202,11 +202,11 @@ end end it 'adds only the entity documentation to declared params, nothing more' do define_requires_all - expect(subject.route_setting(:declared_params)).to eq([:required_field, :optional_field]) + expect(subject.route_setting(:declared_params)).to eq(%i[required_field optional_field]) end end context 'requires :none' do def define_requires_none @@ -348,11 +348,11 @@ context 'hash with a required param with validation' do before do subject.params do requires :items, type: Hash do - requires :key, type: String, values: %w(a b) + requires :key, type: String, values: %w[a b] end end subject.get '/required' do 'required works' end @@ -1056,31 +1056,31 @@ it 'by #use' do subject.params do use :pagination end - expect(subject.route_setting(:declared_params)).to eq [:page, :per_page] + expect(subject.route_setting(:declared_params)).to eq %i[page per_page] end it 'by #use with multiple params' do subject.params do use :pagination, :period end - expect(subject.route_setting(:declared_params)).to eq [:page, :per_page, :start_date, :end_date] + expect(subject.route_setting(:declared_params)).to eq %i[page per_page start_date end_date] end end context 'with block' do before do subject.helpers do params :order do |options| - optional :order, type: Symbol, values: [:asc, :desc], default: options[:default_order] + optional :order, type: Symbol, values: %i[asc desc], default: options[:default_order] optional :order_by, type: Symbol, values: options[:order_by], default: options[:default_order_by] end end subject.format :json subject.params do - use :order, default_order: :asc, order_by: [:name, :created_at], default_order_by: :created_at + use :order, default_order: :asc, order_by: %i[name created_at], default_order_by: :created_at end subject.get '/order' do { order: params[:order], order_by: params[:order_by]