Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ApiTaster.route_path configuration option #45

Merged
merged 1 commit into from
Jul 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/api_taster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module ApiTaster
mattr_accessor :global_params
self.global_params = {}

mattr_accessor :route_path
self.route_path = "#{Rails.root}/lib/api_tasters"

def self.routes(&block)
ApiTaster::RouteCollector.routes << block
end
Expand Down
2 changes: 1 addition & 1 deletion lib/api_taster/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Route
cattr_accessor :metadata

class << self
def map_routes(path = "#{Rails.root}/app/api_tasters")
def map_routes(path = ApiTaster.route_path)
self.route_set = Rails.application.routes
self.supplied_params = {}
self.obsolete_definitions = []
Expand Down
6 changes: 3 additions & 3 deletions spec/mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ApiTaster
before(:all) do
ApiTaster.global_params = { :foo => 'bar' }

Route.map_routes "#{Rails.root}/app/api_tasters/global_params"
Route.map_routes "#{Rails.root}/lib/api_tasters/global_params"
end

it "merges params" do
Expand All @@ -25,7 +25,7 @@ module ApiTaster
end

Route.route_set = routes
Route.map_routes "#{Rails.root}/app/api_tasters/mapper"
Route.map_routes "#{Rails.root}/lib/api_tasters/mapper"
end

it "records obsolete definitions" do
Expand All @@ -40,7 +40,7 @@ module ApiTaster
end
end

Route.map_routes "#{Rails.root}/app/api_tasters/mapper"
Route.map_routes "#{Rails.root}/lib/api_tasters/mapper"
end

it "gets users" do
Expand Down
2 changes: 1 addition & 1 deletion spec/route_collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ApiTaster
Rails.application.routes.draw do
resources :dummy_users
end
Route.map_routes "#{Rails.root}/app/api_tasters/route_collector"
Route.map_routes "#{Rails.root}/lib/api_tasters/route_collector"
end

it "gets users" do
Expand Down