Sha256: 0fc07687c2c4ae0d336ed2d4a286dcc781e02f4cb79d2f82fbc2d687772d50d7

Contents?: true

Size: 938 Bytes

Versions: 25

Compression:

Stored size: 938 Bytes

Contents

require 'spec_helper'

describe 'expect path' do
  describe 'errors' do
    before :each do
      mock_get('array_with_index')
      get '/array_with_index'
    end

    it 'should raise PathError when incorrect path containing .. is used' do
      expect do
        expect_json('cars..make', 'Tesla')
      end.to raise_error(PathError, "Invalid Path, contains '..'")
    end

    it 'should raise PathError when trying to call property on an array' do
      expect do
        expect_json('cars.make', 'Tesla')
      end.to raise_error(PathError, "Expected Array\nto be an object with property make")
    end
  end

  it 'should work with numberic properties' do
    mock_get('numeric_property')
    get '/numeric_property'
    expect_json('cars.0.make', 'Tesla')
  end

  it 'should work with numberic properties' do
    mock_get('numeric_property')
    get '/numeric_property'
    expect_json_keys('cars.0', [:make, :model])
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
airborne-0.2.4 spec/airborne/path_spec.rb
airborne-0.2.3 spec/airborne/path_spec.rb
airborne-0.2.2 spec/airborne/path_spec.rb
airborne-0.2.1 spec/airborne/path_spec.rb
airborne-0.2.0 spec/airborne/path_spec.rb