Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #27: Make sure only one listener is running #32

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/hotwire/spark/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Engine < ::Rails::Engine
config.hotwire = ActiveSupport::OrderedOptions.new unless config.respond_to?(:hotwire)
config.hotwire.spark = ActiveSupport::OrderedOptions.new
config.hotwire.spark.merge! \
enabled: Rails.env.development?,
enabled: Rails.env.development? && !defined?(Rails::Server).nil?,
jacob-carlborg-apoex marked this conversation as resolved.
Show resolved Hide resolved
css_paths: File.directory?("app/assets/builds") ? %w[ app/assets/builds ] : %w[ app/assets/stylesheets ],
html_paths: %w[ app/controllers app/helpers app/models app/views ],
stimulus_paths: %w[ app/javascript/controllers ]
Expand Down
11 changes: 11 additions & 0 deletions test/enabled_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "test_helper"

class EnabledTest < ActiveSupport::TestCase
test "that Hotwire-Spark is only enabled when starting the Rails server" do
script = <<~RUBY.strip
Hotwire::Spark.enabled? ? exit(1) : exit(0)
RUBY

assert system({ "RAILS_ENV" => "development" }, "rails", "runner", script, chdir: Rails.application.root)
end
end
Loading