Sha256: 8399ee84fe1773f2dc8ef8166485d7727a8f433ad0525faf4da591303c765287

Contents?: true

Size: 911 Bytes

Versions: 17

Compression:

Stored size: 911 Bytes

Contents

require "spec_helper"

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

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

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

  context "without a schema.json" do
    before do
      allow(File).to receive(:exist?).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(:exist?).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

17 entries across 17 versions & 1 rubygems

Version Path
pliny-1.1.0 lib/template/spec/endpoints/schema_spec.rb
pliny-1.0.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.32.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.31.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.30.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.30.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.29.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.28.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.27.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.27.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.26.2 lib/template/spec/endpoints/schema_spec.rb
pliny-0.26.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.26.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.25.1 lib/template/spec/endpoints/schema_spec.rb
pliny-0.25.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.24.0 lib/template/spec/endpoints/schema_spec.rb
pliny-0.23.0 lib/template/spec/endpoints/schema_spec.rb