Skip to content

Commit 2161fd2

Browse files
dixpacscott-knight
andcommitted
FIX: Rails controller generators.
Co-authored-by: Scott Knight <[email protected]>
1 parent a2f9353 commit 2161fd2

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "rails/generators/erb/controller/controller_generator"
2+
3+
module Tailwindcss
4+
module Generators
5+
class ControllerGenerator < Erb::Generators::ControllerGenerator
6+
source_root File.expand_path("../templates", __FILE__)
7+
end
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div>
2+
<h1 class="text-xl font-bold"><%= class_name %>#<%= @action %></h1>
3+
<p>Find me in <%= @path %></p>
4+
<div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require "test_helper"
2+
require "generators/tailwindcss/controller/controller_generator"
3+
4+
class Tailwindcss::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
5+
GENERATION_PATH = File.expand_path("../controller_tmp", File.dirname(__FILE__))
6+
7+
tests Tailwindcss::Generators::ControllerGenerator
8+
destination GENERATION_PATH
9+
10+
arguments %w(Messages index show)
11+
12+
Minitest.after_run do
13+
FileUtils.rm_rf GENERATION_PATH
14+
end
15+
16+
test "generates correct view templates" do
17+
run_generator
18+
assert_file "app/views/messages/index.html.erb"
19+
assert_file "app/views/messages/show.html.erb"
20+
end
21+
end
22+

0 commit comments

Comments
 (0)