Sha256: c66cb5d27a0d6732662c82bc87cde498517d9fe1f9565e076015321335cc33bc

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

require 'json'
require 'sinatra'

class SampleApp < Sinatra::Application
  before do
    content_type 'application/json'
  end

  get '/' do
    { foo: 'bar' }.to_json
  end
end

Airborne.configure do |config|
  config.rack_app = SampleApp
end

describe 'rack app' do
  it 'should allow requests against a sinatra app' do
    get '/'
    expect_json_types(foo: :string)
  end

  it 'should ensure correct values from sinatra app' do
    get '/'
    expect { expect_json_types(foo: :int) }.to raise_error
  end

  it 'Should set json_body even when not using the airborne http requests' do
    Response = Struct.new(:body, :headers)
    @response = Response.new({ foo: 'bar' }.to_json)
    expect(json_body).to eq(foo: 'bar')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
airborne-0.1.16 spec/airborne/rack/rack_sinatra_spec.rb