Class: AeTestCoverage::Collectors::SprocketsAssetCollector
- Inherits:
-
Object
- Object
- AeTestCoverage::Collectors::SprocketsAssetCollector
- Defined in:
- lib/ae_test_coverage/collectors/sprockets_asset_collector.rb
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(asset_path) ⇒ SprocketsAssetCollector
constructor
A new instance of SprocketsAssetCollector.
Constructor Details
#initialize(asset_path) ⇒ SprocketsAssetCollector
Returns a new instance of SprocketsAssetCollector.
6 7 8 |
# File 'lib/ae_test_coverage/collectors/sprockets_asset_collector.rb', line 6 def initialize(asset_path) @asset_path = asset_path end |
Instance Method Details
#collect ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ae_test_coverage/collectors/sprockets_asset_collector.rb', line 10 def collect asset = ::Rails.application.assets[@asset_path] # It's not clear why an asset would not be found in the cache. It happens but it seems to happen rarely and repeatably # If there is a bug with assets changes not triggering a test to run, look here to see if the asset was not included # as a dependency because it was not found in the cache if asset.nil? puts "Skipping asset #{@asset_path} because it was not found in the cache" [] else asset.[:dependencies].select { |d| d.ends_with?('.js', '.es6', '.css', '.scss') } end end |