-
Notifications
You must be signed in to change notification settings - Fork 85
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
Change default path for load routes #43
Conversation
Have you any questions to this pull request? |
@ildarkayumov Thanks for the PR. Do you mind posting a bit background info on this? i.e. How do you get this error in the first place? It looks like a file loading issue to me. |
@fredwu I put gem 'api_taster' to my Gemfile so: group :development, :staging do
gem 'api_taster', git: '[email protected]:fredwu/api_taster.git'
end When i run my tests with command: rspec, terminal returns this error: Rack::File headers parameter replaces cache_control after Rack 1.5.
/home/timurb/projects/rails3-base-api/app/api_tasters/posts.rb:1:in `<top (required)>': uninitialized constant ApiTaster (NameError)
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `each'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `block in eager_load!'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `each'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `eager_load!'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/timurb/projects/rails3-base-api/config/environment.rb:5:in `<top (required)>'
from /home/timurb/projects/rails3-base-api/spec/spec_helper.rb:6:in `require'
from /home/timurb/projects/rails3-base-api/spec/spec_helper.rb:6:in `<top (required)>'
from /home/timurb/projects/rails3-base-api/spec/api/posts_spec.rb:1:in `require'
from /home/timurb/projects/rails3-base-api/spec/api/posts_spec.rb:1:in `<top (required)>'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `load'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `each'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/command_line.rb:22:in `run'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/runner.rb:80:in `run'
from /home/timurb/projects/rails3-base-api/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/runner.rb:17:in `block in autorun'
Coverage report generated for RSpec to /home/timurb/projects/rails3-base-api/coverage. 24 / 37 LOC (64.86%) covered. But if we include gem to test group(its not good idea), its work fine. And now, if we change location of folder api_tasters to libs/api_tasters, it works too. |
Rspec is try to load "/app" folder and see so code: ApiTaster.routes do
get '/posts'
end He is return this error, because he didn't know what is ApiTaster. |
Looks to me that |
No, it doesn't help. And we do not have to test ApiTaster- files, i think, require "api_taster" - it would be superfluous... |
Now, if developer wants to load ApiTaster-routes from "/app/api_tasters", he can init this code in initialize-file config / initializers / api_taster.rb : ApiTaster::Route.path = "#{Rails.root}/app/api_tasters" |
Maybe, folder "lib/api_tasters" is not good place for this files? |
@fredwu Why do not you merge this pull request? |
Hi @ildarkayumov I really appreciate your PR! Thanks for your work! I have taken a brief look at this as well as #45 and I believe #45 is a slightly cleaner approach so I am closing this one in favour of #45. :) |
This changes to fix this error:
This error is appear, when we run rspec, when in gemfile we did not include gem 'api_taster' to test group.