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

Repro name scope error in a Rails file app #2445

Closed
wants to merge 1 commit into from

Conversation

benoittgt
Copy link
Member

Next proposal for #2423

From @pirj

Fixes #2417
Related: #2215, rails/rails#37770

See #2417 (comment) for an explanation of at least one of the possible causes


This is a draft proposal. I was not able to easily fetch existing gem and logic from our current Gemfiles.

In the source code of bundler inline:

# Allows for declaring a Gemfile inline in a ruby script, optionally installing
# any gems that aren't already installed on the user's system.

So we should not have any issue reloading existing gems from existing Gemfile.

I tried to use eval_gemfile the Gemfile:

require "bundler/inline"

gemfile(true) do
  eval_gemfile('Gemfile')
end

require "active_record/railtie"

require "ammeter"
require "rspec/autorun"
require "rspec/rails"

class Command
end

RSpec.configure do |config|
  config.use_active_record = false
end

RSpec.describe Command do
  it 'should not break' do
    Command.new
  end
end
...
|  Using actioncable 6.1.0
|  Using activestorage 6.1.0
|  Using actionmailer 6.1.0
|  Using railties 6.1.0
|  Using sprockets-rails 3.2.2
|  Using rspec 3.11.0.pre from source at `/Users/bti/code/rspec-dev/repos/rspec`
|  Using actionmailbox 6.1.0
|  Using actiontext 6.1.0
|  Using rspec-rails 4.1.0.pre from source at `.`
|  Using rails 6.1.0
|  Using ammeter 1.1.4
/Users/bti/code/rspec-dev/repos/rspec-rails/lib/rspec-rails.rb:8:in `<module:Rails>': uninitialized constant Rails (NameError)
    from /Users/bti/code/rspec-dev/repos/rspec-rails/lib/rspec-rails.rb:6:in `<module:RSpec>'
    from /Users/bti/code/rspec-dev/repos/rspec-rails/lib/rspec-rails.rb:4:in `<top (required)>'
    from /Users/bti/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:66:in `require'
    from /Users/bti/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:66:in `block (2 levels) in require'
    from /Users/bti/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `each'
    from /Users/bti/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `block in require'
....

Happy to get tips and to pair on this one.


Resources:

@benoittgt benoittgt changed the title Add a file repro app to test the fix on fixture_support name Repro name scope error in a Rails file app Jan 13, 2021
@pirj
Copy link
Member

pirj commented Jan 13, 2021

My guess is that we should run this snippet separately.
ATM we:

task default: [:spec, :acceptance]

What do you think about adding a :snippets rake task and run snippets such as this one from there one by one?
I'm happy to pair tomorrow after 6pm utc+3!

@benoittgt
Copy link
Member Author

benoittgt commented Jan 14, 2021

@pirj I think it is a good idea to use snippet somewhere else. It will be more easier to run separately.

Ping me on Telegram when you are about to start. 🙏 😊

@JonRowe
Copy link
Member

JonRowe commented Jan 15, 2021

Is this essentially part of #2423? Will it be closed by that?

@benoittgt
Copy link
Member Author

Yes sorry Jon. It can be closed now.

@benoittgt benoittgt closed this Jan 18, 2021
@benoittgt benoittgt deleted the fix-wrong-scope-name-error branch January 18, 2021 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants