Skip to content

Commit 5f69067

Browse files
committed
Fixes generator tests
- cascading test failures caused when no application.js file found during install generator. Because javascript convention changes between major rails versions, generating new sample app no longer reliably places a file at app/assets/javascripts/application.js. Now the install generator will touch that location if detect_js_format falls through, though there may be a better way to do this.
1 parent 7821ed4 commit 5f69067

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/generators/serviceworker/install_generator.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def detect_js_format
6060

6161
return [ext, "//="]
6262
end
63+
FileUtils.touch javascripts_dir("application.js")
64+
['.js', "//="]
6365
end
6466

6567
def detect_layout

test/serviceworker/install_generator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ServiceWorker::InstallGeneratorTest < ::Rails::Generators::TestCase
4545
end
4646

4747
assert_file "app/assets/javascripts/application.js" do |content|
48-
assert_match(%r{\n//= require serviceworker-companion}, content)
48+
assert_match(%r{//= require serviceworker-companion}, content)
4949
end
5050
end
5151

0 commit comments

Comments
 (0)