#797972 add sprockets tests for rails engines

Package:
gem2deb
Source:
gem2deb
Description:
Debian Ruby packaging suite
Submitter:
Pirate Praveen
Date:
2015-09-16 22:51:08 UTC
Severity:
wishlist
#797972#5
Date:
2015-09-04 04:48:15 UTC
From:
To:
package: gem2deb
version: 0.20.2
severity: wishlist

A simple test like this can test if the asset is installed correctly

rails new foo
cd foo
echo "//= require asset >> app/assets/javascripts/application.js
bundle exec rake assets:precompile

there should be an option --check-assets to gem2deb test runner and if
the gem name starts with rails-assets or ends with rails it should be
enabled by default.

#797972#10
Date:
2015-09-04 12:17:48 UTC
From:
To:
you can use sprockets directly instead of a full rails app. check
debian/tests/smoke-test in ruby-bootstrap-sass for an example.

assuming that deriving the asset name from the package name will
actually work, there are also quite a few details to get right, such as
adding the necessary build dependencies, and handling the paths when
running during build vs running on autopkgtest (and thus with the
package already instaled) etc.

#797972#15
Date:
2015-09-05 09:45:14 UTC
From:
To:
ok. Can you pass a javascript file sprockets?

There has to be an automated test and autopkgtest is also fine. If
app/assets or vendor/assets are found, we should add such tests with
gem2deb.

#797972#20
Date:
2015-09-05 11:53:55 UTC
From:
To:
I figured it out

$ cat app.coffee
@import favico.js
#= require favico.js

$ sprockets -r rails-assets-favico.js -I. app.coffee

#797972#25
Date:
2015-09-05 15:54:38 UTC
From:
To:
But when we are trying it for ruby-rails-assets-jquery without setting
engine root, the test still passes, so there is something missing here.

#797972#30
Date:
2015-09-06 09:44:42 UTC
From:
To:
@import always succeed and =require always fails.

Copying debian-ruby for ideas.

#797972#40
Date:
2015-09-06 12:55:51 UTC
From:
To:
@import is only for css/sass ... you want =require. the fact that it
always fails most probably means the package broken, or it's looking for
the assets in /usr/share during the build, when they are there yet.

#797972#45
Date:
2015-09-06 14:51:38 UTC
From:
To:
They are failing even after the package is installed.

Package is not broken because

bundle exec rake assets:precompile

Works fine on a rails app

rails new foo
cd foo
echo '// = require favico.js' >> app/assets/javascripts/application.js

It fails if we don't add rails-assets-favico.js to Gemfile. But it succeeds once I add it to Gemfile and run bundle install --local.

Is sprockets -r enough to load the gem?

#797972#50
Date:
2015-09-16 20:11:36 UTC
From:
To:
I have tried to implement it in gem2deb-testrunner (smoke-test branch
of gem2deb)

http://anonscm.debian.org/cgit/pkg-ruby-extras/gem2deb.git/commit/?h=smoke-test&id=c4ccfad2fc3962b2cecea96a51206e469d6a8853

Can someone review it? May be using sprockets directly is better, but
I could not get that to work. I thought a heavier test is better than
no test.

#797972#55
Date:
2015-09-16 21:11:17 UTC
From:
To:
(01:36:30  IST) j4v4m4n: terceiro: can you review smoke-test branch in
gem2deb?
(01:45:01  IST) terceiro: j4v4m4n: that's completely specific to rails
assets packages, but uses a very generic name
(01:45:18  IST) terceiro: is there a good reason to not add a new binary
(01:45:27  IST) terceiro: also, please fix the indentation
(01:45:47  IST) terceiro: (no tabs please)
(01:46:16  IST) terceiro: does it *need* to be a full blown rails app
every time?
(01:46:26  IST) terceiro: this will add a significant burden on the test
dependencies
(01:47:30  IST) terceiro: also: if `rails new foo` fails, `bundle exec
ANYTHING` will also fail
(01:49:02  IST) terceiro: and the way your code is written the test will
always pass even if everything blows up
(01:50:21  IST) j4v4m4n: adt-run fails when running rails new foo, even
though the command is successful because for some find errors
(01:50:47  IST) j4v4m4n: same errors in assets precompile step too
(01:51:18  IST) j4v4m4n: I could not get it to work with just sprockets
(01:51:37  IST) j4v4m4n: if anyone can help with that, I can remove the
full app step
(01:53:12  IST) j4v4m4n: if a new binary is better I can create it, but
I thought it is similar to check-dependencies though only for a subset
of the gems
(01:56:36  IST) j4v4m4n: terceiro: find: `./*': No such file or
directory in rails new foo makes adt-run to always fail
(01:57:23  IST) j4v4m4n: redirecting to /dev/null is a temporary hack
until I can fix it properly

(02:00:24  IST) terceiro: adt-run will fail by default if there is
anything in stderr
(02:00:40  IST) terceiro: you have to declare ignore-stderr in
Restrictions: if you expect that
(02:00:58  IST) terceiro: but my point is your code will always pass
regardless because you are not checking the result of the commands
(02:03:37  IST) j4v4m4n: I will add checks for exit status
(02:05:54  IST) terceiro: with so many shell commands I wonder if won't
be easier to write a shell script instead
(02:06:08  IST) terceiro: with `set -e`
(02:07:14  IST) j4v4m4n: ok I will make it a shell script as separate binary
(02:07:57  IST) j4v4m4n: gem2deb-assets-test?
(02:08:50  IST) terceiro: gem2deb-test-assets-package ?
(02:09:09  IST) terceiro: taking the gem name as $1, I gues
(02:09:12  IST) terceiro: I guess
(02:09:42  IST) j4v4m4n: terceiro: can you help with running sprockets
directly?
(02:10:05  IST) j4v4m4n: I tried many options but could not get it to work
(02:14:00  IST) terceiro: do you have any assets package that is not
rails-specific?
(02:17:33  IST) j4v4m4n: all of them are rails afaict
(02:17:57  IST) j4v4m4n: I will make it gem2deb-test-assets-package
(02:22:43  IST) terceiro: use rails apps, then
(02:23:50  IST) j4v4m4n: ok

#797972#60
Date:
2015-09-16 22:47:25 UTC
From:
To:
updated test-assets-package branch