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

allow using assets from global path instead of relative path in tests #167

Open
pravi opened this issue Mar 2, 2019 · 3 comments
Open

Comments

@pravi
Copy link

pravi commented Mar 2, 2019

When using the globally installed handlebars,

gem which handlebars_assets
/usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets.rb

all tests fails to find the assets.

1) Error:
HandlebarsAssets::CompilingTest#test_patching_handlebars:
Errno::ENOENT: No such file or directory @ rb_sysopen - vendor/assets/javascripts/handlebars.js
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:35:in `read'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:35:in `read'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:35:in `source'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:18:in `append_patch'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:24:in `block in apply_patches_to_source'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:23:in `each'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:23:in `apply_patches_to_source'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:31:in `context'
   /usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/lib/handlebars_assets/handlebars.rb:10:in `precompile'
   /tmp/autopkgtest-lxc.79gm0iv_/downtmp/build.7aH/src/test/handlebars_assets/compiling_test.rb:26:in `test_patching_handlebars'

https://ci.debian.net/data/packages/unstable/amd64/r/ruby-handlebars-assets/latest-autopkgtest/log.gz
This works when assets are present locally, but we'd like to test the installed package also in debian. If there is a way to make this look for assets relative the the installed path instead of relative to test file path, that would help.

@pravi pravi changed the title allow using assets from global path instead of relative path allow using assets from global path instead of relative path in tests Mar 2, 2019
@pravi
Copy link
Author

pravi commented Mar 2, 2019

A crude method is like this, let me try to make it more generic.

--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -80,7 +80,7 @@
       @source = nil
       @patch_path = nil
       @path = nil
-      @assets_path = nil
+      @assets_path = Pathname.new('/usr/share/rubygems-integration/all/gems/handlebars_assets-0.23.2/vendor/assets/javascripts')
     end
 
   end

@pravi
Copy link
Author

pravi commented Mar 2, 2019

This change makes all tests except one to pass

--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -80,7 +80,7 @@
       @source = nil
       @patch_path = nil
       @path = nil
-      @assets_path = nil
+      @assets_path = Pathname.new(HandlebarsAssets::PATH)
     end
 
   end


 1) Failure:
HandlebarsAssets::CompilingTest#test_custom_handlebars [/<<PKGBUILDDIR>>/test/handlebars_assets/compiling_test.rb:17]:
Expected /PRECOMPILE CALLED/ to match "{\"compiler\":[7,\">= 4.0.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n    var helper;\n\n  return \"This is \"\n    + container.escapeExpression(((helper = (helper = helpers.handlebars || (depth0 != null ? depth0.handlebars : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"handlebars\",\"hash\":{},\"data\":data}) : helper)));\n},\"useData\":true}".

28 runs, 50 assertions, 1 failures, 0 errors, 0 skips

@pravi
Copy link
Author

pravi commented Mar 2, 2019

Actually this patch also failed the same way in autopkgtest (the earlier test run was during build). For now I have disabled autopkgtest, but it'd be nice to be able to run it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant