Open trashhalo opened 10 years ago
It looks like we could potentially get access to the assets and asset load paths via the Sprockets Environment in the rails app. This is possible via the following:
☺ be rails c 2.2.0 45m add_github_auth_support f232e7f
Loading development environment (Rails 4.2.1)
irb(main):001:0> Rails.application.assets
=> #<Sprockets::Environment:0x3fcd2d032228 root="/Users/adeponte/code/codebreakdown/tmuxme", paths=["/Users/adeponte/code/codebreakdown/tmuxme/app/assets/images", "/Users/adeponte/code/codebreakdown/tmuxme/app/assets/javascripts", "/Users/adeponte/code/codebreakdown/tmuxme/app/assets/stylesheets", "/Users/adeponte/code/codebreakdown/tmuxme/vendor/assets/javascripts", "/Users/adeponte/code/codebreakdown/tmuxme/vendor/assets/stylesheets", "/Users/adeponte/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/turbolinks-2.5.3/lib/assets/javascripts", "/Users/adeponte/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/jquery-rails-4.0.3/vendor/assets/javascripts", "/Users/adeponte/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/coffee-rails-4.1.0/lib/assets/javascripts", "/Users/adeponte/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bootstrap-sass-3.3.4.1/assets/stylesheets", "/Users/adeponte/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bootstrap-sass-3.3.4.1/assets/javascripts", "/Users/adeponte/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bootstrap-sass-3.3.4.1/assets/fonts", "/Users/adeponte/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bootstrap-sass-3.3.4.1/assets/images"]>
The question then is how would snapdragon
get access to Rails.application.assets
? Well, could do something like Rspec where the rails_helper.rb exist and has a couple lines that load the Rails application. This could also be used for configuration in the future in the same fashion that Rspec supports configuration.
The use case we are looking at is certain javascript files are provided to us through gems. We can include these files in our deployed application via the //= require directive but its unclear how to test code that depends on this code from snapdragon without knowing the exact path the gem is sitting in the filesystem.