Sha256: a8b233e06089718ca5663227b1dd0a8df08dc0d30ee2c201df9adb80c45ab281

Contents?: true

Size: 795 Bytes

Versions: 5

Compression:

Stored size: 795 Bytes

Contents

require 'spec_helper'

describe 'Parameter Sets' do
  describe 'any_of' do
    it 'returns 400 on requests that contain fewer than one required parameter' do
      get('/any_of', {}) do |response|
        expect(response.status).to eql 400
        expect(JSON.parse(response.body)['message']).to match(/Invalid parameters/)
      end
    end

    it 'returns successfully for requests that have at least one parameter' do
      params = [
        {a: 1},
        {b: 2},
        {c: 3},
        {a: 1, b: 2},
        {b: 2, c: 3},
        {a: 1, b: 2, c: 3}
      ]

      params.each do |param|
        get("/any_of", param) do |response|
          expect(response.status).to eql 200
          expect(JSON.parse(response.body)['message']).to match(/OK/)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
jdx-sinatra-param-0.0.1 spec/parameter_inclusivity_spec.rb
sinatra-param-1.6.0 spec/parameter_inclusivity_spec.rb
sinatra-param-1.5.0 spec/parameter_inclusivity_spec.rb
sinatra-param2-1.0.0 spec/parameter_inclusivity_spec.rb
sinatra-param-1.4.0 spec/parameter_inclusivity_spec.rb