Skip to content

Commit

Permalink
Merge pull request #45 from fs/load-tasters-from-lib
Browse files Browse the repository at this point in the history
Introduce ApiTaster.route_path configuration option
  • Loading branch information
fredwu committed Jul 19, 2013
2 parents 83864a7 + c3ee730 commit 8ac3021
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 5 deletions.
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
File renamed without changes.
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

0 comments on commit 8ac3021

Please sign in to comment.