fredwu / api_taster

A quick and easy way to visually test your Rails application's API.
http://fredwu.github.com/api_taster
727 stars 85 forks source link

Introduce ApiTaster.route_path configuration option #45

Closed timurvafin closed 11 years ago

timurvafin commented 11 years ago

@fredwu,

The right way to define where we would like to use ApiTaster is to require it in the correct bundler group. For example we usually would like to use it in the development and staging environments in the Rails application.

So make sense to require like:

group :development, :staging do
  gem 'api_taster', github: 'fredwu/api_taster'
end

In the config/routes.rb better to check ApiTaster constant definition instead of define tricky logic like this

if Rails.env.development? || Rails.env.staging?
  mount ApiTaster::Engine => '/api_taster'
end

By default Rails loader requires everything from app directory. So in case we are in the test environment for example when api_taster gem does not loaded we will get uninitialized constant ApiTaster error for sure.

And for sure it will be not cool to check ApiTaster constant definition in each file in the app/api_tasters/ folder. Probably better to move api tasters from app/api_tasters to lib/api_tasters.

So this change set implements two things:

  1. ApiTaster.route_path option introduced instead of hardcoded value in the Route class
  2. Default value changed to lib/api_tasters
    • Timur
timurvafin commented 11 years ago

@fredwu it will be great to get some feedback )

fredwu commented 11 years ago

Hi @timurvafin thank you so much for the PR with detailed explanation! :+1: Sorry I haven't been responsive on this project lately, I will go over it in the next few days.

Is this the same issue as #43?

timurvafin commented 11 years ago

@fredwu right #43 is the same issue and that PR could be ignored.