Sha256: a7dc7b57d4730605b91d95b8ecee951759bb41d3277ec6798983fb01a0bb6f7b

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'rails_helper'

describe Apidoco::FileParser do
  let(:doc) { { name: 'Create Resource' } }
  let(:file) do
    Tempfile.new.tap do |f|
      f.write(doc.to_json)
      f.rewind
    end
  end
  let(:file_parser) { described_class.new(file, parents: []) }

  after do
    file.close
    file.unlink
  end

  describe '#id' do
    subject(:id) { file_parser.id }

    it { is_expected.to eq('createresource') }
  end

  describe '#published?' do
    subject(:published?) { file_parser.published? }

    context 'when published key is not available in the doc' do
      it { is_expected.to eq true }
    end

    context 'when published key is true in the doc' do
      let(:doc) { { published: true } }

      it { is_expected.to eq true }
    end

    context 'when published key is false in the doc' do
      let(:doc) { { published: false } }

      it { is_expected.to eq false }
    end
  end

  describe '#sort_order' do
    subject(:sort_order) { file_parser.sort_order }

    context 'when sort_order key is not available in the doc' do
      it { is_expected.to eq 999 }
    end

    context 'when sort_order key is available in the doc' do
      let(:doc) { { sort_order: 25 } }

      it { is_expected.to eq 25 }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apidoco-1.6.0 spec/apidoco/file_parser_spec.rb