magic_test
magic_test copied to clipboard
Issue when running rails g magic_test:install command
Prerequisites:
- Rails 6.1.7.2
- ruby 3.0.3p157
- macbook pro m1
Issue:
After successful bundle install, when running rails g magic_test:install command I'm receiving error as shown below:
mateuszdrozdowski@Mateuszs-MacBook-Pro frontoffice % rails g magic_test:install
generate system_test
rails generate system_test basic
gsub test/system/basics_test.rb
/Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/actions/file_manipulation.rb:274:in `binread': No such file or directory @ rb_sysopen - /Users/mateuszdrozdowski/Documents/projects/frontoffice/test/system/basics_test.rb (Errno::ENOENT)
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/actions/file_manipulation.rb:274:in `gsub_file'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/magic_test-0.0.9/lib/generators/magic_test/install_generator.rb:18:in `install'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `block in invoke_all'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `each'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `map'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `invoke_all'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/group.rb:232:in `dispatch'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/generators.rb:275:in `invoke'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/commands/generate/generate_command.rb:26:in `perform'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/command/base.rb:69:in `perform'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/command.rb:48:in `invoke'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/railties-6.1.7.2/lib/rails/commands.rb:18:in `<main>'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/mateuszdrozdowski/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from bin/rails:9:in `<main>'
Your problem may be that require "rails/test_unit/railtie" is commented out in application.rb and/or system_tests or test_framework is set to nil on config.generators
I had the same issue and the above solution worked for me. For clarification, the issue was that I didn't have test_unit loaded during config. I use RSpec which is why test_unit was disabled.
To fix, open config/application.rb and:
- add
require 'rails/test_unit/railtie'to the top of the file - In the
config.generators do |g|block, add this line:generate.system_tests = :test_unit