alchaplinsky / polymer-elements-rails

Polymer elements for Rails
https://elements.polymer-project.org/
MIT License
39 stars 17 forks source link

CSS error in rails tests #3

Open redbassett opened 9 years ago

redbassett commented 9 years ago

I am getting the following error when I run tests (but not in development):

ActionView::Template::Error: Invalid CSS after "  @apply": expected "}", was "(--paper-drawer..."
          (in /Users/<username>/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/polymer-elements-rails-1.0.0.pre.rc.1/app/assets/components/paper-drawer-panel/paper-drawer-panel.html)

As far as I can trace it back, this issue is actually in paper-drawer-panel.css (which is called in paper-drawer-panel.html). The CSS file has lines similar to this a number of times: @apply(--paper-drawer-panel-drawer-container); Any idea why this is suddenly causing an issue, only in tests, and how to fix it?

I am running version 1.0.0.pre.rc.1 of the gem.

lxbrito commented 9 years ago

@apply is a keyword used by Polymer (I think they call their notation GCSS). Probably your setup is trying to use the standard css interpreter to do the job, and not Polymer. Try to precompile your assets and use the precompiled ones in your tests. I confess to not be used to views tests, so my answer above is purely theoretical.

redbassett commented 9 years ago

What is the process for precompiling? I tried running rake assets:precompile, however it ended in an error and didn't fix the test issue:

TypeError: no implicit conversion of nil into String
  (in /Users/<username>/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/polymer-elements-rails-1.0.0.pre.rc.1/app/assets/components/gold-cc-cvc-input/test/basic.html)
lxbrito commented 9 years ago

Sorry, I forgot this one. There's 2 ways to accomplish that.

The first, ugly but effective is to monkey patch sprockets :) (take a look at my fork of polymer-rails, monkey_patch_sprockets branch, I still thinking about a pull request to Rails/sprockets). Effective, cause you could replace polymer-elements-rails with bower.

The second one is to remove all the offending files (the way this repo is committed to), but there's still no PR available with the fixes, use the master instead gem 'polymer-elements-rails', github:'alchapone/polymer-elements-rails'.

In case you feel demotivated by these bugs, have a look at MDL - Material Design Light.

redbassett commented 9 years ago

Still getting the errors after adding the Github parameter to my Gemfile and running bundle update polymer-elements-rails. Am I missing a step, or should that have fixed it?

(Apologies on the slow step-by-step with this.)

Update: Turns out it does completely break the rendered page though.

lxbrito commented 9 years ago

I think the only one who can help you is @alchapone . As I said, I took the hard way - fork, debug, patch. However I'm using Polymer for pet projects, so I feel comfortable to do nasty things like monkey patching sprockets in a fork of Rails-polymer :) and have a poor test coverage.

rxever commented 9 years ago

Hey! I'm getting the same error

TypeError: no implicit conversion of nil into String
  (in /Users/<username>/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/polymer-elements-rails-1.0.0.pre.rc.1/app/assets/components/gold-cc-cvc-input/test/basic.html)

May I ask what have you done to avoid it? Big thanks for any answers!

redbassett commented 9 years ago

Without implementing @lxbrito's monkey patch, I've currently not found a solution.