Sha256: 38359783a3a23efed191e429d5f4289074d66c97bc63a3e972dedbda65278756

Contents?: true

Size: 913 Bytes

Versions: 18

Compression:

Stored size: 913 Bytes

Contents

require "spec_helper"

RSpec.describe Endpoints::Schema do
  include Rack::Test::Methods

  let(:schema_filename) { "#{Config.root}/schema/schema.json" }

  subject(:get_schema) { get "/schema.json" }

  context "without a schema.json" do
    before do
      allow(File).to receive(:exists?).and_return(false)
    end

    it "raises a 404 on missing schema" do
      assert_raises(Pliny::Errors::NotFound) do
        get_schema
      end
    end
  end

  context "with a schema.json" do
    let(:contents) { "contents" }

    before do
      allow(File).to receive(:exists?).and_return(true)
      allow(File).to receive(:read).and_return(contents)
    end

    it "returns the schema is present" do
      get_schema
      assert_equal 200, last_response.status
      assert_equal "application/schema+json", last_response.headers["Content-Type"]
      assert_equal contents, last_response.body
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pliny-0.21.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.20.2 lib/template/spec/endpoints/schema_spec.rb
pliny-0.20.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.20.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.19.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.18.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.17.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.17.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.16.3 lib/template/spec/endpoints/schema_spec.rb
pliny-0.16.2 lib/template/spec/endpoints/schema_spec.rb
pliny-0.16.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.16.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.15.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.15.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.14.2 lib/template/spec/endpoints/schema_spec.rb
pliny-0.14.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.14.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.13.1 lib/template/spec/endpoints/schema_spec.rb