Sha256: dbebb5e6e10aa352b7efa3a28d67dc8bd6b12aaf0b83630fe771d11d3afde355

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

# encoding: UTF-8

require 'spec_helper'

describe "find-route" do
  before do
    routes = Rails.application.routes
    routes.draw {
      namespace :admin do
        resources :users
        resources :images
      end
    }
    routes.finalize!
  end

  it 'returns the route for a single action' do
    output = mock_pry('find-route Admin::UsersController#show', 'exit-all')
    output.must_match /show GET/
    output.wont_match /index GET/
  end

  it 'returns all the routes for a controller' do
    output = mock_pry('find-route Admin::UsersController', 'exit-all')
    output.must_match /index GET/
    output.must_match /show GET/
    output.must_match /new GET/
    output.must_match /edit GET/
    output.must_match /update (PATCH|PUT)/
    output.must_match /update PUT/
    output.must_match /destroy DELETE/
  end

  it 'returns all routes for controllers under a namespace' do
    output = mock_pry('find-route Admin', 'exit-all')
    output.must_match /Routes for Admin::UsersController/
    output.must_match /Routes for Admin::ImagesController/
  end

  it 'returns no routes found when controller is not recognized' do
    output = mock_pry('find-route Foo', 'exit-all')
    output.must_match /No routes found/
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
pry-rails-0.3.6 spec/find_route_spec.rb
pry-rails-0.3.5 spec/find_route_spec.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/pry-rails-0.3.4/spec/find_route_spec.rb
pry-rails-0.3.4 spec/find_route_spec.rb
pry-rails-0.3.3 spec/find_route_spec.rb