-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
WrongScopeError: name
when use_active_record = false
#2417
Comments
Did it work on prior versions of Rails, or is it a new project? I see a couple weird things here.
was it really Kindly appreciate if you could test your setup against gem 'rspec-rails`, github: 'rspec/rspec-rails', branch: 'rails-6-1-dev' Yet another approach would be to quote RSpec.describe 'Command' do I'd love to see |
I can verify this is definitely a problem with Rails 6.1 compatibility. We make heavy use of the latest released rspec-rails (4.0.1) with the previous version of Rails (6.0.3.4) with no problem. Upgrading to Rails 6.1 causes the above error over and over. We haven't been able to try the
I actually came across the pull request you referenced above (#2398) before this issue. It looks like that will solve this; it would be great to get a pre-release gem out. |
You'll have to point to unreleased branches of other repos (core, support, expectations, mocks) as well: gem 'rspec-support`, github: 'rspec/rspec-support', branch: 'main' There's a lot of development going on ATM, no promises on pre-release versions, sorry. |
Really appreciate if you could check if you are still experiencing this problem against |
Reopened because I want to investigate, I haven't seen anything like this so far. |
I'm going to investigate over the weekend and look to releasing a new version with 6.1 support, but can someone provide me with a spec example for this? The one above would be fine if the source for |
@JonRowe A blank class will do:
|
The solution for this was upgrading to rspec-rails 4.0.1. I was confused because as a dev I would expect this version to not be downloadable for Rails 6.1. |
@pirj It might be zero because the spec doesn't even run, it's a bug. Command is an AR model.
|
There's no good way to prevent us from future breakages due to incompatibilities introduced by Rails. E.g. you can use |
Upgrading to rspec-rails 4.0.1 does not resolve this issue for me. If there's a tight connection with rails, perhaps there should be a corresponding restriction on what versions of Rails this gem can be installed with? |
There is this https://github.com/rspec/rspec-rails/blob/main/features/README.md#rails
We could set a hard constraint on Rails version, e.g. to
|
@pirj Are there special instructions for installing the preview versions? I'm getting |
@bmulholland You typically use gem 'rspec-rails', github: 'rspec/rspec-rails', branch: 'rails-6-1-dev' |
@pirj Thanks! Your message above sounded like you'd published a package. I can't install that branch:
It seems like there's a magic incantation to install these preview builds. Sounds like that's all obvious to you, but I don't have the same context :). I'm trying to help out with your request, above, to try out the preview build - can you make that easy for me? Thanks! |
I couldn't reproduce the issue with this snippet (spin-off of this snippet recommended to submit Rails bug reports): require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", "~> 6.1.0"
gem "rspec-rails", "4.0.1"
gem "sqlite3"
end
require "active_record"
require "logger"
require 'rspec/autorun'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :commands, force: true do |t|
end
end
class Command < ActiveRecord::Base
end
RSpec.describe Command do
it 'foo' do
Command.new
end
end
I'm going to investigate this further, it seems that there might be a problem with shadowing |
@bmulholland This should fix the dependencies: gem 'rspec-rails', github: 'rspec/rspec-rails', branch: 'rails-6-1-dev'
%w[rspec-core rspec-mocks rspec-support rspec-expectations].each do |name|
gem name, github: "rspec/#{name}", branch: 'main'
end |
@bmulholland the issue there is the other gems: Same goes for Unfortunately if you still want to use those two packages you'll have to fork them and update them or else |
@rhymes Oh good point. Okay, I'll have to look into that before I can try out the sample branch, so it will have to wait. Thanks all. |
@rhymes Thanks for sharing! Not sure what breaks those two exactly, since the major version of
gem 'rspec_junit_formatter`, github: 'sj26/rspec_junit_formatter', branch: 'master' |
I'm just about to head out for the day, so I tried dropping the dependencies on
Then upgraded to Rails 6.1 and re-ran rspec. rails-rspec commit is Unfortunately, I'm still getting the same error It's possible I'm missing some of the rails 6.1 upgrade instructions, though I'd expect that to at least show a more helpful error. |
@Edouard-chin, can you please take a look? Seems related to #2215 and rails/rails#37770 |
@bmulholland Any update? Can you reproduce on a fresh Rails app? |
@pirj It did not happen on a fresh Rails app so I spent some time tracking it down. To reproduce this error, set Annoyingly, I am actually using AR in my project, although I wasn't when I first started the app. So what would be perhaps a workaround for others (enable AR support) is actually the full fix for me :) |
Thanks a lot, @bmulholland! |
@matiasgarcia @amilligan Do you happen to have |
No, this was a fresh app. |
Just to give more context. Click for code files, hidden by @JonRowe for brevity in thread.
Part of my Gemfile:
gemlock
rails_helper
spec_helper
The fix for this was to just install 4.0.1 instead of 3.9.1
But as I said, I was using a fresh Rails application generated by doing |
@matiasgarcia Thanks for confirming! |
@pirj We do not. We don't set |
@pirj Should it matter, version 4.0.2 resolved this issue in our applications that do use ActiveRecord. We have projects that do set |
Fixed in #2423 |
I'm getting what I think is a related issue - wondering if this should fix it. I don't have a reproduction on hand; if I need one, I will see what I can do. I have a spec with the following let(:name) { double(foo: "bar") } I'm getting an error from test_fixtures.rb: def run_in_transaction?
use_transactional_tests &&
!self.class.uses_transaction?(name) # <<-- "name" method name
end It's ultimately called from adapters.rb: group.around do |example|
before_setup # <<-- called from here
example.run
after_teardown
end This throws a This could be a misconfiguration on our end; this is in an branch where we're upgrading Rails and ruby, so these are the kinds of kinks we're trying to work through. When I moved the Wondering if this is still a bug, if it should get fixed with 4.1, or if it's likely a misconfiguration on our end. |
Are you using the branch where this was fixed? Or a release, as this has not been released yet. |
No, I’m not using this branch. I moved the |
* Upgrade to rails 6.1 * Fix rails new errors * Change rspec-rails version * rspec/rspec-rails#2417
I have the following spec:
Using RSpec 3.9.1 + Rails 6.1 I get:
The text was updated successfully, but these errors were encountered: