Sha256: baac2282b20312bf3f1a7d01a9ee7080316c83af395c360dded39bebbffe0065

Contents?: true

Size: 847 Bytes

Versions: 11

Compression:

Stored size: 847 Bytes

Contents

require 'spec_helper'

describe 'Parameter Sets' do
  describe 'one_of' do
    it 'returns 400 on requests that contain more than one mutually exclusive parameter' do
      params = [
        {a: 1, b: 2},
        {b: 2, c: 3},
        {a: 1, b: 2, c: 3}
      ]
      params.each do |param|
        get('/choice', param) do |response|
          response.status.should == 400
          JSON.parse(response.body)['message'].should =~ /mutually exclusive/
        end
      end
    end

    it 'returns successfully for requests that only have one parameter' do
      params = [
        {a: 1},
        {b: 2},
        {c: 3}
      ]
      params.each do |param|
        get('/choice', param) do |response|
          response.status.should == 200
          JSON.parse(response.body)['message'].should =~ /OK/
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sinatra-param-1.2.2 spec/parameter_sets_spec.rb
sinatra-param-1.2.1 spec/parameter_sets_spec.rb
sinatra-param-1.2.0 spec/parameter_sets_spec.rb
sinatra-param-1.1.2 spec/parameter_sets_spec.rb
sinatra-param-1.1.1 spec/parameter_sets_spec.rb
sinatra-param-1.1.0 spec/parameter_sets_spec.rb
sinatra-param-1.0.3 spec/parameter_sets_spec.rb
sinatra-param-1.0.2 spec/parameter_sets_spec.rb
sinatra-param-1.0.1 spec/parameter_sets_spec.rb
sinatra-param-1.0.0 spec/parameter_sets_spec.rb
sinatra-param-0.1.3 spec/parameter_sets_spec.rb