Sha256: b4a91617608459f931196b39da0493578172665ce498c60eb95e65a4622a773a

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

require 'spec_helper'

describe GrapeRouteHelpers::AllRoutes do
  Grape::API.extend described_class

  describe '#all_routes' do
    context 'when API is mounted within another API' do
      let(:mounting_api) { Spec::Support::MountedAPI }

      it 'does not include the same route twice' do
        mounting_api

        # A route is unique if no other route shares the same set of options
        all_route_options = Grape::API.all_routes.map do |r|
          r.instance_variable_get(:@options)
        end

        duplicates = all_route_options.select do |o|
          all_route_options.count(o) > 1
        end

        expect(duplicates).to be_empty
        expect(all_route_options.size).to eq(7)

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-route-helpers-1.2.2 spec/grape_route_helpers/all_routes_spec.rb