Sha256: ad6589bc3d92e8a6a6f100271b134f98ba3f417ea3c86b9dad049d216606c0a4

Contents?: true

Size: 1.02 KB

Versions: 25

Compression:

Stored size: 1.02 KB

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(ExpectationNotMetError)
  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

  it 'Should work with consecutive requests' do
    Response = Struct.new(:body, :headers)
    @response = Response.new({ foo: 'bar' }.to_json)
    expect(json_body).to eq(foo: 'bar')

    @response = Response.new({ foo: 'boo' }.to_json)
    expect(json_body).to eq(foo: 'boo')
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
airborne-0.3.7 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.3.6 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.3.5 spec/airborne/rack/rack_sinatra_spec.rb
hops-airborne-0.2.17 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.3.4 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.3.3 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.3.2 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.3.1 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.3.0 spec/airborne/rack/rack_sinatra_spec.rb
hops-airborne-0.2.16 spec/airborne/rack/rack_sinatra_spec.rb
hops-airborne-0.2.15 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.13 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.12 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.11 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.10 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.9 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.8 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.7 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.6 spec/airborne/rack/rack_sinatra_spec.rb
airborne-0.2.5 spec/airborne/rack/rack_sinatra_spec.rb