Skip to content

Commit debe59c

Browse files
authored
FIX: Error when generating a controller. (#78)
1 parent 2a77d8d commit debe59c

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
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+

test/lib/generators/tailwindcss/scaffold_generator_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require "generators/tailwindcss/scaffold/scaffold_generator"
33

44
class Tailwindcss::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
5-
GENERATION_PATH = File.expand_path("../tmp", File.dirname(__FILE__))
5+
GENERATION_PATH = File.expand_path("../scaffold_tmp", File.dirname(__FILE__))
66

77
tests Tailwindcss::Generators::ScaffoldGenerator
88
destination GENERATION_PATH

0 commit comments

Comments
 (0)