Sha256: 32e86f25bcff0f569d66f10bebe662ab7053a735bc8a0dfbac0c107e2257da44

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

RSpec.describe Grape::App do

  subject { described_class }
  before  { subject.init! File.expand_path('../../scenario', __FILE__) }

  it 'should have an env' do
    expect(subject.env).to be_instance_of(ActiveSupport::StringInquirer)
    expect(subject.env).to eq("test")
  end

  it 'should have an root' do
    expect(subject.root).to be_instance_of(Pathname)
  end

  it 'should be an API' do
    expect(subject).to be < Grape::API
  end

  it 'should init with default time zone' do
    expect(Time.zone.name).to eq("UTC")
  end

  it 'should configure i18n' do
    expect(I18n.load_path).to include(subject.root.join("config", "locales", "en.yml").to_s)
    expect(I18n.default_locale).to eq(:en)
    expect(I18n.exception_handler).to be_instance_of(Proc)
  end

  it 'should read env specific initializers' do
    expect(subject.config).to eq(
      test_specific: true,
      raise_on_missing_translations: true,
      cors_allow_origins: ["example.com"],
    )
  end

  it 'should prepare middleware' do
    expect(subject.middleware).to be_instance_of(Rack::Builder)
    expect(subject.middleware.send(:instance_variable_get, :@use).size).to eq(1)
    expect(subject.middleware.send(:instance_variable_get, :@run)).to eq(subject)
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
grape-app-0.3.16 spec/grape/app_spec.rb
grape-app-0.3.15 spec/grape/app_spec.rb
grape-app-0.3.14 spec/grape/app_spec.rb
grape-app-0.3.12 spec/grape/app_spec.rb
grape-app-0.3.11 spec/grape/app_spec.rb
grape-app-0.3.10 spec/grape/app_spec.rb
grape-app-0.3.9 spec/grape/app_spec.rb
grape-app-0.3.5 spec/grape/app_spec.rb