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

Revert "Add basic support for defining generator tests" #181

Merged
merged 1 commit into from
Mar 23, 2024
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
18 changes: 0 additions & 18 deletions spec/generators/install/install_generator_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/internal/app/views/application_view.rb

This file was deleted.

12 changes: 0 additions & 12 deletions spec/internal/app/views/components/application_component.rb

This file was deleted.

48 changes: 0 additions & 48 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,6 @@
require "rspec/rails"
require "view_helper"

# Provide an RSpec-compliant module to use the MiniTest-compliant `Rails::Generators::TestCase` class
# adapted from: https://github.com/stevehodgkiss/generator_spec
module GeneratorTestCase
def self.included(base)
require "rails/generators/test_case"

test_case = Class.new(Rails::Generators::TestCase) do
def fake_test_case; end
def add_assertion; end
end
test_case.tests base.described_class
instance = test_case.new(:fake_test_case)

base.class_variable_set :@@test_case, test_case
base.class_variable_set :@@test_case_instance, instance

base.extend(ClassMethods)
end

module ClassMethods
def tests(klass)
self.class_variable_get(:@@test_case).generator_class = klass
end

def arguments(array)
self.class_variable_get(:@@test_case).default_arguments = array
end

def destination(path)
self.class_variable_get(:@@test_case).destination_root = path
end
end

def method_missing(method_sym, *arguments, &block)
self.class.class_variable_get(:@@test_case_instance).method(method_sym).call(*arguments, &block)
end

def respond_to?(method_sym, include_private = false)
if self.class.instance_variable_get(:@@test_case_instance).respond_to?(method_sym)
true
else
super
end
end
end

RSpec.configure do |config|
config.use_transactional_fixtures = true

config.include GeneratorTestCase, type: :generator
end