Reputation: 2224
After upgrading to sprockets-rails
version 3.0 from version 2.3.3, the integration test below fails. It used to pass but now gives the error: Expected exactly 2 elements matching "img[src*='profile.gif']", found 0..
.
The test:
get user_path(@user1)
puts @response.body
assert_select "img[src*='profile.gif']", count: 2
puts @response.body
confirms that the image is there twice as the body includes two times:
src="/assets/account/profile-3454be0beae***256dab6d.gif"
. Nevertheless the test fails.
Does anyone understand this? And how should I solve it?
Upvotes: 0
Views: 419
Reputation: 1351
Change seems to be related with rails 4
as stated in the Asset Pipeline documentation:
Rails 4 no longer sets default config values for Sprockets in test.rb, so test.rb now requires Sprockets configuration. The old defaults in the test environment are: config.assets.compile = true, config.assets.compress = false, config.assets.debug = false and config.assets.digest = false.
So if digests are not expected in the test environment it should be explicitly configured in the config/environments/test.rb
file:
config.assets.digest = false
Upvotes: 1