Sha256: 583cc33d4553d900c4a9f3e0aa2ba47b2b5dab10091886a47294e4b9253e0846

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

describe 'Test REST API' do
  before :all do
    $service = RestService.new service: Application
    $data = { name: 'Sample App', version: '0.0.1', status: 'OK' }
    $collection = [{ one: 1 }, { two: 2 }, { three: 3 }]
  end

  subject { $service }
  context 'GET /status : test for status' do
    it { expect(subject.get('/status')).to be_correctly_sent }
    it { expect(subject).to respond_with_status code: 208 }
    it { expect(subject).to respond_a_record }
    it { expect(subject).to respond_with data: $data }
  end

  context 'GET /embeded_status : test for status' do
    it { expect(subject.get('/embeded_status')).to be_correctly_sent }
    it { expect(subject).to respond_with_status code: 208 }
    it { expect(subject).to respond_a_record root: :data }
    it { expect(subject).to respond_with data: $data, root: :data }
  end

  context 'GET /collection : test for Array' do
    it { expect(subject.get('/collection')).to be_correctly_sent }
    it { expect(subject).to respond_with_status code: 200 }
    it { expect(subject).to respond_a_collection_of_record }
    it { expect(subject).to respond_with_collection size: 3 }
    it { expect(subject).to respond_with data: $collection }
  end

  context 'GET /embeded_collection : test for Array' do
    it { expect(subject.get('/embeded_collection')).to be_correctly_sent }
    it { expect(subject).to respond_with_status code: 200 }
    it { expect(subject).to respond_a_collection_of_record root: :data }
    it { expect(subject).to respond_with_collection size: 3, root: :data }
    it { expect(subject).to respond_with data: $collection, root: :data }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-rest-rspec-1.0.0 samples/spec/api_spec.rb