Sha256: 7734544df385d402afd49dcf6882237e0378eac014493b0346041df6fab13629
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
require 'spec_helper' describe GrapeApiary::Config do include_context 'configuration' subject { GrapeApiary::Config } it 'allows for host to be set' do subject.host = host expect(subject.host).to eq(host) end it 'allows for name to be set' do subject.name = name expect(subject.name).to eq(name) end it 'allows for description to be set' do subject.description = description expect(subject.description).to eq(description) end context 'headers' do [:request_headers, :response_headers].each do |type| context type do it 'is an array' do expect(subject.send(type)).to be_a(Array) end it 'allows for request headers to be set in bulk' do headers = send(type) subject.send("#{type}=", headers) expect(subject.send(type)).to eq(headers) end it 'allows for request headers to be set individually' do header = { Host: 'api.connexiolabs-qa.com' } expect do subject.send(type) << header end.to change { subject.send(type).length }.by(1) end end end end context 'sample id generation' do it 'allows for setting the type for id generation' do subject.example_id_type = :uuid expect(subject.example_id_type).to eq(:uuid) end it 'guards against unsupported types' do expect do subject.example_id_type = :foo end.to raise_error(UnsupportedIDType) end it 'checks for the bson library if requested' do expect { subject.example_id_type = :bson }.to raise_error(BSONNotDefinied) end it 'generates a valid uuid' do test = /[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/i subject.example_id_type = :uuid expect(subject.generate_id).to match(test) end it 'generates a valid integer' do test = /^[0-9]{1,10}$/ subject.example_id_type = :integer expect(subject.generate_id.to_s).to match(test) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grape-apiary-0.0.4 | spec/grape-apiary/config_spec.rb |
grape-apiary-0.0.3 | spec/grape-apiary/config_spec.rb |