Sha256: 026ed4a177f66718a959207ed1c851d33621bd3e12aee29bc2e256c01cabdbbe

Contents?: true

Size: 952 Bytes

Versions: 3

Compression:

Stored size: 952 Bytes

Contents

require 'rails_helper'
require 'sorbet-rails/routes_rbi_formatter'

RSpec.describe RoutesRbiFormatter do
  it 'sets up Rails Application' do
    expect(Rails.application.routes).to_not be_empty
  end

  it 'generates _path and _url of a named route' do
    all_routes = Rails.application.routes.routes
    require "action_dispatch/routing/inspector"
    inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
    formatted = inspector.format(RoutesRbiFormatter.new)
    expect_match_file(formatted, 'expected_routes.rbi')
  end

  it 'generates correctly when there is no routes' do
    empty_set = ActionDispatch::Routing::RouteSet.new
    empty_set.draw do
      # no routes
    end
    require "action_dispatch/routing/inspector"
    inspector = ActionDispatch::Routing::RoutesInspector.new(empty_set.routes)
    formatted = inspector.format(RoutesRbiFormatter.new)
    expect_match_file(formatted, 'expected_no_routes.rbi')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sorbet-rails-0.4.0 spec/routes_rbi_formatter_spec.rb
sorbet-rails-0.3.0 spec/routes_rbi_formatter_spec.rb
sorbet-rails-0.2.0 spec/routes_rbi_formatter_spec.rb