Sha256: 36e9e7d4550d84cb6d2ffafeb066d016cda5255dbadb2ad4bc30449392f727a3
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true describe Grape::ExtraValidators::MaximumLength do module ValidationsSpec module MaximumLengthValidatorSpec class API < Grape::API default_format :json params do optional :text, type: String, maximum_length: 8 end post "/" do body false end end end end def app ValidationsSpec::MaximumLengthValidatorSpec::API end let(:params) { { text: text } } let(:text) { nil } before { post "/", params } subject { last_response.status } context "when the length is less than the configured maximum length" do let(:text) { "1234567" } it { is_expected.to eq(204) } end context "when the length is equal to the configured maximum length" do let(:text) { "12345678" } it { is_expected.to eq(204) } end context "when the length is more than the configured maximum length" do let(:text) { "123456789" } it { is_expected.to eq(400) } end context "when the parameter is nil" do it { is_expected.to eq(204) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grape-extra_validators-2.0.0 | spec/grape/extra_validators/maximum_length_spec.rb |
grape-extra_validators-1.0.0 | spec/grape/extra_validators/maximum_length_spec.rb |