Joshua Muheim
Joshua Muheim

Reputation: 13195

Rails: don't uglify HTML and CSS in test environment (using SLIM and Sass/Compass)?

I'm actively validating the HTML and CSS in request specs. Sadly, the error messages are very long because the HTML and CSS is uglified/compressed in test env.

I tried to remove the uglifier gem from the Gemfile, but this didn't work out. Do I miss some configuration option here? I can't find any for test.rb...

Update

I found that setting Slim::Engine.set_default_options pretty: true solved the problem for the HTML output.

The CSS is still compressed on one line though, I tried stuff like adding output_style = :nested to config/compass.css, setting Sass::Plugin.options[:style] = :expanded (raised an exception), add config.sass.output_style = :nested to test.rb, and setting # config.assets.css_compressor = nil also in test.rb. Didn't solve my problem.

Upvotes: 1

Views: 904

Answers (1)

Carlos Cervantes
Carlos Cervantes

Reputation: 1447

Try setting this in test.rb:

config.assets.debug = true

In case you're using SLIM templating engine, set pretty: true:

Slim::Engine.set_default_options pretty: true

For more info see https://github.com/slim-template/slim#default-options.

Upvotes: 3

Related Questions