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

Add generator for test/test_helper.rb #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def create_performance_test_file
template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb")
end

def create_test_helper_file
new_filename = File.join('test', 'test_helper.rb')
template 'test_helper.rb', new_filename unless File.exist?(new_filename)
end
end
end
end
12 changes: 12 additions & 0 deletions lib/generators/rails/performance_test/templates/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

module ActiveSupport
class TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all

# Add more helper methods to be used by all tests here...
end
end
1 change: 1 addition & 0 deletions test/generators/performance_test_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ def setup
def test_performance_test_skeleton_is_created
run_generator
assert_file "test/performance/dashboard_test.rb", /class DashboardTest < ActionDispatch::PerformanceTest/
assert_file "test/test_helper.rb", /class TestCase/
end
end