From 06dcbc32fd720a601ef4ad243f55f4c9e874bddd Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Tue, 30 Jan 2024 11:23:35 +0000 Subject: [PATCH] Test legacy template tags --- lib/phlex/sgml.rb | 2 +- test/phlex/view/legacy_template_method.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/phlex/view/legacy_template_method.rb diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb index 9ef5674e..bf47a8a3 100644 --- a/lib/phlex/sgml.rb +++ b/lib/phlex/sgml.rb @@ -75,7 +75,7 @@ def template def self.method_added(method_name) if method_name == :template - warn "Defining the `template` method on a Phlex component is deprecated and will be unsupported in Phlex 2.0. Please define `view_template` instead." + Kernel.warn "Defining the `template` method on a Phlex component is deprecated and will be unsupported in Phlex 2.0. Please define `view_template` instead." end end diff --git a/test/phlex/view/legacy_template_method.rb b/test/phlex/view/legacy_template_method.rb new file mode 100644 index 00000000..feacea98 --- /dev/null +++ b/test/phlex/view/legacy_template_method.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +describe Phlex::SGML do + it "warns when you define a template" do + expect(Kernel).to receive(:warn) + + class Example < Phlex::HTML + def template + h1 { "Hello, world!" } + end + end + + expect( + Example.new.call + ).to be == "

Hello, world!

" + end +end