Sha256: 62fe70d6b5d2a2f28d7cba19567192470752a28fa6ca9dc64c1bcb8068b2233a

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe 'expect_json_types' do

  it 'should detect current type' do
    mock_get('simple_get')
    get '/simple_get'
    expect_json_types({name: :string, age: :int})
  end

  it 'should fail when incorrect json types tested' do
    mock_get('simple_get')
    get '/simple_get'
    expect{expect_json_types({bad: :bool})}.to raise_error
  end

  it 'should not fail when optional property is not present' do
    mock_get('simple_get')
    get '/simple_get'
    expect_json_types({name: :string, age: :int, optional: :bool_or_null })
  end

  it 'should allow full object graph' do
    mock_get('simple_path_get')
    get '/simple_path_get'
    expect_json_types({name: :string, address: {street: :string, city: :string, state: :string}})
  end

  it 'should check all types in a simple array' do
    mock_get('array_of_values')
    get '/array_of_values'
    expect_json_types({grades: :array_of_ints})
  end

  it 'should ensure all valid types in a simple array' do
    mock_get('array_of_values')
    get '/array_of_values'
    expect{expect_json_types({bad: :array_of_ints})}.to raise_error
  end

  it 'should allow empty array' do
    mock_get('array_of_values')
    get '/array_of_values'
    expect_json_types({emptyArray: :array_of_ints})
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
airborne-0.1.15 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.14 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.13 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.12 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.11 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.10 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.9 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.8 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.7 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.6 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.5 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.4 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.3 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.2 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.1.1 spec/airborne/expectations/expect_json_types_spec.rb
airborne-0.0.23 spec/airborne/expectations/expect_json_types_spec.rb