Skip to content

FIX: Error when generating a controller. #78

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

Merged
merged 1 commit into from
Oct 1, 2021
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
9 changes: 9 additions & 0 deletions lib/generators/tailwindcss/controller/controller_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "rails/generators/erb/controller/controller_generator"

module Tailwindcss
module Generators
class ControllerGenerator < Erb::Generators::ControllerGenerator
source_root File.expand_path("../templates", __FILE__)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<h1 class="text-xl font-bold"><%= class_name %>#<%= @action %></h1>
<p>Find me in <%= @path %></p>
<div>
22 changes: 22 additions & 0 deletions test/lib/generators/tailwindcss/controller_generator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require "test_helper"
require "generators/tailwindcss/controller/controller_generator"

class Tailwindcss::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
GENERATION_PATH = File.expand_path("../controller_tmp", File.dirname(__FILE__))

tests Tailwindcss::Generators::ControllerGenerator
destination GENERATION_PATH

arguments %w(Messages index show)

Minitest.after_run do
FileUtils.rm_rf GENERATION_PATH
end

test "generates correct view templates" do
run_generator
assert_file "app/views/messages/index.html.erb"
assert_file "app/views/messages/show.html.erb"
end
end

2 changes: 1 addition & 1 deletion test/lib/generators/tailwindcss/scaffold_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "generators/tailwindcss/scaffold/scaffold_generator"

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

tests Tailwindcss::Generators::ScaffoldGenerator
destination GENERATION_PATH
Expand Down