@@ -37,12 +37,15 @@ namespace :test do
3737 end
3838
3939 namespace :app do
40- task :environment do
41- ENV [ 'RAILS_ROOT' ] = TEST_APP_ROOT
42- ENV [ 'RAILS_ENV' ] = 'test'
4340
44- require ( File . join ( TEST_APP_ROOT , 'config' , 'environment' ) )
45- end
41+ desc "Initializes the test application with a couple of classes"
42+ task init : [ :seed , :customize ]
43+
44+ desc "Customize some of the functionality provided by dry_crud"
45+ task customize : [ 'test:app:add_pagination' ,
46+ 'test:app:use_bootstrap' ,
47+ 'test:app:build_assets'
48+ ]
4649
4750 desc "Create a rails test application"
4851 task :create do
@@ -53,10 +56,6 @@ namespace :test do
5356 File . read ( File . join ( File . dirname ( __FILE__ ) ,
5457 'test' , 'templates' , 'Gemfile.append' ) ) )
5558 sh "cd #{ TEST_APP_ROOT } ; bundle install --local" # update Gemfile.lock
56- #sh "cd #{TEST_APP_ROOT}; bundle binstubs bundler"
57- #sh "cd #{TEST_APP_ROOT}; rails javascript:install:esbuild"
58- #sh "cd #{TEST_APP_ROOT}; yarn add esbuild from \".\""
59- #sh "cd #{TEST_APP_ROOT}; gem install foreman from \".\""
6059
6160 sh "cd #{ TEST_APP_ROOT } ; rails g rspec:install"
6261 FileUtils . rm_f ( File . join ( TEST_APP_ROOT ,
@@ -87,6 +86,13 @@ namespace :test do
8786 destination_root : TEST_APP_ROOT ) . invoke_all
8887 end
8988
89+ task :environment do
90+ ENV [ 'RAILS_ROOT' ] = TEST_APP_ROOT
91+ ENV [ 'RAILS_ENV' ] = 'test'
92+
93+ require ( File . join ( TEST_APP_ROOT , 'config' , 'environment' ) )
94+ end
95+
9096 desc "Populates the test application with some models and controllers"
9197 task populate : [ :generate_crud ] do
9298 # copy test app templates
@@ -117,15 +123,6 @@ namespace :test do
117123 end
118124 end
119125
120- desc "Initializes the test application with a couple of classes"
121- task init : [ :seed , :customize ]
122-
123- desc "Customize some of the functionality provided by dry_crud"
124- task customize : [ 'test:app:add_pagination' ,
125- 'test:app:add_ujs' ,
126- 'test:app:use_bootstrap'
127- ]
128-
129126 desc "Adds pagination to the test app"
130127 task :add_pagination do
131128 list_ctrl = File . join ( TEST_APP_ROOT ,
@@ -145,17 +142,6 @@ namespace :test do
145142 "= paginate entries\n \n = render 'list'" )
146143 end
147144
148- desc "Adds Rails UJS to the test app"
149- task :add_ujs do
150- sh "cd #{ TEST_APP_ROOT } ; yarn add @rails/ujs"
151- app_js = File . join ( TEST_APP_ROOT , 'app' , 'javascript' , 'application.js' )
152- if File . exist? ( app_js ) && File . read ( app_js ) !~ /ujs/
153- file_replace ( app_js ,
154- /\n \z / ,
155- "\n import Rails from '@rails/ujs'\n Rails.start()\n " )
156- end
157- end
158-
159145 desc "Use Boostrap Icons in the test app"
160146 task :use_bootstrap do
161147 sh "cd #{ TEST_APP_ROOT } ; yarn add bootstrap-icons"
@@ -178,6 +164,10 @@ namespace :test do
178164 'app' , 'assets' , 'stylesheets' , 'sample.scss' ) )
179165 end
180166
167+ desc "Build javascript and css in the test app"
168+ task :build_assets do
169+ sh "cd #{ TEST_APP_ROOT } ; rails javascript:build css:build"
170+ end
181171 end
182172end
183173
0 commit comments